All checks were successful
Go CI with S3 Caching / build-and-test (push) Successful in 1m22s
59 lines
1.6 KiB
YAML
59 lines
1.6 KiB
YAML
name: Go CI with S3 Caching
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Add SSH known host
|
|
run: |
|
|
install -m 700 -d "$HOME/.ssh"
|
|
ssh-keyscan -H git.ericxliu.me > $HOME/.ssh/known_hosts
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ssh-key: ${{ secrets.SSH_KEY }}
|
|
|
|
- name: Setup Go + S3 Caching
|
|
uses: ./.gitea/actions/go-cache
|
|
with:
|
|
go-version: '1.24'
|
|
s3-bucket: sccache
|
|
s3-endpoint: https://s3.ericxliu.me
|
|
s3-path-style: "true"
|
|
env:
|
|
SCCACHE_AWS_ACCESS_KEY_ID: ${{ secrets.SCCACHE_AWS_ACCESS_KEY_ID }}
|
|
SCCACHE_AWS_SECRET_ACCESS_KEY: ${{ secrets.SCCACHE_AWS_SECRET_ACCESS_KEY }}
|
|
AWS_REGION: us-east-1
|
|
|
|
- name: Clean Local Go Cache (Start Fresh)
|
|
run: |
|
|
echo "Clearing local cache..."
|
|
go clean -cache
|
|
rm -rf ~/.cache/go-cache
|
|
|
|
- name: Cold Build (Cache Miss / Populates S3)
|
|
run: |
|
|
echo "Running cold build..."
|
|
time go build -o test-binary main.go
|
|
|
|
- name: Clean Local Go Cache (Forces Remote Fetch)
|
|
run: |
|
|
echo "Clearing local cache to force remote S3 fetch..."
|
|
go clean -cache
|
|
rm -rf ~/.cache/go-cache
|
|
|
|
- name: Warm Build (Cache Hit / Fetches from S3)
|
|
run: |
|
|
echo "Running warm build..."
|
|
time go build -o test-binary main.go
|
|
|
|
- name: Run Test Binary
|
|
run: ./test-binary
|