diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index edc7a69c..82aef70c 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -24,64 +24,69 @@ jobs: with: go_version_file: backend/go.mod workdir: backend - fail_on_error: true + fail_level: error filter_mode: nofilter golangci_lint_flags: --timeout=10m - format: - name: Format + generate: + name: Generate runs-on: ubuntu-latest steps: - - name: Generate a token - id: token - uses: actions/create-github-app-token@v1 - with: - app-id: ${{ secrets.PUSHER_APP_ID }} - private-key: ${{ secrets.PUSHER_PRIVATE_KEY }} - name: Checkout uses: actions/checkout@v4 - with: - token: ${{ steps.token.outputs.token }} - name: Setup Go uses: actions/setup-go@v5 with: - go-version-file: backend/go.mod - cache-dependency-path: backend/go.sum - - name: Mod Tidy - run: go mod tidy - - name: Install Format Tools - run: | - go install golang.org/x/tools/cmd/goimports@v0.28.0 - go install mvdan.cc/gofumpt@v0.7.0 - - name: Run Format Tools - run: | - find . -type f -name '*.go' -not -path "*/internal/proto/*" | while IFS='' read -r file; do goimports -l -w "$file"; done - gofumpt -l -w . - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Go - uses: actions/setup-go@v5 + go-version: 1.23 + cache: false + - uses: actions/cache/restore@v4 + id: go-cache + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: go-${{ hashFiles('backend/go.sum') }} + restore-keys: | + go- + - name: Go Generate + run: go generate -x ./... + - name: Check Diff + run: git diff --exit-code + - uses: actions/cache/save@v4 + if: steps.go-cache.outputs.cache-hit != 'true' && github.ref == 'refs/heads/main' with: - go-version-file: backend/go.mod - cache-dependency-path: backend/go.sum - - name: Mod Download - run: go mod download - - name: Build - run: CGO_ENABLED=0 go build -ldflags "-s -w" -trimpath . + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ steps.go-cache.outputs.cache-primary-key }} test: name: Test runs-on: ubuntu-latest - needs: build steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Go uses: actions/setup-go@v5 with: - go-version-file: backend/go.mod - cache-dependency-path: backend/go.sum + go-version: 1.23 + cache: false + - uses: actions/cache/restore@v4 + id: go-cache + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: go-${{ hashFiles('backend/go.sum') }} + restore-keys: | + go- + - name: Go Modules + if: steps.go-cache.outputs.cache-hit != 'true' + run: go mod download -x - name: Run Test - run: go test ./... -v + run: go test -race -shuffle on -parallel 8 -v ./... + - uses: actions/cache/save@v4 + if: steps.go-cache.outputs.cache-hit != 'true' && github.ref == 'refs/heads/main' + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ steps.go-cache.outputs.cache-primary-key }}