2022-12-25 10:39:45 +08:00
|
|
|
name: Backend Test
|
|
|
|
|
|
|
|
on:
|
2023-09-17 23:18:18 +08:00
|
|
|
push:
|
|
|
|
branches: [main]
|
2022-12-27 21:51:43 +08:00
|
|
|
pull_request:
|
2022-12-25 10:39:45 +08:00
|
|
|
branches:
|
|
|
|
- main
|
2023-01-01 22:01:16 +08:00
|
|
|
- "release/*.*.*"
|
2023-10-22 22:08:38 +08:00
|
|
|
paths:
|
|
|
|
- "go.mod"
|
|
|
|
- "go.sum"
|
|
|
|
- "**.go"
|
2022-12-25 10:39:45 +08:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
go-static-checks:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-10-03 16:58:47 +08:00
|
|
|
- uses: actions/checkout@v4
|
2023-12-08 09:55:18 +08:00
|
|
|
- uses: actions/setup-go@v5
|
2022-12-25 10:39:45 +08:00
|
|
|
with:
|
2024-02-08 08:13:42 +08:00
|
|
|
go-version: 1.22
|
2022-12-25 10:39:45 +08:00
|
|
|
check-latest: true
|
|
|
|
cache: true
|
|
|
|
- name: Verify go.mod is tidy
|
|
|
|
run: |
|
2024-02-08 08:13:42 +08:00
|
|
|
go mod tidy -go=1.22
|
2022-12-25 10:39:45 +08:00
|
|
|
git diff --exit-code
|
|
|
|
- name: golangci-lint
|
|
|
|
uses: golangci/golangci-lint-action@v3
|
|
|
|
with:
|
2023-09-17 23:21:03 +08:00
|
|
|
version: v1.54.1
|
|
|
|
args: --verbose --timeout=3m
|
2022-12-25 10:39:45 +08:00
|
|
|
skip-cache: true
|
|
|
|
|
|
|
|
go-tests:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-10-03 16:58:47 +08:00
|
|
|
- uses: actions/checkout@v4
|
2023-12-08 09:55:18 +08:00
|
|
|
- uses: actions/setup-go@v5
|
2022-12-25 10:39:45 +08:00
|
|
|
with:
|
2024-02-08 08:13:42 +08:00
|
|
|
go-version: 1.22
|
2022-12-25 10:39:45 +08:00
|
|
|
check-latest: true
|
|
|
|
cache: true
|
|
|
|
- name: Run all tests
|
|
|
|
run: go test -v ./... | tee test.log; exit ${PIPESTATUS[0]}
|
|
|
|
- name: Pretty print tests running time
|
|
|
|
run: grep --color=never -e '--- PASS:' -e '--- FAIL:' test.log | sed 's/[:()]//g' | awk '{print $2,$3,$4}' | sort -t' ' -nk3 -r | awk '{sum += $3; print $1,$2,$3,sum"s"}'
|