Skip to content

Add kwargs to arguments for Backend.get_compiled_circuit #1977

Add kwargs to arguments for Backend.get_compiled_circuit

Add kwargs to arguments for Backend.get_compiled_circuit #1977

Workflow file for this run

name: test libraries
on:
push:
branches:
- develop
pull_request:
branches:
- develop
workflow_dispatch: {}
env:
ALL_LIBS: '["tklog", "tkassert", "tkrng", "tktokenswap", "tkwsm"]'
jobs:
changes:
runs-on: ubuntu-22.04
outputs:
tklog: ${{ steps.filter.outputs.tklog }}
tkassert: ${{ steps.filter.outputs.tkassert }}
tkrng: ${{ steps.filter.outputs.tkrng }}
libs: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v3
- uses: dorny/[email protected]
id: filter
with:
base: ${{ github.ref }}
filters: |
tklog:
- 'libs/tklog/**'
tkassert:
- 'libs/tkassert/**'
tkrng:
- 'libs/tkrng/**'
tktokenswap:
- 'libs/tktokenswap/**'
tkwsm:
- 'libs/tkwsm/**'
gh_actions:
- '.github/workflows/test_libs.yml'
set_libs_matrix:
name: Set the libs strategy matrix
needs: changes
runs-on: ubuntu-22.04
outputs:
libs: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set LIBS_TO_TEST to all the libraries
# Test all libraries if the test_libs.yml file was modified
if: ${{ contains(needs.changes.outputs.libs, 'gh_actions') }}
run: |
echo "LIBS_TO_TEST=${{ toJSON(env.ALL_LIBS) }}" >> $GITHUB_ENV
- name: Set LIBS_TO_TEST to the modified libraries only
if: ${{ ! contains(needs.changes.outputs.libs, 'gh_actions') }}
run: |
echo "LIBS_TO_TEST=${{ toJSON(needs.changes.outputs.libs) }}" >> $GITHUB_ENV
- name: Set libs matrix
id: set-matrix
run: echo "matrix=${LIBS_TO_TEST}" >> $GITHUB_OUTPUT
test_libraries:
name: test library
needs: set_libs_matrix
if: ${{ needs.set_libs_matrix.outputs.libs != '[]' && needs.set_libs_matrix.outputs.libs != '' }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-22.04', 'macos-12', 'windows-2022']
lib: ${{ fromJson(needs.set_libs_matrix.outputs.libs) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install conan
uses: turtlebrowser/[email protected]
- name: create profile
run: conan profile detect
- name: add remote
run: conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: build ${{ matrix.lib }}
run: conan create libs/${{ matrix.lib }} -o boost/*:header_only=True --build=missing
- name: build ${{ matrix.lib }} tests
run: conan create -o boost/*:header_only=True libs/${{ matrix.lib }}/test --build=missing --format json > test-${{ matrix.lib }}.json
- name: run ${{ matrix.lib }} tests
shell: bash
run: |
PKGPATH=`./rootpath test-${{ matrix.lib }}.json test-${{ matrix.lib }}`
cd ${PKGPATH}/bin
./test-${{ matrix.lib }}
macos-m1:
name: test library (macos-m1)
needs: set_libs_matrix
if: ${{ needs.set_libs_matrix.outputs.libs != '[]' && needs.set_libs_matrix.outputs.libs != '' }}
runs-on: ['self-hosted', 'macOS', 'ARM64']
strategy:
fail-fast: false
matrix:
lib: ${{ fromJson(needs.set_libs_matrix.outputs.libs) }}
steps:
- uses: actions/checkout@v3
- name: Install conan
uses: turtlebrowser/[email protected]
- name: create profile
shell: bash
run: conan profile detect --force
- name: set remotes
run: conan remote add --force tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: build ${{ matrix.lib }}
run: conan create -o boost/*:header_only=True libs/${{ matrix.lib }} --build=missing
- name: build ${{ matrix.lib }} tests
run: conan create libs/${{ matrix.lib }}/test --build=missing --format json > test-${{ matrix.lib }}.json
- name: run ${{ matrix.lib }} tests
run: |
PKGPATH=`./rootpath test-${{ matrix.lib }}.json test-${{ matrix.lib }}`
cd ${PKGPATH}/bin
./test-${{ matrix.lib }}
generate_coverage:
name: Generate coverage report
needs: set_libs_matrix
if: ${{ needs.set_libs_matrix.outputs.libs != '[]' && needs.set_libs_matrix.outputs.libs != '' }}
strategy:
matrix:
lib: ${{ fromJson(needs.set_libs_matrix.outputs.libs) }}
runs-on: 'ubuntu-22.04'
steps:
- uses: actions/checkout@v3
- name: Install conan
uses: turtlebrowser/[email protected]
- name: create profile
run: conan profile detect
- name: add remote
run: conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: build ${{ matrix.lib }}
run: |
conan install libs/${{ matrix.lib }} -s build_type=Debug --build=missing -o boost/*:header_only=True -o ${{ matrix.lib }}/*:profile_coverage=True -of build/${{ matrix.lib }}
conan build libs/${{ matrix.lib }} -s build_type=Debug -o boost/*:header_only=True -o ${{ matrix.lib }}/*:profile_coverage=True -of build/${{ matrix.lib }}
conan export-pkg libs/${{ matrix.lib }} -s build_type=Debug -o boost/*:header_only=True -o ${{ matrix.lib }}/*:profile_coverage=True -of build/${{ matrix.lib }} -tf ""
- name: build ${{ matrix.lib }} tests
run: |
conan install libs/${{ matrix.lib }}/test -s build_type=Debug --build=missing -o boost/*:header_only=True -o test-${{ matrix.lib }}/*:with_coverage=True -of build/${{ matrix.lib }}-tests
conan build libs/${{ matrix.lib }}/test -s build_type=Debug --build=missing -o boost/*:header_only=True -o test-${{ matrix.lib }}/*:with_coverage=True -of build/${{ matrix.lib }}-tests
- name: run ${{ matrix.lib }} tests
working-directory: ./build/${{ matrix.lib }}-tests/build/Debug
run: ./test-${{ matrix.lib }}
- name: install gcovr
run: pip install gcovr~=6.0
- name: build coverage report
run: |
mkdir ${{ matrix.lib }}-coverage
gcovr --print-summary --html --html-details -r ${GITHUB_WORKSPACE}/libs/${{ matrix.lib }} --exclude-lines-by-pattern '.*\bTKET_ASSERT\(.*\);' --object-directory ${GITHUB_WORKSPACE}/build/${{ matrix.lib }}/build/Debug/CMakeFiles/${{ matrix.lib }}.dir/src -o ${{ matrix.lib }}-coverage/index.html --decisions > ${{ matrix.lib }}-coverage/summary.txt
cat ${{ matrix.lib }}-coverage/summary.txt
- name: upload artefact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.lib }}_coverage
path: ${{ matrix.lib }}-coverage/
- name: check coverage against latest published data from develop
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.
wget https://cqcl.github.io/tket/${{ matrix.lib }}/test-coverage/summary.txt || true
if [[ -f summary.txt ]] ; then
./.github/workflows/compare-coverage summary.txt ${{ matrix.lib }}-coverage/summary.txt
fi
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 != '' }}
strategy:
matrix:
lib: ${{ fromJson(needs.set_libs_matrix.outputs.libs) }}
concurrency: gh_pages
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
ref: gh-pages
- name: download artefact
uses: actions/download-artifact@v3
with:
name: ${{ matrix.lib }}_coverage
path: ${{ matrix.lib }}-coverage/
- name: configure git
run: |
git config --global user.email "[email protected]"
git config --global user.name "«$GITHUB_WORKFLOW» github action"
- name: pull latest
run: git pull
- name: remove old report
run: git rm -r docs/${{ matrix.lib }}/test-coverage
- name: add report to repository
run: |
mkdir -p docs/${{ matrix.lib }}
mv ${{ matrix.lib }}-coverage docs/${{ matrix.lib }}/test-coverage
git add -f docs/${{ matrix.lib }}/test-coverage
git commit --allow-empty -m "Add generated coverage report."
- name: publish report
run: git push origin gh-pages:gh-pages