Development #89
This file contains hidden or 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: run-code-coverage | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| paths: | |
| - ".github/workflows/coverage.yml" | |
| - "CMakeLists.txt" | |
| - "**.f90" | |
| - "**.F90" | |
| - "**.cmake" | |
| pull_request: | |
| branches: | |
| - "main" | |
| types: | |
| - opened | |
| - synchronize | |
| paths: | |
| - ".github/workflows/coverage.yml" | |
| - "CMakeLists.txt" | |
| - "**.f90" | |
| - "**.F90" | |
| - "**.cmake" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| run-code-coverage: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| compiler: [gcc] | |
| version: [13] | |
| steps: | |
| - name: checkout repo | |
| uses: actions/checkout@v4 | |
| - name: actions-setup-cmake | |
| uses: jwlawson/actions-setup-cmake@v2 | |
| with: | |
| cmake-version: '3.24.x' | |
| - uses: fortran-lang/setup-fortran@v1 | |
| id: setup-fortran | |
| with: | |
| compiler: ${{ matrix.compiler }} | |
| version: ${{ matrix.version }} | |
| - name: Install gcovr | |
| run: | | |
| pip --version | |
| pip install gcovr | |
| - name: Build project | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake make | |
| cmake --version | |
| mkdir -p build | |
| cd build | |
| cmake -DCMAKE_BUILD_TYPE=Coverage -DBUILD_PYTHON=Off -DBUILD_EXECUTABLE=Off .. | |
| make | |
| - name: Run coverage tests | |
| run: | | |
| cd build | |
| env CTEST_OUTPUT_ON_FAILURE=1 make coverage | |
| - name: Get coverage percentage | |
| run: | | |
| pip install bs4 | |
| echo "COVERAGE_PERCENTAGE="$(python ./tools/coverage_badge.py) >> $GITHUB_ENV | |
| - name: Create coverage badge | |
| uses: schneegans/dynamic-badges-action@v1.7.0 | |
| with: | |
| auth: ${{ secrets.GIST_SECRET }} | |
| gistID: 48f14ebb5636b54d3813e4b4494903eb | |
| filename: raffle_coverage_${{ github.head_ref || github.ref_name }}.json # Use branch-specific file | |
| label: Coverage | |
| message: ${{ env.COVERAGE_PERCENTAGE }}% | |
| valColorRange: ${{ env.COVERAGE_PERCENTAGE }} | |
| maxColorRange: 100 | |
| minColorRange: 0 | |
| - name: upload artifact | |
| uses: actions/upload-pages-artifact@v1 | |
| with: | |
| path: './build/coverage/' | |
| # Deploy to GitHub Pages: uniform pattern for all branches | |
| - name: deploy to Github Pages (main branch) | |
| if: ${{ github.ref == 'refs/heads/main' }} | |
| uses: actions/deploy-pages@v2 | |
| id: deployment | |
| with: | |
| path: './build/coverage/' # Use the same coverage directory | |
| - name: deploy to GitHub Pages (non-main branch) | |
| if: ${{ github.ref != 'refs/heads/main' }} | |
| uses: actions/deploy-pages@v2 | |
| with: | |
| path: './build/coverage/' # Same local coverage directory | |
| branch: gh-pages-${{ github.head_ref }} # Deploy to a branch-specific GitHub Pages branch |