Skip to content

Commit

Permalink
chore(ci): rewrite backend ci
Browse files Browse the repository at this point in the history
  • Loading branch information
tosuke committed Dec 17, 2024
1 parent 2e5b570 commit 479115a
Showing 1 changed file with 47 additions and 41 deletions.
88 changes: 47 additions & 41 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,64 +24,70 @@ jobs:
with:
go_version_file: backend/go.mod
workdir: backend
fail_on_error: true
level: warning
fail_on_error: true # deprecated
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/[email protected]
go install mvdan.cc/[email protected]
- 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 }}

0 comments on commit 479115a

Please sign in to comment.