mirror of
https://github.com/MeshCore-Beacon/beacon-server.git
synced 2026-11-04 10:57:31 +00:00
* Read each observer's receptions on their own in the observer comparison * Tighten the observer comparison plan checks
135 lines
8.8 KiB
YAML
135 lines
8.8 KiB
YAML
# Copyright 2026 Beacon Contributors
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main, dev]
|
|
pull_request:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
backup-postgres:
|
|
image: postgres:16-alpine
|
|
env:
|
|
POSTGRES_PASSWORD: backup-ci-only
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 5s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
# The fixture tier's baselines were written on PostgreSQL 16.15 under C collation: keep both fixed here.
|
|
planguard-postgres:
|
|
image: postgres:16.15-alpine
|
|
env:
|
|
POSTGRES_PASSWORD: planguard-ci-only
|
|
POSTGRES_DB: planguard
|
|
POSTGRES_INITDB_ARGS: --locale=C --encoding=UTF8
|
|
ports:
|
|
- 5433:5432
|
|
options: >-
|
|
--health-cmd pg_isready --health-interval 5s --health-timeout 5s --health-retries 10
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
|
|
- name: Build
|
|
run: go build ./...
|
|
|
|
- name: Format check
|
|
run: |
|
|
if [ -n "$(gofmt -l .)" ]; then
|
|
echo "The following files are not formatted:"
|
|
gofmt -l .
|
|
exit 1
|
|
fi
|
|
|
|
- name: Vet
|
|
run: go vet ./...
|
|
|
|
- name: Test
|
|
run: go test ./...
|
|
|
|
- name: Verify scope refresh concurrency
|
|
run: go test -race ./internal/meshmapper ./internal/scopestore && go test -race ./db -run '^TestChannelIDCache'
|
|
|
|
- name: Verify backup startup and the read-only boot against PostgreSQL 16
|
|
env:
|
|
BEACON_TEST_POSTGRES_DSN: postgres://postgres:backup-ci-only@127.0.0.1:5432/postgres?sslmode=disable
|
|
run: go test ./cmd/beacon -run '^Test(BackupConfiguration|ReadOnlyBootWritesNothing)Postgres$' -count=1 -v
|
|
|
|
- name: Verify stats and endpoint queries against PostgreSQL 16
|
|
env:
|
|
BEACON_TEST_POSTGRES_DSN: postgres://postgres:backup-ci-only@127.0.0.1:5432/postgres?sslmode=disable
|
|
run: go test ./db -run '^Test(Signal|Paths|PacketSummaries|PacketEndpointsResolveLive|ObserverMetrics|RouteEvidence|RouteEvidenceIndex|AnalyticsRetention|AnalyticsRetentionConcurrent|DeleteOldPacketsBatches|MeshMapperCatalogue|ChannelMessageScopes|NodeLocationReset|RunMigrations[A-Za-z]*|KnownRoutesIndexSet|PacketsDomainChecks|Reconfirm[A-Za-z]*|BigintCursors|RouteSearchHopOrder|StatsNodeTypesSplit|ListKnownRoutes|ListKnownRoutesMatchesLegacy|KnownRoutesCursorTies|KnownRoutesUnanalyzedRegion|KnownRoutesHopStatementsStayCustom|KnownRoutePaginationTies|RouteRetentionCutoffsExact|DeleteExpiredRoutes|DeleteGraceRoutesSlice|GraceWatermarkHeldByLockedRow|OpenPoolsSettings|PlanRouterClassCUnnamed|APIStoreHopStatementsUnnamed|PgStatStatementsMigrationGuarded|DBStatements|DBStatementsNoExtension|PgStatStatementsMigrationNoCreatableSchema|IndexHealthBaselineOnReindex|UnusedIndexes|PgActivity|RollHourSetsWorkMem|SmallTableIndexSet|NodeReadersAfterIndexDrops|ObserverChannelReadersAfterIndexDrops|UpsertChannelWriteThrough|UpsertChannelHashOnlyWriteThrough|ReadOnlyPoolsRejectWrites|ListPacketsGlobalMatchesLegacy|PacketsGlobalCursorTies|ListPacketsWindowInvertedRows|PacketsLatestObserverTie|NodesLegacyCursorMatchesToday|NodesPageCursorTies|ObserversLegacyCursorMatchesToday|ObserversNextCursorFromLastSeen|ObserverAdvertsPartialIndex|ObserverComparisonMatchesToday|AdvertsWaitForPayloadTypeBackfill|StatsProbeMatchesToday|TraceTagsKeysetMatchesToday|TelemetrySinceMatchesCatchAll|TraceTagPagination|TraceTagPaginationTies|TraceSummarySurvivesMissedHearing|CmiMigrationsIndexSet|InsertChannelMessageSeed[A-Za-z]*|AddChannelMessageIATA|CmiSeedAndAddRace|CmiInitAndBackfill|CmiMessageRangeReconcile|CmiObservationRangeReconcile|CmiBackfillRetries23503|WaitForPreBootWriters|ChannelMessagesByIATAsMatchesLegacy|ChannelMessagesZeroHitRegion|CmiTrustLifecycle|CmiFirstVerification|PacketSitesMigrationsIndexSet|InsertObservationMaintainsPacketSites|InsertObservationResendWritesNothing|PacketSitesRaceMaxMerge|InsertObservationSiteFallback|PacketSitesInitAndBackfill|FillPacketSitesSliceIdempotent|FillPacketSitesSliceRetries23503|PacketSitesReconcile|PacketSitesAudit|PacketSitesAuditTakesNewestHearing|PacketsBySitesMatchesTruth|PacketsBySitesCursorTies|PacketsBySitesManyBogusSites|PacketsBySitesSaturatedPagesFull|PacketsBySitesMatchesLegacy|PacketSitesTrustLifecycle|PacketsBySitesBounded|PacketsBySitesFallbackKeepsPageCursor|SweepPacketSitesFrontsPlan|IndexHealthPacketSitesFreshBaseline|PacketSitesFirstVerification|PacedBackfillSlices|FillSessionsPlanCustom|FillAnalyzeFailureIsIgnored|FillAnalyzeOnlyNeverAnalyzed|HygieneIndexSet|HygieneReadersAfterIndexDrops|KnownRoutesColumns|SequenceUse|SlowPoolIsolation|SlowPoolSize|SequenceUseMixedCaseSchema|ObservationsIndexSet|ReadersAfterIndexDrops)Postgres$' -count=1 -v
|
|
|
|
- name: Verify the channel message site rule against PostgreSQL 16
|
|
env:
|
|
BEACON_TEST_POSTGRES_DSN: postgres://postgres:backup-ci-only@127.0.0.1:5432/postgres?sslmode=disable
|
|
run: go test ./internal/ingest -run '^Test(CmiAddOnDecryptFailure|CmiCleanIngestReconcilesNothing)Postgres$' -count=1 -v
|
|
|
|
- name: Verify route retention task against PostgreSQL 16
|
|
env:
|
|
BEACON_TEST_POSTGRES_DSN: postgres://postgres:backup-ci-only@127.0.0.1:5432/postgres?sslmode=disable
|
|
run: go test ./internal/background -run '^Test(RouteRetentionTask|PayloadTypeBackfill|PayloadTypeBackfillProbe|CmiBootRepair|CmiReadOnlyTrust|PacketSitesRollbackRollForward|PacketSitesTrustDropsOnBypass|PacketSitesReadOnlyTrust|PacedFillsEarnTrust)Postgres$' -count=1 -v
|
|
|
|
# Builds the fixture once; the planguard tests below reuse it (PLANGUARD_FIXTURE_DSN) after checking that its
|
|
# marker records a build of the same files.
|
|
- name: Planguard fixture tier (plain EXPLAIN on a migrated, skewed fixture)
|
|
run: go run ./cmd/planguard run --tier fixture --dsn 'postgres://postgres:planguard-ci-only@127.0.0.1:5433/planguard?sslmode=disable' --out "$RUNNER_TEMP/planguard"
|
|
|
|
- name: Verify planguard against PostgreSQL 16
|
|
env:
|
|
BEACON_TEST_POSTGRES_DSN: postgres://postgres:backup-ci-only@127.0.0.1:5432/postgres?sslmode=disable
|
|
PLANGUARD_FIXTURE_DSN: postgres://postgres:planguard-ci-only@127.0.0.1:5433/planguard?sslmode=disable
|
|
run: go test ./internal/planguard -timeout 20m -run '^Test(RunnerReadOnly|RunnerRecoversAfterError|UnresolvedParamsSkip|GenericModeShowsParams|CorpusStatementsPrepareClean|BuildFixtureThroughMigrations|BuildFixtureRefusesRealDatabase|BuildFixtureRebuildsStaleInputs|RunDiffSnapshot|RunDiffFindsReadmodelsSkip|StatementScannerMatches|PlanguardProdTier|PlanguardProdCancel|RequiresIndexSkips|RetiredIndexesDropped)Postgres$' -count=1 -v
|
|
|
|
- name: Plan policy up to date
|
|
run: go run ./cmd/planguard gen-policy && git diff --exit-code db/planpolicy
|
|
|
|
- name: Verify backup command against PostgreSQL 16
|
|
run: |
|
|
CGO_ENABLED=0 go build -o "$RUNNER_TEMP/beacon-backup" ./cmd/beacon-backup
|
|
CGO_ENABLED=0 go test -c -o "$RUNNER_TEMP/backup.test" ./internal/backup
|
|
CGO_ENABLED=0 go test -c -o "$RUNNER_TEMP/backup-http.test" ./internal/api/router
|
|
docker run --rm --network host \
|
|
-e PGHOST=127.0.0.1 -e PGUSER=postgres -e PGDATABASE=postgres \
|
|
-e PGPASSWORD=backup-ci-only -e PGSSLMODE=disable \
|
|
-e BEACON_BACKUP_TEST_POSTGRES=1 -e BEACON_BACKUP_TEST_BINARY=/beacon-backup \
|
|
-v "$RUNNER_TEMP/beacon-backup:/beacon-backup:ro" \
|
|
-v "$RUNNER_TEMP/backup.test:/backup.test:ro" \
|
|
postgres:16-alpine /backup.test -test.run '^TestExportPostgres$' -test.v
|
|
docker run --rm --network host \
|
|
-e PGHOST=127.0.0.1 -e PGUSER=postgres -e PGDATABASE=postgres \
|
|
-e PGPASSWORD=backup-ci-only -e PGSSLMODE=disable -e BEACON_BACKUP_TEST_POSTGRES=1 \
|
|
-v "$RUNNER_TEMP/backup-http.test:/backup-http.test:ro" \
|
|
postgres:16-alpine /backup-http.test -test.run '^TestBackupDownloadPostgres$' -test.v
|
|
|
|
- name: Install govulncheck
|
|
run: go install golang.org/x/vuln/cmd/govulncheck@latest
|
|
|
|
- name: Vulnerability check
|
|
run: govulncheck ./...
|
|
|
|
- name: Install swag
|
|
run: go install github.com/swaggo/swag/cmd/swag@latest
|
|
|
|
- name: Swagger docs up to date
|
|
run: |
|
|
cp docs/swagger.json docs/swagger.json.bak
|
|
swag init -g cmd/beacon/main.go -o docs --parseInternal --parseDependency
|
|
if ! diff -q docs/swagger.json docs/swagger.json.bak > /dev/null; then
|
|
echo "Swagger docs are out of date. Run swag init and commit the result."
|
|
rm docs/swagger.json.bak
|
|
exit 1
|
|
fi
|
|
rm docs/swagger.json.bak
|