|
| 1 | +name: Build and test |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - develop |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - develop |
| 11 | + - 'wheel/**' |
| 12 | + release: |
| 13 | + types: |
| 14 | + - created |
| 15 | + - edited |
| 16 | + |
| 17 | +env: |
| 18 | + PYTKET_REMOTE_QISKIT_TOKEN: ${{ secrets.PYTKET_REMOTE_QISKIT_TOKEN }} |
| 19 | + |
| 20 | +jobs: |
| 21 | + qiskit-checks: |
| 22 | + name: Qiskit - Build and test module |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + os: ['ubuntu-20.04', 'macos-11', 'windows-2019'] |
| 26 | + runs-on: ${{ matrix.os }} |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v3 |
| 29 | + with: |
| 30 | + fetch-depth: '0' |
| 31 | + - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* +refs/heads/*:refs/remotes/origin/* |
| 32 | + - name: Set up Python 3.8 |
| 33 | + if: github.event_name == 'push' |
| 34 | + uses: actions/setup-python@v3 |
| 35 | + with: |
| 36 | + python-version: '3.8' |
| 37 | + - name: Build and test (3.8) |
| 38 | + if: github.event_name == 'push' |
| 39 | + shell: bash |
| 40 | + run: | |
| 41 | + ./.github/workflows/build-test nomypy |
| 42 | + - name: Set up Python 3.9 |
| 43 | + if: github.event_name == 'pull_request' || github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel') |
| 44 | + uses: actions/setup-python@v3 |
| 45 | + with: |
| 46 | + python-version: '3.9' |
| 47 | + - name: Build and test including remote checks (3.9) mypy |
| 48 | + 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')) |
| 49 | + shell: bash |
| 50 | + run: | |
| 51 | + ./.github/workflows/build-test mypy |
| 52 | + env: |
| 53 | + PYTKET_RUN_REMOTE_TESTS: 1 |
| 54 | + - name: Build and test including remote checks (3.9) nomypy |
| 55 | + 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')) |
| 56 | + shell: bash |
| 57 | + run: | |
| 58 | + ./.github/workflows/build-test nomypy |
| 59 | + env: |
| 60 | + PYTKET_RUN_REMOTE_TESTS: 1 |
| 61 | + - name: Set up Python 3.10 |
| 62 | + if: github.event_name == 'push' || github.event_name == 'pull_request' |
| 63 | + uses: actions/setup-python@v3 |
| 64 | + with: |
| 65 | + python-version: '3.10' |
| 66 | + - name: Build and test (3.10) |
| 67 | + if: github.event_name == 'push' || github.event_name == 'pull_request' |
| 68 | + shell: bash |
| 69 | + run: | |
| 70 | + ./.github/workflows/build-test nomypy |
| 71 | + - uses: actions/upload-artifact@v3 |
| 72 | + if: github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel') |
| 73 | + with: |
| 74 | + name: artefacts |
| 75 | + path: wheelhouse/ |
| 76 | + - name: Install docs dependencies |
| 77 | + if: (matrix.os == 'ubuntu-20.04') && (github.event_name == 'pull_request') |
| 78 | + run: | |
| 79 | + pip install -r .github/workflows/docs/requirements.txt |
| 80 | + - name: Build docs |
| 81 | + if: (matrix.os == 'ubuntu-20.04') && (github.event_name == 'pull_request') |
| 82 | + timeout-minutes: 20 |
| 83 | + run: | |
| 84 | + ./.github/workflows/docs/check-build-docs |
| 85 | +
|
| 86 | +
|
| 87 | + publish_to_pypi: |
| 88 | + name: Publish to pypi |
| 89 | + if: github.event_name == 'release' |
| 90 | + needs: qiskit-checks |
| 91 | + runs-on: ubuntu-20.04 |
| 92 | + steps: |
| 93 | + - name: Download all wheels |
| 94 | + uses: actions/download-artifact@v3 |
| 95 | + with: |
| 96 | + path: wheelhouse |
| 97 | + - name: Put them all in the dist folder |
| 98 | + run: | |
| 99 | + mkdir dist |
| 100 | + for w in `find wheelhouse/ -type f -name "*.whl"` ; do cp $w dist/ ; done |
| 101 | + - name: Publish wheels |
| 102 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 103 | + with: |
| 104 | + user: __token__ |
| 105 | + password: ${{ secrets.PYPI_PYTKET_QISKIT_API_TOKEN }} |
| 106 | + verbose: true |
| 107 | + |
| 108 | + docs: |
| 109 | + name: Build and publish docs |
| 110 | + if: github.event_name == 'release' |
| 111 | + needs: publish_to_pypi |
| 112 | + runs-on: ubuntu-20.04 |
| 113 | + steps: |
| 114 | + - uses: actions/checkout@v3 |
| 115 | + with: |
| 116 | + fetch-depth: '0' |
| 117 | + - name: Set up Python 3.9 |
| 118 | + uses: actions/setup-python@v3 |
| 119 | + with: |
| 120 | + python-version: '3.9' |
| 121 | + - name: Download all wheels |
| 122 | + uses: actions/download-artifact@v3 |
| 123 | + with: |
| 124 | + path: wheelhouse |
| 125 | + - name: Install pip, wheel |
| 126 | + run: pip install -U pip wheel |
| 127 | + - name: Install extensions |
| 128 | + run: for w in `find wheelhouse/ -type f -name "*.whl"` ; do pip install $w ; done |
| 129 | + - name: Install docs dependencies |
| 130 | + run: | |
| 131 | + pip install -r .github/workflows/docs/requirements.txt |
| 132 | + - name: Build docs |
| 133 | + timeout-minutes: 20 |
| 134 | + run: | |
| 135 | + cd .github/workflows/docs |
| 136 | + mkdir extensions |
| 137 | + ./build-docs -d ${GITHUB_WORKSPACE}/.github/workflows/docs/extensions |
| 138 | + - name: Configure git |
| 139 | + run: | |
| 140 | + git config --global user.email "tket-bot@cambridgequantum.com" |
| 141 | + git config --global user.name "«$GITHUB_WORKFLOW» github action" |
| 142 | + - name: Check out gh-pages branch |
| 143 | + run: git checkout gh-pages |
| 144 | + - name: Remove old docs |
| 145 | + run: git rm -r --ignore-unmatch docs/api |
| 146 | + - name: Add generated docs to repository |
| 147 | + run: | |
| 148 | + mkdir -p docs |
| 149 | + mv .github/workflows/docs/extensions docs/api |
| 150 | + git add -f docs/api |
| 151 | + git commit --allow-empty -m "Add generated documentation." |
| 152 | + - name: Publish docs |
| 153 | + run: git push origin gh-pages:gh-pages |
0 commit comments