Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge develop into main #1372

Merged
merged 11 commits into from
May 3, 2024
5 changes: 5 additions & 0 deletions .github/workflows/build-with-nix.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: build with nix

on:
pull_request:
branches:
- main
schedule:
# 01:00 every Sunday morning
- cron: '0 1 * * 0'
workflow_dispatch: {}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand Down
21 changes: 10 additions & 11 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ on:
pull_request:
branches:
- main
- develop
push:
branches:
- develop
- main
schedule:
# 03:00 every Saturday morning
- cron: '0 3 * * 6'
Expand Down Expand Up @@ -63,7 +62,7 @@ jobs:
tket_package_exists=`conan search -r tket-libs "tket/${{ steps.tket_ver.outputs.tket_ver }}@tket/stable" | grep "not found" > /dev/null 2>&1 && echo false || echo true`
echo "tket_package_exists=${tket_package_exists}" >> $GITHUB_OUTPUT
- name: Check tket version bump
if: github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'develop' && steps.filter.outputs.tket == 'true' && steps.test_package_exists.outputs.tket_package_exists == 'true'
if: github.event_name == 'pull_request' && steps.filter.outputs.tket == 'true' && steps.test_package_exists.outputs.tket_package_exists == 'true'
run: exit 1

check_docs_tket:
Expand Down Expand Up @@ -138,7 +137,7 @@ jobs:
- name: Build tket
run: conan create tket -s build_type=Release --user=tket --channel=stable -o boost/*:header_only=True -o with_all_tests=True
- name: Upload package
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
if: github.event_name == 'push'
run: |
ccache --set-config namespace=WITHOUT_TESTS
conan create tket --user=tket --channel=stable -o boost/*:header_only=True
Expand Down Expand Up @@ -207,7 +206,7 @@ jobs:
conan build tket --user=tket --channel=stable -o boost/*:header_only=True -o with_all_tests=True -c tools.cmake.cmaketoolchain:generator=Ninja
conan export-pkg tket --user=tket --channel=stable -o boost/*:header_only=True -o with_all_tests=True -c tools.cmake.cmaketoolchain:generator=Ninja
- name: Upload package
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
if: github.event_name == 'push'
run: |
ccache --set-config namespace=WITHOUT_TESTS
conan build tket --user=tket --channel=stable -o boost/*:header_only=True
Expand Down Expand Up @@ -319,7 +318,7 @@ jobs:
name: pytket_test_coverage
path: pytket/tests/htmlcov
- name: Upload package
if: github.event_name == 'push' && github.ref == 'refs/heads/develop' && needs.check_changes.outputs.tket_changed == 'true'
if: github.event_name == 'push' && needs.check_changes.outputs.tket_changed == 'true'
run: |
conan remote login -p ${{ secrets.JFROG_ARTIFACTORY_TOKEN_3 }} tket-libs ${{ secrets.JFROG_ARTIFACTORY_USER_3 }}
conan upload tket/${{ needs.check_changes.outputs.tket_ver }}@tket/stable -r=tket-libs
Expand Down Expand Up @@ -409,7 +408,7 @@ jobs:
git diff --quiet pytket/_tket && echo "Stubs are up-to-date" || exit 1 # fail if stubs change after regeneration
python -m mypy --config-file=mypy.ini --no-incremental -p pytket -p tests
- name: Upload package
if: github.event_name == 'push' && github.ref == 'refs/heads/develop' && needs.check_changes.outputs.tket_changed == 'true'
if: github.event_name == 'push' && needs.check_changes.outputs.tket_changed == 'true'
run: |
conan remote login -p ${{ secrets.JFROG_ARTIFACTORY_TOKEN_3 }} tket-libs ${{ secrets.JFROG_ARTIFACTORY_USER_3 }}
conan upload tket/${{ needs.check_changes.outputs.tket_ver }}@tket/stable -r=tket-libs
Expand Down Expand Up @@ -521,7 +520,7 @@ jobs:
pip install -r requirements.txt
pytest --ignore=simulator/
- name: Upload package
if: github.event_name == 'push' && github.ref == 'refs/heads/develop' && needs.check_changes.outputs.tket_changed == 'true'
if: github.event_name == 'push' && needs.check_changes.outputs.tket_changed == 'true'
run: |
conan remote login -p ${{ secrets.JFROG_ARTIFACTORY_TOKEN_3 }} tket-libs ${{ secrets.JFROG_ARTIFACTORY_USER_3 }}
conan upload tket/${{ needs.check_changes.outputs.tket_ver }}@tket/stable -r=tket-libs
Expand All @@ -534,7 +533,7 @@ jobs:
name: Publish pytket coverage
needs: build_test_pytket_ubuntu
concurrency: gh_pages
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
if: github.event_name == 'push'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -562,7 +561,7 @@ jobs:
check_pytket_coverage:
name: Check pytket line and branch coverage
needs: build_test_pytket_ubuntu
if: (github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'develop') || github.event_name == 'workflow_dispatch'
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -571,7 +570,7 @@ jobs:
with:
name: pytket_test_coverage
path: pytket-test-coverage/
- name: Compare with latest report from develop
- name: Compare with latest report from main
run: |
wget https://cqcl.github.io/tket/pytket/test-coverage/cov.xml -O oldcov.xml
./.github/workflows/compare-pytket-coverage oldcov.xml pytket-test-coverage/cov.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: build libraries
on:
push:
branches:
- develop
- main
pull_request:
branches:
- develop
- main
workflow_dispatch: {}

jobs:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Analyse tket C++ test coverage
on:
pull_request:
branches:
- develop
- main
push:
branches:
- develop
- main
schedule:
# 03:00 every Saturday morning
- cron: '0 3 * * 6'
Expand Down Expand Up @@ -99,12 +99,12 @@ jobs:
with:
name: test_coverage
path: test-coverage/
- name: Compare with latest report from develop (short tests)
- name: Compare with latest report from main (short tests)
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
run: |
wget https://cqcl.github.io/tket/tket/test-coverage-short/summary.txt
./.github/workflows/compare-coverage summary.txt test-coverage/summary.txt
- name: Compare with latest report from develop (full suite)
- name: Compare with latest report from main (full suite)
if: github.event_name == 'schedule'
run: |
wget https://cqcl.github.io/tket/tket/test-coverage/summary.txt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy tket C++ documentation
on:
push:
branches:
- develop
- main
paths:
- 'tket/src/**'

Expand Down
107 changes: 107 additions & 0 deletions .github/workflows/pytket_benchmarking.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Automated Benchmarks

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:

build_wheels:
name: Build macos wheels
runs-on: macos-14

steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'

- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Install conan
uses: turtlebrowser/get-conan@v1.2

- name: Set up conan
run: |
conan profile detect
DEFAULT_PROFILE_PATH=`conan profile path default`
PROFILE_PATH=./conan-profiles/macos-14
diff ${DEFAULT_PROFILE_PATH} ${PROFILE_PATH} || true
cp ${PROFILE_PATH} ${DEFAULT_PROFILE_PATH}
conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0

- name: Build tket C++
run: conan create tket --user tket --channel stable --build=missing -o boost/*:header_only=True -o tklog/*:shared=True -o tket/*:shared=True -tf ""

- name: Build wheel
run: |
conan create recipes/pybind11
conan create recipes/pybind11_json/all --version 0.2.13
cd pytket
# Ensure wheels are compatible with MacOS 12.0 and later:
export WHEEL_PLAT_NAME=macosx_12_0_arm64
python3.11 -m pip install -U pip build delocate
python3.11 -m build
delocate-wheel -v -w "$GITHUB_WORKSPACE/wheelhouse/" "dist/pytket-"*".whl"

- name: Save Wheel
uses: actions/upload-artifact@v4
with:
name: pytket_wheel
path: wheelhouse/

compile-and-compare:
name: Compile and compare
runs-on: macos-14
needs: build_wheels

steps:

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Download wheel
uses: actions/download-artifact@v4
with:
name: pytket_wheel

- name: Install dependencies
run: |
pip install pytket-*.whl
pip install --pre --index-url https://github_actions:${{ secrets.PRIVATE_PYPI_PASS }}@cqcpythonrepository.azurewebsites.net/simple/ pytket_benchmarking

- name: Checkout pytket-benchmarking-store
uses: actions/checkout@v4
with:
repository: CQCL/pytket-benchmarking-store
path: pytket-benchmarking-store

- name: Perform Compilation
run: |
pytket_benchmarking compile QiskitIBMQ pytket-benchmarking-store/benchmarking_circuits/quantum_volume automated_benchmarks_compiled
pytket_benchmarking compile PytketIBMQ pytket-benchmarking-store/benchmarking_circuits/quantum_volume automated_benchmarks_compiled

- name: Save compiled circuits
uses: actions/upload-artifact@v4
with:
name: automated_benchmarks_compiled
path: automated_benchmarks_compiled/

- name: Calculate percentage better
run: echo "RETURN_TEST=$(pytket_benchmarking percentage-better pytket-benchmarking-store/benchmarking_circuits/quantum_volume automated_benchmarks_compiled PytketIBMQ)" >> $GITHUB_ENV

- name: Create comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: '${{ env.RETURN_TEST }}'
env:
RETURN_TEST: ${{ env.RETURN_TEST }}
7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ jobs:
build_macos_arm64_wheels:
name: Build macos arm64 wheels
runs-on: macos-14
env:
MACOSX_DEPLOYMENT_TARGET: '12.0'
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
Expand All @@ -130,16 +132,15 @@ jobs:
cp ${PROFILE_PATH} ${DEFAULT_PROFILE_PATH}
conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: Build tket C++
run: conan create tket --user tket --channel stable --build=missing -o boost/*:header_only=True -o tklog/*:shared=True -o tket/*:shared=True -tf ""
run: conan create tket --user tket --channel stable --build="*" -o boost/*:header_only=True -o tklog/*:shared=True -o tket/*:shared=True -tf ""
- name: Build wheel
run: |
conan create recipes/pybind11
conan create recipes/pybind11_json/all --version 0.2.13
cd pytket
# Ensure wheels are compatible with MacOS 12.0 and later:
export WHEEL_PLAT_NAME=macosx_12_0_arm64
python${{ matrix.python-version }} -m pip install -U pip build
python${{ matrix.python-version }} -m pip install delocate~=0.10.7
python${{ matrix.python-version }} -m pip install -U pip build delocate
python${{ matrix.python-version }} -m build
delocate-wheel -v -w "$GITHUB_WORKSPACE/wheelhouse/" "dist/pytket-"*".whl"
- uses: actions/upload-artifact@v4
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test_libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: test libraries
on:
push:
branches:
- develop
- main
pull_request:
branches:
- develop
- main
workflow_dispatch: {}

env:
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
with:
name: ${{ matrix.lib }}_coverage
path: ${{ matrix.lib }}-coverage/
- name: check coverage against latest published data from develop
- name: check coverage against latest published data from main
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
run: |
# File may not exist if this is the very first time, so don't error.
Expand All @@ -146,7 +146,7 @@ jobs:
publish_coverage:
name: Publish coverage
needs: [set_libs_matrix, generate_coverage]
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' && needs.set_libs_matrix.outputs.libs != '[]' && needs.set_libs_matrix.outputs.libs != '' }}
if: ${{ github.event_name == 'push' && needs.set_libs_matrix.outputs.libs != '[]' && needs.set_libs_matrix.outputs.libs != '' }}
strategy:
matrix:
lib: ${{ fromJson(needs.set_libs_matrix.outputs.libs) }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: valgrind check
on:
pull_request:
branches:
- develop
- main
workflow_dispatch: {}

schedule:
Expand Down
16 changes: 8 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Contributing to TKET

Pull requests are welcome. To make a PR, first fork the repo, make your proposed
changes on the `develop` branch, and open a PR from your fork. If it passes
changes on the `main` branch, and open a PR from your fork. If it passes
tests and is accepted after review, it will be merged in.

When adding a new feature, please add tests for it. When fixing a bug, please
add a test that demonstrates the fix.

If you make a change to one of the libraries in the `libs` directory, please
increase the version number and make a PR with that change only: the component
will then be tested on the CI, and on merge to `develop` the new version will be
will then be tested on the CI, and on merge to `main` the new version will be
uploaded. Then it will be possible to update conan requirements to use the new
version.

A new version of TKET is uploaded to our conan repo with each push to `develop`
A new version of TKET is uploaded to our conan repo with each push to `main`
that changes the core library. This process is managed by CI workflows. If you
are making changes only to TKET tests or pytket, you do not need to build TKET
locally: the right version should be downloaded automatically from the conan
Expand Down Expand Up @@ -80,7 +80,7 @@ If you make any changes in `tket/src`, you should bump the version number of
`tket` in `recipes/tket/conanfile.py`, and also the `tket` versions in the
`requires` field in `recipes/tket-test/conanfile.py`,
`recipes/tket-proptests/conanfile.py` and `pytket/conanfile.txt` so that they
match the new version. (This is checked on the CI for all PRs to `develop`.)
match the new version. (This is checked on the CI for all PRs to `main`.)
Follow the "semantic versioning" convention: any backwards-incompatible changes
to the C++ API require a major version bump; new API features that maintain
backwards compatibility require a minor version bump; internal improvements and
Expand All @@ -92,21 +92,21 @@ bugfixes require a patch version bump.

The code coverage of the `tket` tests is reported
[here](https://cqcl.github.io/tket/tket/test-coverage/index.html). This report
is generated weekly from the `develop` branch.
is generated weekly from the `main` branch.

The libraries' coverage (from their own unit tests) is also reported: for
example [tklog](https://cqcl.github.io/tket/tket/tklog-coverage/index.html).
(For other libraries, just replace "tklog" with the library name in the URL.)

In both cases, PRs to `develop` check that the coverage has not decreased, and
In both cases, PRs to `main` check that the coverage has not decreased, and
merging is blocked until the coverage is at least as good as before.

### pytket

The code coverage of the `pytket` tests is reported
[here](https://cqcl.github.io/tket/pytket/test-coverage/index.html). This report
reflects the coverage of the `develop` branch, and is updated with every push.
reflects the coverage of the `main` branch, and is updated with every push.
The same report can be found in XML format
[here](https://cqcl.github.io/tket/pytket/test-coverage/cov.xml).

Lines and branch coverage results are also checked with every PR to `develop`.
Lines and branch coverage results are also checked with every PR to `main`.
Loading
Loading