Skip to content

Commit

Permalink
clean up (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-melf authored Jul 26, 2022
1 parent 6d437cf commit 6997521
Show file tree
Hide file tree
Showing 38 changed files with 75 additions and 285 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS

This file was deleted.

92 changes: 18 additions & 74 deletions .github/workflows/build-test
Original file line number Diff line number Diff line change
Expand Up @@ -27,92 +27,36 @@ git clean -dfx

echo "Module to test: ${MODULE}"

MODULEDIR="${GITHUB_WORKSPACE}/modules"
MODULEDIR="${GITHUB_WORKSPACE}"

ARTIFACTSDIR=${GITHUB_WORKSPACE}/wheelhouse

rm -rf ${ARTIFACTSDIR} && mkdir ${ARTIFACTSDIR}

python -m pip install --upgrade pip wheel build

function unsupported() {
case "$1" in
pytket-iqm)
# The iqm-client package is not available for 3.8.
[[ "${PYVER}" == "3.8" ]] && return
;;
pytket-qsharp)
# Cannot install qsharp on Windows with 3.10.
[[ "${PLAT}" == "Windows" && ${PYVER} == "3.10" ]] && return
;;
pytket-qulacs)
# Cannot install qulacs on MacOS or Windows with 3.10.
[[ "${PLAT}" != "Linux" && "${PYVER}" == "3.10" ]] && return
;;
*)
false
;;
esac
}

function skip_tests() {
case "$1" in
pytket-qsharp)
case "${PLAT}" in
Darwin)
# Test timeout issues
[[ ${PYVER} == "3.10" ]] && return
;;
*)
false
;;
esac
;;
*)
false
;;
esac
}

