backend-tests.yml 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. name: Backend Test
  2. on:
  3. push:
  4. branches: [main]
  5. pull_request:
  6. branches:
  7. - main
  8. - "release/*.*.*"
  9. paths:
  10. - "go.mod"
  11. - "go.sum"
  12. - "**.go"
  13. jobs:
  14. go-static-checks:
  15. runs-on: ubuntu-latest
  16. steps:
  17. - uses: actions/checkout@v4
  18. - uses: actions/setup-go@v5
  19. with:
  20. go-version: 1.22
  21. check-latest: true
  22. cache: true
  23. - name: Verify go.mod is tidy
  24. run: |
  25. go mod tidy -go=1.22
  26. git diff --exit-code
  27. - name: golangci-lint
  28. uses: golangci/golangci-lint-action@v6
  29. with:
  30. version: v1.54.1
  31. args: --verbose --timeout=3m
  32. skip-cache: true
  33. go-tests:
  34. runs-on: ubuntu-latest
  35. steps:
  36. - uses: actions/checkout@v4
  37. - uses: actions/setup-go@v5
  38. with:
  39. go-version: 1.22
  40. check-latest: true
  41. cache: true
  42. - name: Run all tests
  43. run: go test -v ./... | tee test.log; exit ${PIPESTATUS[0]}
  44. - name: Pretty print tests running time
  45. 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"}'