|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + # Triggers the workflow on push or pull request events but only for the "main" branch |
| 5 | + push: |
| 6 | + branches: [ "main" ] |
| 7 | + pull_request: |
| 8 | + branches: [ "main" ] |
| 9 | + |
| 10 | + # Allows you to run this workflow manually from the Actions tab |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + services: |
| 17 | + bazel-remote: |
| 18 | + image: buchgr/bazel-remote-cache:v1.3.4 |
| 19 | + ports: |
| 20 | + - 9092:9092 |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Set up Go |
| 27 | + uses: actions/setup-go@v5 |
| 28 | + with: |
| 29 | + go-version-file: go.mod |
| 30 | + |
| 31 | + - name: Build CLI |
| 32 | + run: mkdir -p bin && go build -o bin/tbc . |
| 33 | + |
| 34 | + - name: Upload CLI |
| 35 | + uses: actions/upload-artifact@v4 |
| 36 | + with: |
| 37 | + name: tbc |
| 38 | + path: bin/tbc |
| 39 | + |
| 40 | + - name: golangci-lint |
| 41 | + uses: golangci/golangci-lint-action@v6 |
| 42 | + with: |
| 43 | + version: v1.59.1 |
| 44 | + |
| 45 | + - name: Run tests |
| 46 | + run: go test ./... |
| 47 | + |
| 48 | + - name: Run integration tests |
| 49 | + run: go test ./client -remote-cache-host localhost:9092 |
| 50 | + |
| 51 | + ############################################################################ |
| 52 | + |
| 53 | + end2end: |
| 54 | + runs-on: ubuntu-latest |
| 55 | + needs: build |
| 56 | + |
| 57 | + services: |
| 58 | + bazel-remote: |
| 59 | + image: buchgr/bazel-remote-cache:v1.3.4 |
| 60 | + ports: |
| 61 | + - 9092:9092 |
| 62 | + |
| 63 | + env: |
| 64 | + # This is required by turbo with "remoteCache": { "signature": true } |
| 65 | + # tbc --auto-env does not set this variable. |
| 66 | + TURBO_REMOTE_CACHE_SIGNATURE_KEY: super_secret |
| 67 | + TURBO_TELEMETRY_DISABLED: 1 |
| 68 | + TBC_SUMMARY: true |
| 69 | + TBC_HOST: localhost:9092 |
| 70 | + |
| 71 | + steps: |
| 72 | + - name: Checkout code |
| 73 | + uses: actions/checkout@v4 |
| 74 | + with: |
| 75 | + sparse-checkout: | |
| 76 | + .github |
| 77 | + end2end |
| 78 | +
|
| 79 | + - name: Install pnpm |
| 80 | + uses: pnpm/action-setup@v4 |
| 81 | + with: |
| 82 | + run_install: false |
| 83 | + package_json_file: end2end/monorepo/package.json |
| 84 | + |
| 85 | + - name: Set up Node |
| 86 | + uses: actions/setup-node@v4 |
| 87 | + with: |
| 88 | + node-version-file: end2end/.tool-versions |
| 89 | + cache: 'pnpm' |
| 90 | + cache-dependency-path: end2end/monorepo/pnpm-lock.yaml |
| 91 | + |
| 92 | + - name: Install dependencies |
| 93 | + run: pnpm -C end2end/monorepo install |
| 94 | + |
| 95 | + - name: Grab tbc |
| 96 | + uses: actions/download-artifact@v4 |
| 97 | + with: |
| 98 | + name: tbc |
| 99 | + |
| 100 | + - name: Restore exec bit for tbc |
| 101 | + run: chmod +x $GITHUB_WORKSPACE/tbc |
| 102 | + |
| 103 | + - name: Build monorepo for the first time |
| 104 | + run: > |
| 105 | + cd end2end/monorepo && |
| 106 | + $GITHUB_WORKSPACE/tbc pnpm build 2>&1 | tee $GITHUB_WORKSPACE/first_build.log |
| 107 | +
|
| 108 | + - name: Check that cache worked correctly |
| 109 | + run: grep -q "server stats uploads=2 downloads_not_found=2" first_build.log |
| 110 | + |
| 111 | + - name: Wipe local cache |
| 112 | + run: pnpm -C end2end/monorepo wipe |
| 113 | + |
| 114 | + - name: Build monorepo for the second time to check that artifacts were taken from the remote cache |
| 115 | + run: > |
| 116 | + cd end2end/monorepo && |
| 117 | + $GITHUB_WORKSPACE/tbc pnpm build 2>&1 | tee $GITHUB_WORKSPACE/second_build.log |
| 118 | +
|
| 119 | + - name: Check that cache worked correctly for the second time |
| 120 | + run: > |
| 121 | + grep -q "FULL TURBO" second_build.log && |
| 122 | + grep -q "server stats downloads=2" second_build.log |
| 123 | +
|
| 124 | + - name: Check the --ignore-failures mode (invalid cache host) |
| 125 | + env: |
| 126 | + TBC_HOST: example.org:9093 # invalid |
| 127 | + TBC_IGNORE_FAILURES: true |
| 128 | + run: > |
| 129 | + cd end2end/monorepo && |
| 130 | + $GITHUB_WORKSPACE/tbc pnpm build 2>&1 | tee $GITHUB_WORKSPACE/third_build.log |
| 131 | +
|
| 132 | + - name: Check the log |
| 133 | + run: > |
| 134 | + grep -q "FULL TURBO" third_build.log && |
| 135 | + grep -q "cache proxy failed, just running the command" third_build.log |
0 commit comments