repaired #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Backend Test | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: | |
- main | |
- "release/*.*.*" | |
paths: | |
- "go.mod" | |
- "go.sum" | |
- "**.go" | |
jobs: | |
go-static-checks: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: 1.22 | |
check-latest: true | |
cache: true | |
- name: Verify go.mod is tidy | |
run: | | |
go mod tidy -go=1.22 | |
git diff --exit-code | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: v1.54.1 | |
args: --verbose --timeout=3m | |
skip-cache: true | |
go-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: 1.22 | |
check-latest: true | |
cache: true | |
# Add an action to run your tests with the CodeComet action: | |
- name: Run all tests | |
uses: codecomet-io/setup-and-run@v1.4 | |
env: | |
# You can save the CODECOMET_API_KEY in your repo's secrets: | |
CODECOMET_API_KEY: ${{ secrets.CODECOMET_API_KEY }} | |
with: | |
# Not sure if 'tee' works | |
test_command: go test -v ./... | tee test.log; exit ${PIPESTATUS[0]} | |
test_suite_name: Memos Backend Tests | |
- 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"}' |