Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/.github/workflows/ci.yml
blob: 78406079e3a348652b0e99f22d6bf8d00396cefd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# SPDX-FileCopyrightText: 2026 Progmasoft <[email protected]>
# SPDX-License-Identifier: MIT

name: CI

on:
  push:
    branches: [main]
  pull_request:

permissions:
  contents: read

concurrency:
  group: tazelish-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    name: Test (${{ matrix.os }})
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-24.04, macos-15, windows-2025]
    runs-on: ${{ matrix.os }}
    timeout-minutes: 45
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      # The hosted Windows image carries LLVM, whose clang-cl the Bazel
      # configuration uses.
      - if: runner.os == 'Windows'
        shell: pwsh
        run: '"BAZEL_LLVM=C:\Program Files\LLVM" | Out-File -FilePath $env:GITHUB_ENV -Append'
      # Pushes to the default branch write to the Progmasoft remote cache and
      # pull requests only read it; a pull request from a fork gets no secrets
      # and builds without it.
      - name: Use the Progmasoft remote cache
        shell: bash
        env:
          WRITES: ${{ github.event_name == 'push' && github.ref_name == github.event.repository.default_branch }}
          CACHE_READ: ${{ secrets.BAZEL_CACHE_READ }}
          CACHE_WRITE: ${{ github.event_name == 'push' && github.ref_name == github.event.repository.default_branch && secrets.BAZEL_CACHE_WRITE || '' }}
        run: |
          auth=$([ "$WRITES" = true ] && echo "$CACHE_WRITE" || echo "$CACHE_READ")
          if [ -z "$auth" ]; then
            echo "No cache credentials: building without the remote cache."
            exit 0
          fi
          {
            echo "common --remote_cache=https://remotecache.progmasoft.com"
            echo "common --remote_header=\"Authorization=Basic $auth\""
            [ "$WRITES" = true ] || echo "common --remote_upload_local_results=false"
          } >> "$HOME/.bazelrc"

      - run: bazelisk test //...
      - run: bazelisk build //:tazelish

  coverage-report:
    name: Coverage report
    runs-on: ubuntu-24.04
    timeout-minutes: 45
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      # Clang's own coverage, read by the LLVM tools of the runner's Clang.
      - run: >-
          bazelisk coverage //Tests:tests
          --combined_report=lcov
          --instrumentation_filter=^//:
          --repo_env=BAZEL_USE_LLVM_NATIVE_COVERAGE=1
          --repo_env=BAZEL_LLVM_PROFDATA=/usr/bin/llvm-profdata-18
          --repo_env=BAZEL_LLVM_COV=/usr/bin/llvm-cov-18
      - run: cp "$(bazelisk info output_path)/_coverage/_coverage_report.dat" lcov.info
      - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: tazelish-coverage
          path: lcov.info
          if-no-files-found: error
          retention-days: 1

  coverage:
    # Fork PRs cannot receive the OIDC token required for Codecov uploads.
    if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
    needs: coverage-report
    runs-on: ubuntu-24.04
    timeout-minutes: 10
    permissions:
      contents: read
      id-token: write
    steps:
      # Keep the OIDC-capable job apart from the build.
      - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
        with:
          name: tazelish-coverage
      - uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
        with:
          use_oidc: true
          files: lcov.info
          fail_ci_if_error: true

  doxygen:
    name: Doxygen
    runs-on: ubuntu-24.04
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - name: Install Doxygen
        run: |
          sudo apt-get update
          sudo apt-get install --yes --no-install-recommends doxygen

      # Every warning fails, an undocumented declaration included.
      - name: Build the reference of the headers
        run: doxygen Doxyfile

      - name: Keep the reference
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: tazelish-doxygen
          path: doxygen/html/
          if-no-files-found: error
          retention-days: 7

  required:
    name: CI Required
    if: always()
    needs: [test, doxygen]
    runs-on: ubuntu-24.04
    timeout-minutes: 5
    steps:
      - env:
          RESULTS: ${{ needs.test.result }} ${{ needs.doxygen.result }}
        run: test "$RESULTS" = "success success"