Files
nezha_domains/.github/workflows/test.yml
T
dependabot[bot] bb941e4d73 chore(deps): bump the github-actions group with 2 updates
Bumps the github-actions group with 2 updates: [actions/checkout](https://github.com/actions/checkout) and [actions/setup-go](https://github.com/actions/setup-go).


Updates `actions/checkout` from 7.0.0 to 7.0.1
- [Release notes](https://github.com/actions/checkout/releases)
- [Commits](https://github.com/actions/checkout/compare/v7...v7.0.1)

Updates `actions/setup-go` from 6 to 7
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: actions/setup-go
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-22 06:56:52 +08:00

147 lines
4.7 KiB
YAML

name: Run Tests
on:
push:
branches:
- master
pull_request:
branches:
- master
merge_group:
permissions:
contents: read
concurrency:
group: nezha-quality-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
name: Ordinary tests and build (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e
with:
go-version: "1.26.x"
cache: false
- name: Generate Swagger docs
run: |
go install github.com/swaggo/swag/cmd/swag@v1.16.6
touch ./cmd/dashboard/user-dist/a
touch ./cmd/dashboard/admin-dist/a
swag init --pd -d cmd/dashboard -g main.go -o cmd/dashboard/docs
- name: Unit test
run: go test -mod=readonly -count=1 ./...
- name: Build dashboard
run: go build -v ./cmd/dashboard
linux-race-quality:
name: Linux race and quality
runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e
with:
go-version: "1.26.x"
cache: false
- name: Generate Swagger docs
run: |
go install github.com/swaggo/swag/cmd/swag@v1.16.6
touch ./cmd/dashboard/user-dist/a
touch ./cmd/dashboard/admin-dist/a
swag init --pd -d cmd/dashboard -g main.go -o cmd/dashboard/docs
- name: Race and shuffle tests
run: go test -mod=readonly -race -shuffle=on -count=1 ./...
- name: Vet
run: go vet ./...
- name: Check formatting
shell: bash
run: test -z "$(git ls-files -co --exclude-standard '*.go' -z | xargs -0 gofmt -l)"
- name: Build dashboard
run: go build ./cmd/dashboard
- name: Run Gosec Security Scanner
shell: bash
env:
GOTOOLCHAIN: auto
run: |
go install github.com/securego/gosec/v2/cmd/gosec@v2.27.1
gosec --exclude=G104,G115,G117,G203,G402,G703,G704 ./...
agentcompat-stress:
name: Linux agent compatibility stress
runs-on: ubuntu-24.04
timeout-minutes: 75
steps:
- name: Checkout Nezha revision
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
path: nezha
persist-credentials: false
- name: Checkout pinned Agent revision
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
repository: nezhahq/agent
ref: 667e1dd5e166ffef808ec26dc20de85bc33a0a0f
path: agent
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e
with:
go-version: "1.26.x"
cache: false
- name: Prepare Dashboard build inputs
working-directory: nezha
run: |
go install github.com/swaggo/swag/cmd/swag@v1.16.6
mkdir -p cmd/dashboard/user-dist cmd/dashboard/admin-dist
printf 'placeholder\n' > cmd/dashboard/user-dist/placeholder.txt
printf 'placeholder\n' > cmd/dashboard/admin-dist/placeholder.txt
swag init --pd -d cmd/dashboard -g main.go -o cmd/dashboard/docs
- name: Require named stress test
working-directory: nezha
run: go test -mod=readonly -tags=agentcompat -list '^TestStressPRFullEightAgentExactlyOnce$' ./integration/agentcompat/internal/scenario | grep -Fx 'TestStressPRFullEightAgentExactlyOnce'
- name: Run PR-full agent compatibility stress
working-directory: nezha
env:
AGENTCOMPAT_NEZHA_SOURCE: ${{ github.workspace }}/nezha
AGENTCOMPAT_AGENT_SOURCE: ${{ github.workspace }}/agent
run: go test -mod=readonly -tags=agentcompat -run '^TestStressPRFullEightAgentExactlyOnce$' -count=1 -v ./integration/agentcompat/internal/scenario
nezha-quality-required:
name: nezha-quality-required
if: ${{ always() }}
needs:
- tests
- linux-race-quality
- agentcompat-stress
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Require all blocking jobs to pass
shell: bash
run: |
test "${{ needs.tests.result }}" = success
test "${{ needs.linux-race-quality.result }}" = success
test "${{ needs.agentcompat-stress.result }}" = success