# Generate and install the package
if ! (unsupported ${MODULE}) ; then
echo "${MODULE}..."
cd ${MODULEDIR}/${MODULE}
python -m build
for w in dist/*.whl ; do
python -m pip install $w
cp $w ${ARTIFACTSDIR}
done
fi
python -m build
for w in dist/*.whl ; do
python -m pip install $w
cp $w ${ARTIFACTSDIR}
done

# Test and mypy:
if [[ "${MYPY}" = "mypy" ]]
then
python -m pip install --upgrade mypy
fi
if ! (unsupported ${MODULE}) ; then
if ! (skip_tests ${MODULE}) ; then
echo "${MODULE}..."

cd ${MODULEDIR}/${MODULE}/tests

python -m pip install --pre -r test-requirements.txt

if [[ "${MODULE}" = "pytket-qsharp" && "${PLAT}" != "Darwin" ]]
then
dotnet iqsharp install --user
fi

# Disable the remote tests for pytket-aqt and -qsharp for now
if [[ "${MODULE}" = "pytket-aqt" || "${MODULE}" = "pytket-qsharp" ]]; then
unset PYTKET_RUN_REMOTE_TESTS; pytest --doctest-modules
else
pytest --doctest-modules
fi

if [[ "${MYPY}" = "mypy" ]]
then
${MODULEDIR}/mypy-check ${MODULEDIR}/${MODULE}
fi
fi

cd ${GITHUB_WORKSPACE}/tests

python -m pip install --pre -r test-requirements.txt

pytest --doctest-modules

cd ..

if [[ "${MYPY}" = "mypy" ]]
then
${GITHUB_WORKSPACE}/mypy-check ${GITHUB_WORKSPACE}}
fi
165 changes: 22 additions & 143 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ env:
PYTKET_REMOTE_QUANTINUUM_PASSWORD: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_PASSWORD }}

jobs:
linux-checks:
name: Linux - Build and test module
runs-on: ubuntu-20.04

quantinuum-checks:
name: Quantinuum - Build and test module
strategy:
matrix:
os: ['ubuntu-20.04', 'macos-11', 'windows-2019']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* +refs/heads/*:refs/remotes/origin/*

- name: Set up Python 3.8
if: github.event_name == 'push'
uses: actions/setup-python@v3
Expand All @@ -38,23 +39,23 @@ jobs:
if: github.event_name == 'push'
run: |
./.github/workflows/build-test nomypy
env:
MODULE: ${{ matrix.module }}
- name: Set up Python 3.9
if: github.event_name == 'pull_request' || github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel')
uses: actions/setup-python@v3
with:
python-version: '3.9'
- name: Build and test including remote checks (3.9)
if: |
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
|| github.event_name == 'release'
|| contains(github.ref, 'refs/heads/wheel')
- name: Build and test including remote checks (3.9) mypy
if: (matrix.os == 'macos-11') && ((github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel'))
run: |
./.github/workflows/build-test mypy
env:
PYTKET_RUN_REMOTE_TESTS: 1
- name: Build and test including remote checks (3.9) nomypy
if: (matrix.os != 'macos-11') && ((github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel'))
run: |
./.github/workflows/build-test nomypy
env:
# PYTKET_RUN_REMOTE_TESTS: 1
MODULE: ${{ matrix.module }}
PYTKET_RUN_REMOTE_TESTS: 1
- name: Set up Python 3.10
if: github.event_name == 'push' || github.event_name == 'pull_request'
uses: actions/setup-python@v3
Expand All @@ -64,138 +65,16 @@ jobs:
if: github.event_name == 'push' || github.event_name == 'pull_request'
run: |
./.github/workflows/build-test nomypy
env:
MODULE: ${{ matrix.module }}
- uses: actions/upload-artifact@v3
if: github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel')
with:
name: artefacts
path: wheelhouse/

macos-checks:
name: MacOS - Build and test module
runs-on: macos-11

steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* +refs/heads/*:refs/remotes/origin/*

- name: Set up Python 3.8
if: github.event_name == 'push'
uses: actions/setup-python@v3
with:
python-version: '3.8'
- name: Build and test (3.8)
if: github.event_name == 'push'
run: |
./.github/workflows/build-test nomypy
env:
MODULE: ${{ matrix.module }}

- name: Set up Python 3.9
if: github.event_name == 'pull_request'
uses: actions/setup-python@v3
with:
python-version: '3.9'
- name: Build and test including remote checks and mypy (3.9)
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
run: |
./.github/workflows/build-test mypy
env:
# PYTKET_RUN_REMOTE_TESTS: 1
MODULE: ${{ matrix.module }}

- name: Set up Python 3.10
if: github.event_name == 'push' || github.event_name == 'pull_request'
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Build and test (3.10)
if: github.event_name == 'push' || github.event_name == 'pull_request'
run: |
./.github/workflows/build-test nomypy
env:
MODULE: ${{ matrix.module }}

windows-checks:
name: Windows - Build and test module
runs-on: windows-2019

steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* +refs/heads/*:refs/remotes/origin/*
- name: Set up Python 3.8
if: github.event_name == 'push'
uses: actions/setup-python@v3
with:
python-version: '3.8'
- name: Build and test (3.8)
if: github.event_name == 'push'
shell: bash
run: |
./.github/workflows/build-test nomypy
env:
MODULE: ${{ matrix.module }}
- name: Set up Python 3.9
if: github.event_name == 'pull_request'
uses: actions/setup-python@v3
with:
python-version: '3.9'
- name: Build and test including remote checks (3.9)
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
shell: bash
run: |
./.github/workflows/build-test nomypy
env:
# PYTKET_RUN_REMOTE_TESTS: 1
MODULE: ${{ matrix.module }}
- name: Set up Python 3.10
if: github.event_name == 'push' || github.event_name == 'pull_request'
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Build and test (3.10)
if: github.event_name == 'push' || github.event_name == 'pull_request'
shell: bash
run: |
./.github/workflows/build-test nomypy
env:
MODULE: ${{ matrix.module }}

linux:
name: Build and test (Linux)
runs-on: ubuntu-20.04
needs: linux-checks
steps:
- name: All linux checks should have succeeded by now
run: exit 0

macos:
if: github.event_name != 'release'
name: Build and test (MacOS)
needs: macos-checks
runs-on: ubuntu-20.04
steps:
- name: All macos checks should have succeeded by now
run: exit 0

windows:
if: github.event_name != 'release'
name: Build and test (Windows)
needs: windows-checks
runs-on: ubuntu-20.04
steps:
- name: All windows checks should have succeeded by now
run: exit 0

publish_to_pypi:
name: Publish to pypi
if: github.event_name == 'release'
needs: linux
needs: quantinuum-checks
runs-on: ubuntu-20.04
steps:
- name: Download all wheels
Expand All @@ -206,12 +85,12 @@ jobs:
run: |
mkdir dist
for w in `find wheelhouse/ -type f -name "*.whl"` ; do cp $w dist/ ; done
#- name: Publish wheels
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# user: __token__
# password: ${{ secrets.PYPI_EXTENSIONS_API_TOKEN }}
# verbose: true
- name: Publish wheels
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_PYTKET_QUANTINUUM_API_TOKEN }}
verbose: true

docs:
name: Build and publish docs
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pytket Extensions Docs
name: Pytket Quantinuum Docs

on:
push:
Expand All @@ -20,9 +20,8 @@ jobs:
python-version: 3.9
- name: Upgrade pip and install wheel
run: pip install --upgrade pip wheel
- name: Install pytket extensions
run: |
cd modules/pytket-quantinuum/
- name: Install pytket quantinuum
run: |
pip install .
- name: Install docs dependencies
run: |
Expand Down
Loading

0 comments on commit 6997521

Please sign in to comment.