Skip to content

merge: Merge pull request #10 from DigitalHolography/feat/sliding-ave… #8

merge: Merge pull request #10 from DigitalHolography/feat/sliding-ave…

merge: Merge pull request #10 from DigitalHolography/feat/sliding-ave… #8

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
classify:
name: Classify Pull Request
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
package: ${{ steps.changes.outputs.package }}
steps:
- name: Check out source
uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
- name: Detect packaging changes
id: changes
shell: bash
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
package=false
while IFS= read -r path; do
case "$path" in
CMakeLists.txt|*/CMakeLists.txt|CMakePresets.json|\
cmake/*|external/*|resources/*|\
src/holovibes/src/resources.qrc|\
VERSION|LICENSE|README.md|\
tools/validate_windows_package.ps1|\
.github/workflows/testing.yml|\
.github/workflows/verify.yml|\
.github/workflows/release.yml)
package=true
break
;;
esac
done < <(git diff --name-only "$BASE_SHA" "$HEAD_SHA")
echo "package=$package" >> "$GITHUB_OUTPUT"
echo "Package verification required: $package"
workflow-lint:
name: Workflow Syntax
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out source
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: stable
cache: false
- name: Validate workflows
run: go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.12 -color
documentation:
name: Documentation
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Check out source
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Install documentation dependencies
run: >
python -m pip install
mkdocs==1.6.1
mkdocs-get-deps==0.2.0
mkdocs-material==9.6.21
mkdocs-material-extensions==1.3.1
mkdocs-mermaid2-plugin==1.2.2
mkdocs-simple-hooks==0.1.5
- name: Build documentation
working-directory: doc/mkdocs
run: mkdocs build --clean
- name: Stage documentation for GitHub Pages
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v7
with:
name: documentation-pages
path: doc/mkdocs/site
if-no-files-found: error
retention-days: 1
release-tests:
name: Windows Release Tests
if: >-
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
needs: classify
runs-on: [self-hosted, windows, x64]
timeout-minutes: 180
steps:
- name: Check out source
uses: actions/checkout@v7
with:
submodules: recursive
fetch-depth: 0
persist-credentials: false
- name: Preflight toolchain
shell: pwsh
run: |
cmake --version
nvcc --version
nvidia-smi
python --version
python -c "import numpy; print(numpy.__version__)"
- name: Configure
run: >
cmake --preset msvc-multi
-DFETCHCONTENT_BASE_DIR=C:/.fc
-DENABLE_BENCHMARKS=OFF
-DENABLE_DOCUMENTATION=OFF
-DENABLE_EXAMPLES=OFF
- name: Build
run: cmake --build --preset build-Release -j
- name: Test
shell: pwsh
run: |
New-Item -ItemType Directory -Force build/test-results | Out-Null
ctest --preset test-Release --output-junit build/test-results/release.junit.xml
- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
with:
name: release-test-results-${{ github.sha }}
path: |
build/test-results
build/msvc-multi/Testing/Temporary
retention-days: 30
- name: Stage install
if: needs.classify.outputs.package == 'true'
shell: pwsh
run: |
$stage = Join-Path $env:GITHUB_WORKSPACE "build/stage"
cmake --install build/msvc-multi --config Release --prefix $stage --component binaries
cmake --install build/msvc-multi --config Release --prefix $stage --component dependencies
- name: Validate staged runtime
if: needs.classify.outputs.package == 'true'
run: >
pwsh -NoProfile -File tools/validate_windows_package.ps1
-StageDirectory build/stage
- name: Package
if: needs.classify.outputs.package == 'true'
run: cmake --build --preset build-Release --target package -j
coverage:
name: Windows Native Coverage
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
runs-on: [self-hosted, windows, x64]
timeout-minutes: 180
steps:
- name: Check out source
uses: actions/checkout@v7
with:
submodules: recursive
fetch-depth: 0
persist-credentials: false
- name: Preflight coverage toolchain
shell: pwsh
run: |
nvidia-smi
python -c "import numpy; print(numpy.__version__)"
Microsoft.CodeCoverage.Console --version
dotnet --version
- name: Configure coverage build
run: >
cmake --preset msvc-coverage
-DFETCHCONTENT_BASE_DIR=C:/.fc
- name: Build coverage configuration
run: cmake --build --preset build-Coverage -j
- name: Collect and render coverage
run: pwsh -NoProfile -File tools/run_coverage.ps1
- name: Stage coverage for GitHub Pages
uses: actions/upload-artifact@v7
with:
name: coverage-pages
path: build/coverage/html
if-no-files-found: error
retention-days: 1
publish-pages:
name: Publish Documentation and Coverage
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
needs: [documentation, coverage]
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write
steps:
- name: Check out trusted source
uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: true
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Install publication dependency
run: python -m pip install ghp-import==2.1.0
- name: Download documentation
uses: actions/download-artifact@v8
with:
name: documentation-pages
path: doc/mkdocs/site
- name: Add coverage report
uses: actions/download-artifact@v8
with:
name: coverage-pages
path: doc/mkdocs/site/coverage
- name: Publish combined site
working-directory: doc/mkdocs
run: >
ghp-import --no-jekyll --push --force
--message "docs: publish ${{ github.sha }}"
site
pr-gate:
name: PR Gate
if: always() && github.event_name == 'pull_request'
needs: [classify, workflow-lint, documentation, release-tests]
runs-on: ubuntu-latest
timeout-minutes: 5
permissions: {}
steps:
- name: Enforce pull request policy
shell: bash
env:
BASE_REPOSITORY: ${{ github.repository }}
HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
CLASSIFY_RESULT: ${{ needs.classify.result }}
WORKFLOW_LINT_RESULT: ${{ needs.workflow-lint.result }}
DOCUMENTATION_RESULT: ${{ needs.documentation.result }}
RELEASE_TESTS_RESULT: ${{ needs.release-tests.result }}
run: |
set -euo pipefail
if [[ "$HEAD_REPOSITORY" != "$BASE_REPOSITORY" ]]; then
echo "::error::Fork pull requests cannot use the self-hosted CI runner. Move trusted commits to a branch in $BASE_REPOSITORY."
exit 1
fi
for result in \
"$CLASSIFY_RESULT" \
"$WORKFLOW_LINT_RESULT" \
"$DOCUMENTATION_RESULT" \
"$RELEASE_TESTS_RESULT"; do
if [[ "$result" != "success" ]]; then
echo "::error::A required pull request job did not succeed."
exit 1
fi
done
echo "All required pull request checks succeeded."