From 3bba1d1cd8ed69692ae9b0aff63f33b4f82b7503 Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Tue, 19 May 2026 21:07:46 -0700 Subject: [PATCH] feat(ci): add CI workflow e2e test with cold/warm builds --- .gitea/workflows/ci.yml | 56 +++++++++++++++++++++++++++++++++++++++++ main.go | 10 ++++++++ 2 files changed, 66 insertions(+) create mode 100644 .gitea/workflows/ci.yml create mode 100644 main.go diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..2277021 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,56 @@ +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: auto + + - name: Clean Local Go Cache (Start Fresh) + run: | + echo "Clearing local cache..." + go clean -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 + + - 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 diff --git a/main.go b/main.go new file mode 100644 index 0000000..1610bda --- /dev/null +++ b/main.go @@ -0,0 +1,10 @@ +package main + +import ( + "fmt" + "time" +) + +func main() { + fmt.Printf("Hello, Gitea Actions with Go caching on S3! Built at: %s\n", time.Now().Format(time.RFC3339)) +}