|
| 1 | +name: Bazel |
| 2 | + |
| 3 | +on: [pull_request, push] |
| 4 | + |
| 5 | +concurrency: |
| 6 | + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} |
| 7 | + cancel-in-progress: true |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-windows: |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - { name: "Windows (native)", os: windows-2022, action: "test", config: "--config=windows", } |
| 16 | + - { name: "Windows (arm)", os: windows-2022, action: "build", config: "--config=windows_arm", } |
| 17 | + - { name: "Windows (roborio)", os: windows-2022, action: "build", config: "--config=roborio", } |
| 18 | + |
| 19 | + name: "Build ${{ matrix.name }}" |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + with: { fetch-depth: 0 } |
| 24 | + - uses: actions/setup-java@v4 |
| 25 | + with: |
| 26 | + distribution: 'zulu' |
| 27 | + java-version: 17 |
| 28 | + architecture: x64 |
| 29 | + |
| 30 | + - id: Setup_build_buddy |
| 31 | + uses: ./.github/actions/setup-build-buddy |
| 32 | + with: |
| 33 | + token: ${{ secrets.BUILDBUDDY_API_KEY }} |
| 34 | + |
| 35 | + - name: Build Release |
| 36 | + run: bazel --output_user_root=C:\\bazelroot ${{ matrix.action }} -k ... --config=ci -c opt ${{ matrix.config }} --verbose_failures |
| 37 | + shell: bash |
| 38 | + |
| 39 | + - name: Build Debug |
| 40 | + run: bazel --output_user_root=C:\\bazelroot ${{ matrix.action }} -k ... --config=ci -c dbg ${{ matrix.config }} --verbose_failures |
| 41 | + shell: bash |
| 42 | + |
| 43 | + build-mac: |
| 44 | + strategy: |
| 45 | + fail-fast: false |
| 46 | + matrix: |
| 47 | + include: |
| 48 | + - { name: "Mac (native)", os: macos-14, action: "test", config: "--config=macos", } |
| 49 | + - { name: "Mac (roborio)", os: macos-14, action: "build", config: "--config=roborio", } |
| 50 | + |
| 51 | + name: "${{ matrix.name }}" |
| 52 | + runs-on: ${{ matrix.os }} |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v4 |
| 55 | + with: { fetch-depth: 0 } |
| 56 | + |
| 57 | + - id: Setup_build_buddy |
| 58 | + uses: ./.github/actions/setup-build-buddy |
| 59 | + with: |
| 60 | + token: ${{ secrets.BUILDBUDDY_API_KEY }} |
| 61 | + |
| 62 | + - name: Build Release |
| 63 | + run: bazel ${{ matrix.action }} -k ... --config=ci -c opt ${{ matrix.config }} --nojava_header_compilation --verbose_failures |
| 64 | + shell: bash |
| 65 | + |
| 66 | + - name: Build Debug |
| 67 | + run: bazel ${{ matrix.action }} -k ... --config=ci -c dbg ${{ matrix.config }} --nojava_header_compilation --verbose_failures |
| 68 | + shell: bash |
| 69 | + |
| 70 | + build-linux: |
| 71 | + strategy: |
| 72 | + fail-fast: false |
| 73 | + matrix: |
| 74 | + include: |
| 75 | + - { name: "Linux (native)", os: ubuntu-22.04, action: "test", config: "--config=linux", } |
| 76 | + - { name: "Linux (roborio)", os: ubuntu-22.04, action: "build", config: "--config=roborio", } |
| 77 | + name: "${{ matrix.name }}" |
| 78 | + runs-on: ${{ matrix.os }} |
| 79 | + steps: |
| 80 | + - uses: actions/checkout@v4 |
| 81 | + with: { fetch-depth: 0 } |
| 82 | + - uses: bazelbuild/setup-bazelisk@v3 |
| 83 | + |
| 84 | + - id: Setup_build_buddy |
| 85 | + uses: ./.github/actions/setup-build-buddy |
| 86 | + with: |
| 87 | + token: ${{ secrets.BUILDBUDDY_API_KEY }} |
| 88 | + |
| 89 | + - name: Build and Test Release |
| 90 | + run: bazel ${{ matrix.action }} ... --config=ci -c opt ${{ matrix.config }} -k --verbose_failures |
| 91 | + |
| 92 | + - name: Build and Test Debug |
| 93 | + run: bazel ${{ matrix.action }} ... --config=ci -c dbg ${{ matrix.config }} -k --verbose_failures |
| 94 | + |
| 95 | + build-sanitizers: |
| 96 | + strategy: |
| 97 | + fail-fast: false |
| 98 | + matrix: |
| 99 | + include: |
| 100 | + - config: "asan" |
| 101 | + - config: "ubsan" |
| 102 | + runs-on: ubuntu-22.04 |
| 103 | + name: "Sanitizer ${{ matrix.config }}" |
| 104 | + steps: |
| 105 | + - uses: actions/checkout@v4 |
| 106 | + with: { fetch-depth: 0 } |
| 107 | + - uses: bazelbuild/setup-bazelisk@v3 |
| 108 | + |
| 109 | + - id: Setup_build_buddy |
| 110 | + uses: ./.github/actions/setup-build-buddy |
| 111 | + with: |
| 112 | + token: ${{ secrets.BUILDBUDDY_API_KEY }} |
| 113 | + |
| 114 | + - name: Build and Test |
| 115 | + run: bazel test -k --config=ci --config=linux --config=${{ matrix.config }} //... |
| 116 | + |
| 117 | + buildifier: |
| 118 | + name: "buildifier" |
| 119 | + runs-on: ubuntu-22.04 |
| 120 | + steps: |
| 121 | + - name: Set up Go 1.15.x |
| 122 | + uses: actions/setup-go@v5 |
| 123 | + with: |
| 124 | + go-version: 1.15.x |
| 125 | + id: go |
| 126 | + |
| 127 | + - name: Install Buildifier |
| 128 | + run: | |
| 129 | + cd $(mktemp -d) |
| 130 | + GO111MODULE=on go get github.com/bazelbuild/buildtools/[email protected] |
| 131 | +
|
| 132 | + - uses: actions/checkout@v4 |
| 133 | + with: { fetch-depth: 0 } |
| 134 | + |
| 135 | + - name: Run buildifier |
| 136 | + run: buildifier -warnings all --lint=fix -r . |
| 137 | + |
| 138 | + - name: Check Output |
| 139 | + run: git --no-pager diff --exit-code HEAD |
| 140 | + |
| 141 | + - name: Generate diff |
| 142 | + run: git diff HEAD > bazel-lint-fixes.patch |
| 143 | + if: ${{ failure() }} |
| 144 | + |
| 145 | + - uses: actions/upload-artifact@v4 |
| 146 | + with: |
| 147 | + name: ${{ matrix.platform }}-bazel-lint-fixes |
| 148 | + path: bazel-lint-fixes.patch |
| 149 | + if: ${{ failure() }} |
0 commit comments