ci: refine checks and pages deploy #317
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: CI | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
- beta | |
- alpha | |
- +([0-9])?(.{+([0-9]),x}).x | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- uses: pre-commit/action@v3.0.1 | |
with: | |
extra_args: --hook-stage manual --all-files | |
consistency: | |
if: ${{ !cancelled() && ! failure() }} | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Git | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
- name: Install copier for template rendering using pipx | |
run: pipx install copier | |
- name: Generate the project with the default value | |
run: | | |
find . -maxdepth 1 ! -name '.' \ | |
! -name 'template' \ | |
! -name 'includes' \ | |
! -name '.git' \ | |
! -name 'copier.yml' \ | |
! -name 'CHANGELOG.md' \ | |
-exec rm -r {} + | |
copier copy -r HEAD -f . . | |
rm .copier-answers.yml | |
- name: Test for consistency | |
run: | | |
echo "List inconsistent files:" | |
git status --porcelain | |
git diff --exit-code || ( \ | |
echo "# :warning: Inconsistent files found" >> $GITHUB_STEP_SUMMARY && \ | |
echo "The following files are inconsistent with the template:" >> $GITHUB_STEP_SUMMARY && \ | |
git status --porcelain | while read file; do echo "- $file"; done >> $GITHUB_STEP_SUMMARY && \ | |
echo "" >> $GITHUB_STEP_SUMMARY && \ | |
echo "Please run 'copier copy -r HEAD -f . .' to fix them." >>$GITHUB_STEP_SUMMARY && \ | |
exit 1 \ | |
) | |
checks: | |
runs-on: ${{ matrix.presets.os.name }} | |
timeout-minutes: 15 | |
permissions: | |
actions: read | |
contents: read | |
security-events: write | |
strategy: | |
fail-fast: false | |
matrix: | |
presets: | |
- {os: {name: ubuntu-latest, type: linux}, compiler: {name: gcc-11, type: gcc}} | |
- {os: {name: ubuntu-latest, type: linux}, compiler: {name: llvm, type: llvm}} | |
- {os: {name: ubuntu-latest, type: mingw-dynamic-linux}, compiler: {name: mingw, type: mingw}} | |
- {os: {name: macos-latest, type: osx}, compiler: {name: applellvm, type: llvm}} | |
- {os: {name: macos-latest, type: osx}, compiler: {name: llvm, type: llvm}} | |
# setup-cpp doesn't support mingw on macOS yet | |
# - {os: {name: macos-latest, type: mingw-dynamic-darwin}, compiler: {name: mingw, type: mingw}} | |
- {os: {name: windows-latest, type: windows}, compiler: {name: msvc, type: msvc}} | |
- {os: {name: windows-latest, type: windows}, compiler: {name: llvm, type: llvm}} | |
- {os: {name: windows-latest, type: mingw-dynamic-windows}, compiler: {name: mingw, type: mingw}} | |
arch: | |
- {name: x64, type: x64} | |
vcpkg: | |
- true | |
- false | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/vcpkg | |
~/.cache/pip | |
~/.cache/vcpkg | |
~/AppData/Local/vcpkg | |
key: | | |
${{ matrix.arch.name }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}-${{ hashFiles('./vcpkg.json') }}-${{ matrix.vcpkg }} | |
restore-keys: | | |
${{ matrix.arch.name }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}-${{ hashFiles('./vcpkg.json') }}- | |
- uses: aminya/setup-cpp@v1 | |
with: | |
compiler: ${{ matrix.presets.compiler.name }} | |
vcvarsall: ${{ contains(matrix.presets.os.type, 'windows' )}} | |
cmake: true | |
ninja: true | |
vcpkg: ${{ matrix.vcpkg }} | |
ccache: true | |
python: true | |
opencppcoverage: ${{ contains(matrix.presets.os.type, 'windows' )}} | |
- name: Lcov for coverage | |
if: contains(matrix.presets.compiler.type, 'gcc') && contains(matrix.presets.os.type, 'linux') | |
run: | | |
sudo apt-get update | |
sudo apt-get install lcov | |
- name: Gcovr for coverage | |
if: contains(matrix.presets.compiler.type, 'mingw') && contains(matrix.presets.os.type, 'mingw') | |
run: | | |
pip install gcovr | |
- name: Target Windows on Linux (Mingw-w64) | |
if: contains(matrix.presets.compiler.type, 'mingw') && contains(matrix.presets.os.type, 'linux') | |
run: | | |
sudo apt-get update && sudo apt-get install mingw-w64 wine wine64 powershell | |
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix | |
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix | |
wine64 true || true | |
echo "wait 10s for wine registry to be created" && sleep 10 | |
sed -i '/"PATH"/ s|"$|;Z:/usr/lib/gcc/x86_64-w64-mingw32/10-posix;Z:/usr/x86_64-w64-mingw32/lib"|g' ~/.wine/system.reg && echo "wine registry updated" | |
- name: Configure CMake | |
run: | | |
cmake -S . --preset=${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }} -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=ON -DBUILD_TESTING=ON ${{ matrix.presets.os.type == 'linux' && '-DUSE_SANITIZER=OFF' || '' }} | |
- name: Build | |
run: | | |
cmake --build out/build/${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }} --target all | |
- name: Coverage | |
run: | | |
cmake --build out/build/${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }} --target ccov-all | |
- name: Upload coverage report | |
uses: codecov/codecov-action@v4.1.0 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: out/build/${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }}/code_coverage/coverage.xml | |
flags: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}-${{ matrix.presets.compiler.type }}-${{ matrix.vcpkg }} | |
name: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}-${{ matrix.presets.compiler.type }}-${{ matrix.vcpkg }}-coverage | |
pass: | |
if: always() | |
needs: [pre-commit, consistency, checks] | |
runs-on: ubuntu-latest | |
timeout-minutes: 2 | |
steps: | |
- name: Decide whether the needed jobs succeeded or failed | |
uses: re-actors/alls-green@release/v1 | |
with: | |
jobs: ${{ toJSON(needs) }} | |
release: | |
name: release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
needs: [pass] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Semantic Release | |
uses: cycjimmy/semantic-release-action@v4 | |
id: semantic | |
with: | |
semantic_version: 22.0.5 | |
branches: | | |
[ | |
'+([0-9])?(.{+([0-9]),x}).x', | |
'master', | |
'main', | |
'next', | |
'next-major', | |
{ | |
name: 'beta', | |
prerelease: true | |
}, | |
{ | |
name: 'alpha', | |
prerelease: true | |
} | |
] | |
extra_plugins: | | |
@semantic-release/changelog | |
@semantic-release/git | |
@semantic-release/exec | |
@semantic-release/github | |
conventional-changelog-conventionalcommits | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |