Skip to content

Commit

Permalink
🚸 Make reusable workflows more generic (#407)
Browse files Browse the repository at this point in the history
## Description

This PR tries to make the reusable workflows from the repository truly
reusable in our top-level projects; at least in the top-priority ones.
This includes:
- passing additional CMake arguments to the configure calls
- potentially setting up Z3
- running mypy in GitHub CI instead of pre-commit.ci (frequently runs
out of memory if you add to many dependencies to the mypy job)
- eliminates the need for a CodeQL configuration file
- adding retry jobs on coverage uploads
- a minimal versions Python test with coverage that makes sure
everything works with all the lower caps
- automatically setting the `DEPLOY` CMake variable in CI systems

## Checklist:

<!---
This checklist serves as a reminder of a couple of things that ensure
your pull request will be merged swiftly.
-->

- [x] The pull request only contains commits that are related to it.
- [x] I have added appropriate tests and documentation.
- [x] I have made sure that all CI jobs on GitHub pass.
- [x] The pull request introduces no new warnings and follows the
project's style guidelines.
  • Loading branch information
burgholzer authored Aug 28, 2023
2 parents e75a2f8 + 89dc202 commit 226315a
Show file tree
Hide file tree
Showing 29 changed files with 560 additions and 98 deletions.
2 changes: 0 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ linux_aarch64_wheels_task:
architecture: arm64
platform: linux
cpu: 8
env:
CIBW_SKIP: "*-musllinux_*"
setup_pyhton_script:
- apt-get install -y python3-venv python-is-python3
<<: *BUILD_AND_STORE_WHEELS
Expand Down
6 changes: 2 additions & 4 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
ignore:
- "extern/**/*"
- "include/python/**/*"
- "src/python/**/*"
- "**/python"
- "test/**/*"

coverage:
Expand All @@ -27,12 +26,11 @@ flag_management:
paths:
- "include"
- "src"
- "!src/mqt/**/*"
after_n_builds: 1
- name: python
paths:
- "src/mqt/**/*.py"
after_n_builds: 2
after_n_builds: 3
statuses:
- type: project
threshold: 0.5%
Expand Down
4 changes: 0 additions & 4 deletions .github/codeql-config.yml

This file was deleted.

21 changes: 20 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,35 @@ version: 2
updates:
- package-ecosystem: "gitsubmodule"
directory: "/"
groups:
submodules:
patterns:
- "*"
schedule:
interval: "monthly"
day: "wednesday"
time: "06:00"
timezone: "Europe/Vienna"

- package-ecosystem: "github-actions"
directory: "/"
groups:
github-actions:
patterns:
- "*"
schedule:
interval: "weekly"
day: "wednesday"
time: "06:00"
timezone: "Europe/Vienna"

- package-ecosystem: "pip"
directory: "/"
groups:
python-dependencies:
patterns:
- "*"
schedule:
interval: "weekly"
day: "friday"
time: "06:00"
timezone: "Europe/Vienna"
4 changes: 2 additions & 2 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 📝 • Release Drafter
name: Release Drafter

on:
push:
Expand All @@ -20,4 +20,4 @@ jobs:
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
3 changes: 3 additions & 0 deletions .github/workflows/reusable-change-detection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ jobs:
!test/python/**
.clang-tidy
.github/workflows/reusable-cpp-linter.yml
.github/workflows/ci.yml
- name: Set a flag for running the C++ linter
if: >-
github.event_name != 'pull_request'
Expand All @@ -98,6 +99,7 @@ jobs:
.github/workflows/reusable-python-tests.yml
.github/workflows/reusable-python-coverage.yml
.github/workflows/reusable-python-ci.yml
.github/workflows/ci.yml
- name: Set a flag for running the Python tests
if: >-
github.event_name != 'pull_request'
Expand All @@ -122,6 +124,7 @@ jobs:
.github/workflows/reusable-code-ql-cpp.yml
.github/workflows/reusable-code-ql-python.yml
.github/workflows/reusable-code-ql.yml
.github/workflows/ci.yml
- name: Set a flag for running CodeQL
if: >-
github.event_name != 'pull_request'
Expand Down
25 changes: 24 additions & 1 deletion .github/workflows/reusable-code-ql-cpp.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
name: 📝 • CodeQL • C++
on:
workflow_call:
inputs:
cmake-args:
description: "Additional arguments to pass to CMake"
default: ""
type: string
setup-z3:
description: "Whether to set up Z3"
default: false
type: boolean
z3-version:
description: "The version of Z3 to set up"
default: "4.11.2"
type: string

jobs:
analyze:
Expand All @@ -16,6 +29,13 @@ jobs:
with:
submodules: recursive
fetch-depth: 0
- if: ${{ inputs.setup-z3 }}
name: Setup Z3
uses: cda-tum/setup-z3@v1
with:
version: ${{ inputs.z3-version }}
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
Expand All @@ -29,8 +49,11 @@ jobs:
languages: cpp
config-file: .github/codeql-config.yml
setup-python-dependencies: false
config: |
queries:
- uses: security-and-quality
- name: Configure CMake
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug ${{ inputs.cmake-args }}
- name: Build
run: cmake --build build
- name: Perform CodeQL Analysis
Expand Down
27 changes: 25 additions & 2 deletions .github/workflows/reusable-code-ql-python.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
name: 📝 • CodeQL • Python
on:
workflow_call:
inputs:
setup-z3:
description: "Whether to set up Z3"
default: false
type: boolean
z3-version:
description: "The version of Z3 to set up"
default: "4.11.2"
type: string
build-time-dependencies:
description: "The build-time dependencies to install"
default: "nanobind scikit-build-core[pyproject] setuptools_scm pybind11"
type: string

jobs:
analyze:
Expand All @@ -16,6 +29,13 @@ jobs:
with:
submodules: recursive
fetch-depth: 0
- if: ${{ inputs.setup-z3 }}
name: Setup Z3
uses: cda-tum/setup-z3@v1
with:
version: ${{ inputs.z3-version }}
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
Expand All @@ -30,8 +50,8 @@ jobs:
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install nanobind scikit-build-core[pyproject] setuptools_scm pybind11
python -m pip install --upgrade pip wheel setuptools
pip install ${{ inputs.build-time-dependencies }}
pip install --no-build-isolation -ve .
echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV
- name: Initialize CodeQL
Expand All @@ -40,6 +60,9 @@ jobs:
languages: python
config-file: .github/codeql-config.yml
setup-python-dependencies: false
config: |
queries:
- uses: security-and-quality
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/reusable-code-ql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,47 @@ name: 📝 • CodeQL

on:
workflow_call:
inputs:
cmake-args:
description: "Additional arguments to pass to CMake"
default: ""
type: string
setup-z3:
description: "Whether to set up Z3"
default: false
type: boolean
z3-version:
description: "The version of Z3 to set up"
default: "4.11.2"
type: string
build-time-dependencies:
description: "The build-time dependencies to install"
default: "nanobind scikit-build-core[pyproject] setuptools_scm pybind11"
type: string
enable-cpp:
description: "Whether to enable C++ analysis"
default: true
type: boolean
enable-python:
description: "Whether to enable Python analysis"
default: true
type: boolean

jobs:
analyze-cpp:
if: ${{ inputs.enable-cpp }}
name: 🇨‌
uses: ./.github/workflows/reusable-code-ql-cpp.yml
with:
cmake-args: ${{ inputs.cmake-args }}
setup-z3: ${{ inputs.setup-z3 }}
z3-version: ${{ inputs.z3-version }}

analyze-python:
if: ${{ inputs.enable-python }}
name: 🐍
uses: ./.github/workflows/reusable-code-ql-python.yml
with:
setup-z3: ${{ inputs.setup-z3 }}
z3-version: ${{ inputs.z3-version }}
build-time-dependencies: ${{ inputs.build-time-dependencies }}
38 changes: 38 additions & 0 deletions .github/workflows/reusable-cpp-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ on:
token:
description: "The token to use for Codecov"
required: true
inputs:
cmake-args:
description: "Additional arguments to pass to CMake on every OS"
default: "-G Ninja"
type: string
cmake-args-ubuntu:
description: "Additional arguments to pass to CMake on Ubuntu"
default: ""
type: string
cmake-args-macos:
description: "Additional arguments to pass to CMake on macOS"
default: ""
type: string
cmake-args-windows:
description: "Additional arguments to pass to CMake on Windows"
default: ""
type: string
setup-z3:
description: "Whether to set up Z3"
default: false
type: boolean
z3-version:
description: "The version of Z3 to set up"
default: "4.11.2"
type: string

jobs:
cpp-tests-ubuntu:
Expand All @@ -16,6 +41,9 @@ jobs:
uses: ./.github/workflows/reusable-cpp-tests-ubuntu.yml
with:
config: ${{ matrix.config }}
cmake-args: ${{ inputs.cmake-args }} ${{ inputs.cmake-args-ubuntu }}
setup-z3: ${{ inputs.setup-z3 }}
z3-version: ${{ inputs.z3-version }}

cpp-tests-macos:
name: 🍎 ${{ matrix.config }}
Expand All @@ -26,6 +54,9 @@ jobs:
uses: ./.github/workflows/reusable-cpp-tests-macos.yml
with:
config: ${{ matrix.config }}
cmake-args: ${{ inputs.cmake-args }} ${{ inputs.cmake-args-macos }}
setup-z3: ${{ inputs.setup-z3 }}
z3-version: ${{ inputs.z3-version }}

cpp-tests-windows:
name: 🏁 ${{ matrix.config }}
Expand All @@ -36,9 +67,16 @@ jobs:
uses: ./.github/workflows/reusable-cpp-tests-windows.yml
with:
config: ${{ matrix.config }}
cmake-args: ${{ inputs.cmake-args }} ${{ inputs.cmake-args-windows }}
setup-z3: ${{ inputs.setup-z3 }}
z3-version: ${{ inputs.z3-version }}

coverage:
name: 📈
uses: ./.github/workflows/reusable-cpp-coverage.yml
secrets:
token: ${{ secrets.token }}
with:
cmake-args: ${{ inputs.cmake-args }} ${{ inputs.cmake-args-ubuntu }}
setup-z3: ${{ inputs.setup-z3 }}
z3-version: ${{ inputs.z3-version }}
43 changes: 35 additions & 8 deletions .github/workflows/reusable-cpp-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ on:
token:
description: "The token to use for Codecov"
required: true
inputs:
cmake-args:
description: "Additional arguments to pass to CMake"
default: "-G Ninja"
type: string
setup-z3:
description: "Whether to set up Z3"
default: false
type: boolean
z3-version:
description: "The version of Z3 to set up"
default: "4.11.2"
type: string

jobs:
coverage:
Expand All @@ -18,24 +31,38 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: recursive
- if: ${{ inputs.setup-z3 }}
name: Setup Z3
uses: cda-tum/setup-z3@v1
with:
version: ${{ inputs.z3-version }}
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
prepend_symlinks_to_path: false
override_cache_key: c++-coverage
- name: Set up mold as linker
uses: rui314/setup-mold@v1
- name: Install Ninja
run: pipx install ninja
- name: Configure CMake
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON -DDEPLOY=ON
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON ${{ inputs.cmake-args }}
- name: Build
run: cmake --build build --config Debug
- name: Test
run: ctest -C Debug --output-on-failure --test-dir build --repeat until-pass:3 --timeout 300
run: ctest -C Debug --output-on-failure --test-dir build --repeat until-pass:3 --timeout 600
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
# Coverage uploads can be flaky, so we retry them a few times.
uses: Wandalen/wretry.action@v1.3.0
with:
fail_ci_if_error: true
flags: cpp
gcov: true
gcov_ignore: "extern/**/*"
token: ${{ secrets.token }}
action: codecov/codecov-action@v3
attempt_limit: 5
attempt_delay: 2000
with: |
fail_ci_if_error: true
flags: cpp
gcov: true
gcov_ignore: "extern/**/*"
token: ${{ secrets.token }}
Loading

0 comments on commit 226315a

Please sign in to comment.