adding badge status #46
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: CI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| branches: [ master ] | |
| jobs: | |
| build: | |
| runs-on: self-hosted | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ ubuntu-22.04, ubuntu-24.04 ] | |
| compiler: [ gcc-10, gcc-11, gcc-12, gcc-13, clang-14, clang-15, clang-16, clang-17, clang-18, icx] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Run build inside container | |
| run: | | |
| env | grep '^GITHUB_' > github.env | |
| podman run --env-file github.env --rm --userns=keep-id -v /var/github:/var/github ci-${{ matrix.os }} bash -c ' | |
| set -e | |
| echo "Running inside container: ${{ matrix.os }} + ${{ matrix.compiler }}" | |
| cd ${{ github.workspace }} | |
| compiler=${{ matrix.compiler }} | |
| if [[ $compiler == gcc-* ]]; then | |
| export CC=$compiler | |
| export CXX=g++-${compiler#gcc-} | |
| elif [[ $compiler == clang-* ]]; then | |
| export CC=$compiler | |
| export CXX=clang++-${compiler#clang-} | |
| elif [[ $compiler == icx ]]; then | |
| # Load Intel oneAPI environment | |
| source /opt/intel/oneapi/setvars.sh > /dev/null | |
| export CC=icx | |
| export CXX=icpx | |
| fi | |
| cmake -B build -DCMAKE_CXX_COMPILER=$CXX | |
| cmake --build build -- -j$(nproc) | |
| build/runner_test | |
| echo "||" $GITHUB_RUN_NUMBER $GITHUB_RUN_ID $GITHUB_REPOSITORY_ID "||" | |
| ' | |
| - name: Record Badge Status | |
| if: always() | |
| run: | | |
| mkdir -p badge-status | |
| cat <<EOF > badge-status/status-${{ matrix.os }}-${{ matrix.compiler }}.json | |
| { | |
| "os": "${{ matrix.os }}", | |
| "compiler": "${{ matrix.compiler }}", | |
| "status": "${{ job.status }}" | |
| } | |
| EOF | |
| - name: Upload Status Artifact | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: status-${{ matrix.os }}-${{ matrix.compiler }} | |
| path: badge-status/status-${{ matrix.os }}-${{ matrix.compiler }}.json | |
| overwrite: true | |
| generate-badges: | |
| name: Generate SVG Badges | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: always() | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Determine badge target directory | |
| id: badge_dir | |
| run: | | |
| if [[ "${GITHUB_REF##*/}" == "staging" ]]; then | |
| echo "dir=badges-staging" >> $GITHUB_OUTPUT | |
| else | |
| echo "dir=badges" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Download all badge status artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: badge-status | |
| pattern: status-* | |
| merge-multiple: true | |
| - name: Generate SVG Badges | |
| run: | | |
| mkdir -p ${{ steps.badge_dir.outputs.dir }} | |
| for f in badge-status/*.json; do | |
| echo "file name: $f" | |
| [[ ! -f "$f" ]] && continue | |
| os=$(jq -r .os "$f") | |
| compiler=$(jq -r .compiler "$f") | |
| status=$(jq -r .status "$f") | |
| color="gray" | |
| symbol="□" | |
| [[ "$status" == "success" ]] && { symbol="✔"; color="green"; } | |
| [[ "$status" == "skipped" ]] && { symbol="○"; color="gray"; } | |
| [[ "$status" == "failure" ]] && { symbol="✘"; color="red"; } | |
| label="${os}-${compiler}" | |
| badge="${{ steps.badge_dir.outputs.dir }}/${label}.svg" | |
| echo "https://img.shields.io/badge/${prefix}-${symbol}-${color}.svg $badge" | |
| curl -s "https://img.shields.io/badge/${prefix}-${symbol}-${color}.svg" -o "$badge" | |
| done | |
| - name: Upload badge folder to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./${{ steps.badge_dir.outputs.dir }} | |
| destination_dir: ${{ steps.badge_dir.outputs.dir }} | |