|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + merge_group: |
| 8 | + pull_request: |
| 9 | + types: |
| 10 | + - opened |
| 11 | + - synchronize |
| 12 | + |
| 13 | +env: |
| 14 | + BAZEL_STARTUP_FLAGS: --bazelrc=${{ github.workspace }}/.github/github.bazelrc |
| 15 | + |
| 16 | +jobs: |
| 17 | + ci: |
| 18 | + runs-on: ${{ matrix.os }} |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - os: macos-latest |
| 23 | + - os: ubuntu-24.04 |
| 24 | + - os: ubuntu-24.04-arm |
| 25 | + - os: windows-2022 |
| 26 | + steps: |
| 27 | + # Checkout the code |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - uses: bazel-contrib/setup-bazel@0.14.0 |
| 31 | + with: |
| 32 | + bazelisk-cache: true |
| 33 | + disk-cache: ${{ github.workflow }} |
| 34 | + repository-cache: true |
| 35 | + |
| 36 | + - name: Setup Bazelrc (Windows) |
| 37 | + run: | |
| 38 | + echo "TEMP=$env:RUNNER_TEMP" >> "$env:GITHUB_ENV" |
| 39 | + echo "TMP=$env:RUNNER_TEMP" >> "$env:GITHUB_ENV" |
| 40 | + echo "startup --output_user_root=D:/bzl" > ./user.bazelrc |
| 41 | + if: startswith(runner.os, 'Windows') |
| 42 | + - name: Setup Bazelrc |
| 43 | + run: | |
| 44 | + echo "common --keep_going" >> ./user.bazelrc |
| 45 | +
|
| 46 | + # Build and Test the code |
| 47 | + - name: Test (Unix) |
| 48 | + run: bazel ${BAZEL_STARTUP_FLAGS[@]} test //... |
| 49 | + if: startswith(runner.os, 'Windows') != true |
| 50 | + - name: Test (Windows) |
| 51 | + run: bazel $env:BAZEL_STARTUP_FLAGS test //... |
| 52 | + if: startswith(runner.os, 'Windows') |
| 53 | + |
| 54 | + ci-aspects: |
| 55 | + runs-on: ${{ matrix.os }} |
| 56 | + strategy: |
| 57 | + matrix: |
| 58 | + include: |
| 59 | + - os: macos-latest |
| 60 | + - os: ubuntu-24.04 |
| 61 | + - os: ubuntu-24.04-arm |
| 62 | + - os: windows-2022 |
| 63 | + steps: |
| 64 | + # Checkout the code |
| 65 | + - uses: actions/checkout@v4 |
| 66 | + |
| 67 | + - uses: bazel-contrib/setup-bazel@0.14.0 |
| 68 | + with: |
| 69 | + bazelisk-cache: true |
| 70 | + disk-cache: ${{ github.workflow }} |
| 71 | + repository-cache: true |
| 72 | + |
| 73 | + - name: Setup Bazelrc (Windows) |
| 74 | + run: | |
| 75 | + echo "TEMP=$env:RUNNER_TEMP" >> "$env:GITHUB_ENV" |
| 76 | + echo "TMP=$env:RUNNER_TEMP" >> "$env:GITHUB_ENV" |
| 77 | + echo "startup --output_user_root=D:/bzl" > ./user.bazelrc |
| 78 | + if: startswith(runner.os, 'Windows') |
| 79 | + - name: Setup Bazelrc |
| 80 | + run: | |
| 81 | + echo "common --keep_going" >> ./user.bazelrc |
| 82 | + echo "common --config=strict" >> ./user.bazelrc |
| 83 | +
|
| 84 | + # Build and Test the code |
| 85 | + - name: Test (Unix) |
| 86 | + run: bazel ${BAZEL_STARTUP_FLAGS[@]} test //... |
| 87 | + if: startswith(runner.os, 'Windows') != true |
| 88 | + - name: Test (Windows) |
| 89 | + run: bazel $env:BAZEL_STARTUP_FLAGS test //... |
| 90 | + if: startswith(runner.os, 'Windows') |
| 91 | + |
| 92 | + ci-coverage: |
| 93 | + runs-on: ${{ matrix.os }} |
| 94 | + strategy: |
| 95 | + matrix: |
| 96 | + include: |
| 97 | + - os: macos-latest |
| 98 | + - os: ubuntu-24.04 |
| 99 | + - os: ubuntu-24.04-arm |
| 100 | + # TODO: https://github.com/bazelbuild/bazel/issues/26649 |
| 101 | + # - os: windows-2022 |
| 102 | + steps: |
| 103 | + # Checkout the code |
| 104 | + - uses: actions/checkout@v4 |
| 105 | + |
| 106 | + - uses: bazel-contrib/setup-bazel@0.14.0 |
| 107 | + with: |
| 108 | + bazelisk-cache: true |
| 109 | + disk-cache: ${{ github.workflow }} |
| 110 | + repository-cache: true |
| 111 | + |
| 112 | + - name: Setup Bazelrc (Windows) |
| 113 | + run: | |
| 114 | + echo "TEMP=$env:RUNNER_TEMP" >> "$env:GITHUB_ENV" |
| 115 | + echo "TMP=$env:RUNNER_TEMP" >> "$env:GITHUB_ENV" |
| 116 | + echo "startup --output_user_root=D:/bzl" > ./user.bazelrc |
| 117 | + if: startswith(runner.os, 'Windows') |
| 118 | + - name: Setup Bazelrc |
| 119 | + run: | |
| 120 | + echo "common --keep_going" >> ./user.bazelrc |
| 121 | +
|
| 122 | + # Build and Test the code |
| 123 | + - name: Coverage (Unix) |
| 124 | + run: bazel ${BAZEL_STARTUP_FLAGS[@]} coverage //... |
| 125 | + if: startswith(runner.os, 'Windows') != true |
| 126 | + - name: Coverage (Windows) |
| 127 | + run: bazel $env:BAZEL_STARTUP_FLAGS coverage //... |
| 128 | + if: startswith(runner.os, 'Windows') |
| 129 | + |
| 130 | + - name: Check Coverage |
| 131 | + run: python3 tools/coverage/coverage_checker.py |
| 132 | + |
| 133 | + ci-bazel-run: |
| 134 | + runs-on: ${{ matrix.os }} |
| 135 | + strategy: |
| 136 | + matrix: |
| 137 | + include: |
| 138 | + - os: macos-latest |
| 139 | + - os: ubuntu-24.04 |
| 140 | + - os: ubuntu-24.04-arm |
| 141 | + - os: windows-2022 |
| 142 | + steps: |
| 143 | + - uses: actions/checkout@v4 |
| 144 | + - uses: bazel-contrib/setup-bazel@0.14.0 |
| 145 | + with: |
| 146 | + bazelisk-cache: true |
| 147 | + disk-cache: ${{ github.workflow }} |
| 148 | + repository-cache: true |
| 149 | + |
| 150 | + - name: Test (Unix) |
| 151 | + if: startswith(runner.os, 'Windows') != true |
| 152 | + run: | |
| 153 | + bazel ${BAZEL_STARTUP_FLAGS} run //python/verilog/private/tests/bazel_free:greeter -- world --output=$(pwd)/data.txt |
| 154 | +
|
| 155 | + if [[ "$(cat data.txt)" != "Hello, world"* ]]; then |
| 156 | + cat data.txt |
| 157 | + exit 1 |
| 158 | + fi |
| 159 | + - name: Test (Windows) |
| 160 | + if: startswith(runner.os, 'Windows') |
| 161 | + run: | |
| 162 | + # Run the command and redirect output to data.txt |
| 163 | + & bazel $BAZEL_STARTUP_FLAGS run //python/verilog/private/tests/bazel_free:greeter "--" world --output=$(pwd)/data.txt |
| 164 | +
|
| 165 | + # Check if the contents of data.txt start with "Hello, world." |
| 166 | + if ((Get-Content data.txt) -notmatch "^Hello, world.*") { |
| 167 | + Get-Content data.txt |
| 168 | + exit 1 |
| 169 | + } |
| 170 | +
|
| 171 | + ci-fixers: |
| 172 | + runs-on: ${{ matrix.os }} |
| 173 | + strategy: |
| 174 | + matrix: |
| 175 | + include: |
| 176 | + - os: macos-latest |
| 177 | + - os: ubuntu-24.04 |
| 178 | + - os: ubuntu-24.04-arm |
| 179 | + - os: windows-2022 |
| 180 | + steps: |
| 181 | + # Checkout the code |
| 182 | + - uses: actions/checkout@v4 |
| 183 | + - uses: bazel-contrib/setup-bazel@0.14.0 |
| 184 | + with: |
| 185 | + bazelisk-cache: true |
| 186 | + disk-cache: ${{ github.workflow }} |
| 187 | + repository-cache: true |
| 188 | + |
| 189 | + - name: Format (unix) |
| 190 | + run: | |
| 191 | + bazel ${BAZEL_STARTUP_FLAGS[@]} run //python/black |
| 192 | + bazel ${BAZEL_STARTUP_FLAGS[@]} run //python/isort |
| 193 | + bazel ${BAZEL_STARTUP_FLAGS[@]} run //python/global_verilog |
| 194 | + if: startswith(runner.os, 'Windows') != true |
| 195 | + - name: Format (Windows) |
| 196 | + run: | |
| 197 | + bazel $env:BAZEL_STARTUP_FLAGS run //python/black |
| 198 | + bazel $env:BAZEL_STARTUP_FLAGS run //python/isort |
| 199 | + # TODO: https://github.com/periareon/rules_verilog/issues/57 |
| 200 | + # bazel $env:BAZEL_STARTUP_FLAGS run //python/global_verilog |
| 201 | + if: startswith(runner.os, 'Windows') |
| 202 | + |
| 203 | + - name: Git diff |
| 204 | + shell: bash |
| 205 | + run: | |
| 206 | + git diff |
| 207 | + if [[ -n "$(git status --porcelain)" ]]; then |
| 208 | + exit 1 |
| 209 | + fi |
| 210 | +
|
| 211 | + ci-format: |
| 212 | + runs-on: ubuntu-24.04 |
| 213 | + steps: |
| 214 | + # Checkout the code |
| 215 | + - uses: actions/checkout@v4 |
| 216 | + - uses: bazel-contrib/setup-bazel@0.14.0 |
| 217 | + with: |
| 218 | + bazelisk-cache: true |
| 219 | + disk-cache: ${{ github.workflow }} |
| 220 | + repository-cache: true |
| 221 | + |
| 222 | + - uses: DoozyX/clang-format-lint-action@v0.14 |
| 223 | + with: |
| 224 | + source: "." |
| 225 | + extensions: "h,c,cc" |
| 226 | + clangFormatVersion: 14 |
| 227 | + |
| 228 | + - name: Format (unix) |
| 229 | + run: | |
| 230 | + bazel ${BAZEL_STARTUP_FLAGS[@]} run //:buildifier_check |
| 231 | +
|
| 232 | + - name: Git diff |
| 233 | + shell: bash |
| 234 | + run: | |
| 235 | + git diff |
| 236 | + if [[ -n "$(git status --porcelain)" ]]; then |
| 237 | + exit 1 |
| 238 | + fi |
0 commit comments