remove tket build dummy job #2451
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v4 | |
- uses: dorny/paths-filter@v2.11.1 | |
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', 'macos-13-xlarge'] | |
lib: ${{ fromJson(needs.set_libs_matrix.outputs.libs) }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install conan | |
uses: turtlebrowser/get-conan@v1.2 | |
- name: Set up conan | |
shell: bash | |
run: | | |
conan profile detect | |
DEFAULT_PROFILE_PATH=`conan profile path default` | |
PROFILE_PATH=./conan-profiles/${{ matrix.os }} | |
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 ${{ 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 }} | |
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@v4 | |
- 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/ubuntu-22.04 | |
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 ${{ matrix.lib }} | |
run: | | |
conan build 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 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 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@v4 | |
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 "tket-bot@cambridgequantum.com" | |
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 |