From 821d784fb9b40f500ba6a37c29137e9e9e68a6aa Mon Sep 17 00:00:00 2001 From: StellarWayne <45438363+StellarWayne@users.noreply.github.com> Date: Wed, 23 Sep 2026 17:36:48 -0700 Subject: [PATCH] ci: run Go checks on CodeBuild with S3 dependency caches --- .github/workflows/tests.yml | 74 ++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 21 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0916950..48bd527 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,26 +2,58 @@ on: [push, pull_request] name: Test jobs: - test: - strategy: - matrix: - go-version: - - 1.20.x - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - services: - redis: - image: redis - ports: - - 6379:6379 - steps: - - name: Checkout code - uses: actions/checkout@v3 + test: + strategy: + matrix: + go-version: + - 1.20.x + os: [ubuntu-latest] + runs-on: codebuild-stellaraf-actions-public-${{ github.run_id }}-${{ github.run_attempt }} + services: + redis: + image: redis + ports: + - 6379:6379 + steps: + - name: Checkout code + uses: actions/checkout@v4 - - name: Install Go - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.go-version }} + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} - - name: Test - run: go test ./... -v + cache: false + - name: Resolve Go compiler version + id: go-cache + run: | + echo "version=$(go env GOVERSION)" >> "$GITHUB_OUTPUT" + - name: Export temporary AWS cache credentials + shell: bash + run: | + python3 - <<'PYTHON' + import json, os, subprocess + credentials = json.loads(subprocess.check_output(['aws', 'configure', 'export-credentials', '--format', 'process'])) + with open(os.environ['GITHUB_ENV'], 'a') as output: + for source, target in [('AccessKeyId', 'AWS_ACCESS_KEY_ID'), ('SecretAccessKey', 'AWS_SECRET_ACCESS_KEY'), ('SessionToken', 'AWS_SESSION_TOKEN')]: + value = credentials[source] + if not value or '\n' in value or '\r' in value: + raise RuntimeError('Invalid temporary credential value') + print('::add-mask::' + value) + output.write(target + '=' + value + '\n') + PYTHON + - name: Restore Go dependencies and build cache from S3 + uses: tespkg/actions-cache@e07e2d4953dc8c020d447363e5064e36d04f3cf9 + with: + region: us-west-1 + bucket: stellaraf-public-ci-961341522852-us-west-1 + path: | + /tmp/stellar-go/pkg/mod + /tmp/stellar-go-build + key: cache/${{ github.repository }}/${{ github.ref }}/go/${{ runner.os }}/${{ runner.arch }}/${{ steps.go-cache.outputs.version }}/${{ hashFiles('**/go.sum') }} + use-fallback: false + - name: Test + run: go test ./... -v + env: + GOPATH: /tmp/stellar-go + GOCACHE: /tmp/stellar-go-build