mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-09-19 09:40:12 +00:00
153 lines
4.4 KiB
YAML
153 lines
4.4 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
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
steps:
|
|
|
|
- uses: actions/checkout@v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/setup-go@v7
|
|
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@v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/setup-go@v7
|
|
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@v7.0.1
|
|
with:
|
|
path: nezha
|
|
persist-credentials: false
|
|
- name: Checkout Agent repository
|
|
uses: actions/checkout@v7.0.1
|
|
with:
|
|
repository: nezhahq/agent
|
|
path: agent
|
|
persist-credentials: false
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v7
|
|
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
|
|
|