mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-04 16:34:52 +03:00
3d6655ffb0
Complete the remaining correctness work for #7319 on top of the SQL fleet aggregation introduced by #7342. Replace the overflowing BIGINT upload-plus-download quota comparison in countNodeFleet with a guarded subtraction-based CASE. Preserve depletion precedence, unlimited quotas, missing traffic behavior, email-based traffic attribution, host deduplication, exclusion of orphan memberships, and database error propagation. Add regression coverage for signed int64 limits, negative counters, unlimited quotas and orphan memberships. Require both fleet regression tests to execute and pass in PostgreSQL CI without weakening existing checks. Validation: reviewed head e9b344a63bdf6aa945f0e4f6b3cbe933a416fabe; all 12 CI jobs passed, including both PostgreSQL fleet tests and all seven quota subcases. Independent arithmetic comparison over 1,331 boundary combinations found zero mismatches. See https://github.com/MHSanaei/3x-ui/pull/7323#issuecomment-7388723297. The green CI is for the reviewed PR head, not a fresh post-merge run. Closes #7319.
661 lines
32 KiB
YAML
661 lines
32 KiB
YAML
name: CI
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- "**.go"
|
|
- "go.mod"
|
|
- "go.sum"
|
|
- "frontend/**"
|
|
- ".nvmrc"
|
|
- "Makefile"
|
|
- "install.sh"
|
|
- "deploy/test/installer-panel-port.sh"
|
|
- ".github/workflows/ci.yml"
|
|
- "x-ui.sh"
|
|
- "scripts/lib/ip-ssl.sh"
|
|
- "scripts/sync-ip-ssl-helpers.sh"
|
|
- "scripts/test/**"
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "**.go"
|
|
- "go.mod"
|
|
- "go.sum"
|
|
- "frontend/**"
|
|
- ".nvmrc"
|
|
- "Makefile"
|
|
- "install.sh"
|
|
- "deploy/test/installer-panel-port.sh"
|
|
- ".github/workflows/ci.yml"
|
|
- "x-ui.sh"
|
|
- "scripts/lib/ip-ssl.sh"
|
|
- "scripts/sync-ip-ssl-helpers.sh"
|
|
- "scripts/test/**"
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
go-test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: actions/setup-go@v7
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
- name: Stub internal/web/dist for go:embed
|
|
run: mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
|
|
- name: Test
|
|
run: |
|
|
go list ./... | grep -v '/frontend/node_modules/' > /tmp/go-packages.txt
|
|
mapfile -t go_packages < /tmp/go-packages.txt
|
|
go test -shuffle=on -count=1 "${go_packages[@]}"
|
|
|
|
postgres-durable-first:
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
postgres:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: xui_durable
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd "pg_isready -U postgres -d xui_durable"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
env:
|
|
XUI_DB_TYPE: postgres
|
|
XUI_DB_DSN: "host=127.0.0.1 port=5432 user=postgres password=postgres dbname=xui_durable sslmode=disable"
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: actions/setup-go@v7
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
- name: Stub internal/web/dist for go:embed
|
|
run: mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
|
|
- name: PostgreSQL durable-first tests
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run 'PostgresCommitFailure|^TestSyncInboundClientsOnPostgres$|^TestSetClientLimitHwidIsSerializedWithSyncInbound$|^TestVlessManagedFallbackConflictPostgres$' -count=1 -v | tee /tmp/postgres-durable-first.log
|
|
# Count passes rather than assert no SKIP: a renamed or deleted test
|
|
# prints "no tests to run" and exits 0, leaving the step green for nothing.
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-durable-first.log || true)
|
|
if [ "$passed" -lt 5 ]; then
|
|
echo "expected at least 5 passing durable-first tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL maintenance fencing and recovery
|
|
run: |
|
|
set -o pipefail
|
|
go test -p=1 . ./internal/database -run '^Test(PostgresCLIWorkFenceSurvivesSessionLoss|PostgresExclusiveRestoreFenceSurvivesSessionLoss|PostgresPendingRestoreRetriesBeforeServing|PostgresRuntimeMaintenanceReacquiresAfterSessionLoss|MaintenanceAcrossProcesses)$' -count=1 -v | tee /tmp/postgres-maintenance.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-maintenance.log || true)
|
|
if [ "$passed" -ne 5 ]; then
|
|
echo "expected 5 passing PostgreSQL maintenance tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL inbound add orphan cleanup
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^TestAddInboundClient(BoundedOrphanCleanup|OrphanProbePreservesConcurrentRecreation)Postgres$' -count=1 -v | tee /tmp/postgres-add-orphans.log
|
|
passed=$(grep -c -- '^--- PASS: TestAddInboundClient' /tmp/postgres-add-orphans.log || true)
|
|
if [ "$passed" -ne 2 ]; then
|
|
echo "expected both PostgreSQL inbound add orphan cleanup tests to pass, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL sync orphan recovery
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^Test(SyncOrphanRecoveryScope|LegacySyncOrphanMarksAcrossLinkChanges)Postgres$' -count=1 -v | tee /tmp/postgres-sync-orphans.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-sync-orphans.log || true)
|
|
if [ "$passed" -ne 2 ]; then
|
|
echo "expected both PostgreSQL sync orphan recovery tests to pass, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL client traffic lifecycle edits
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^TestClientTrafficLifecyclePostgres$' -count=1 -v | tee /tmp/postgres-client-traffic-lifecycle.log
|
|
if ! grep -q -- '^--- PASS: TestClientTrafficLifecyclePostgres ' /tmp/postgres-client-traffic-lifecycle.log; then
|
|
echo "expected the PostgreSQL client traffic lifecycle suite to pass" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL batched stats identities
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^TestClientStatsIdentitiesPostgres$' -count=1 -v | tee /tmp/postgres-stats-identities.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-stats-identities.log || true)
|
|
if [ "$passed" -ne 1 ]; then
|
|
echo "expected 1 passing PostgreSQL stats identities test, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL client IP sync regressions
|
|
run: |
|
|
set -o pipefail
|
|
go test -p=1 ./internal/web/service ./internal/web/job -run '^TestClientIpSyncPostgres(Scanner|Scheduler)?$' -count=1 -v | tee /tmp/postgres-client-ip-sync.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-client-ip-sync.log || true)
|
|
if [ "$passed" -ne 3 ]; then
|
|
echo "expected 3 passing PostgreSQL client IP sync tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL IP reporter lock order and lifecycle
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^TestPostgres(NodeIPReporterClientLockOrder|FlatIPReporterLifecycleCommit|PolledAttributionSurvivesConcurrentPrune)$' -count=1 -v | tee /tmp/postgres-ip-reporter-locks.log
|
|
for test in NodeIPReporterClientLockOrder FlatIPReporterLifecycleCommit PolledAttributionSurvivesConcurrentPrune; do
|
|
if ! grep -q -- "^--- PASS: TestPostgres${test} " /tmp/postgres-ip-reporter-locks.log; then
|
|
echo "expected PostgreSQL reporter test TestPostgres${test} to pass" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
- name: PostgreSQL Xray traffic retry
|
|
run: |
|
|
set -o pipefail
|
|
go test -p=1 ./internal/web/job ./internal/web/service -run '^TestXrayTraffic(PollRetriesRolledBackSample|BatchSurvivesFullQueueAndWriterRestart|BatchRetriesDeferredCommitFailure)Postgres$' -count=1 -v | tee /tmp/postgres-xray-traffic-retry.log
|
|
passed=$(grep -c -- '^--- PASS: TestXrayTraffic' /tmp/postgres-xray-traffic-retry.log || true)
|
|
if [ "$passed" -ne 3 ]; then
|
|
echo "expected 3 passing PostgreSQL Xray traffic retry tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL inbound catalog scope and projection
|
|
run: go test ./internal/web -run '^TestRemoteInboundCatalogScopeAndProjection$' -count=1 -v
|
|
|
|
- name: PostgreSQL online attribution regressions
|
|
run: |
|
|
set -o pipefail
|
|
go test -p=1 ./internal/web/job ./internal/web/service -run '^Test(InboundOnlineAvailabilityDistinguishesEmptyFromMissing|SetRemoteTraffic_RemapsActiveInboundTreeAndCentralTags|XrayTrafficRetryDoesNotPublishOnlineStateAcrossCoreReplacement)$' -count=1 -v | tee /tmp/postgres-online-attribution.log
|
|
passed=$(grep -c -- '^--- PASS: Test' /tmp/postgres-online-attribution.log || true)
|
|
if [ "$passed" -ne 3 ]; then
|
|
echo "expected 3 passing PostgreSQL online attribution tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL node client push ordering
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^Test(NodeClientMutationsCommitWhileAnEarlierPushIsBlocked|NodeClientQueueTimeoutDefersCommittedDelta|NodeClientCapacityPreservesPermanentDelete|NodeWideDeleteSkipsReattachmentSentByQueuedReconcile|NodeWideDeleteRetriesAfterQueueExpiry|BulkDeleteStopsPushingToAHungNode|ReconcileDoesNotOvertakeCommittedClientState|TrafficDepletionWaitsForEarlierNodeClientPush|Create(GroupsCompatibleInboundsOnOneRemote|SplitsFlowAndSendsResolvedInbounds|UsesEffectiveAllowedIPsOnRemote|DispatchesReadyLaneBeforeBlockedLane|CancellationStopsFurtherNodeWaves)|GroupedCreate(ReconcilesUnsentRebasedSettings|RecoversIndeterminateDelivery|RepairsDeferredTargets|DispatchesIndependentReadyPayload|OrdersLaterClientMutations|ReconcileBarrierDrainsAfterAcknowledgment|KeepsFifthNodeDurablyPendingWhenBudgetExpires|PreservesProtocolCredentials))$' -count=1 -v | tee /tmp/postgres-node-client-order.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-node-client-order.log || true)
|
|
if [ "$passed" -ne 21 ]; then
|
|
echo "expected 21 passing PostgreSQL node client ordering tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL client inbound read regressions
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^Test(ClientCreate(ReadsInboundSettingsOnlyForMutation|ClearsFlowOnIneligibleInbound|PreservesSettingsBasedDefaults)|UpdateInboundClientReadsSettingsOnceBeforeCommit|Slim(Create(UsesLockedFlowForGroupedDelivery|HealthyTargetsProgressWithBlockedPeer|ProjectionPreservesNodeIDAndProtocolSettings)|AttachUsesLockedFlowAndPreservesRawAdd|UpdateRebasesConcurrentSettings))$' -count=1 -v | tee /tmp/postgres-client-inbound-reads.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-client-inbound-reads.log || true)
|
|
if [ "$passed" -ne 9 ]; then
|
|
echo "expected 9 passing PostgreSQL client inbound read tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL paged group client workflows
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/controller -run '^Test(GroupClientPageAndFrozenWriteHTTP|GroupBulkOperationsRespectFrozenMembersHTTP|GroupBulkAddResolvesInboundMembershipHTTP|GroupSubscriptionExportAndPagingHTTP|GroupAdjustCapsReportedSkipsWithoutChangingExplicitResponses)$' -count=1 -v | tee /tmp/postgres-group-clients.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-group-clients.log || true)
|
|
if [ "$passed" -ne 5 ]; then
|
|
echo "expected 5 passing PostgreSQL group client tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL frozen group identity
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^TestFrozenGroupBulk(RejectsIdentityAndMembershipChanges|AppliesLinkedTargets|AdjustSurvivesMembershipMoveAfterCommit|AdjustRollsBackWhenTrafficWriteFails)$' -count=1 -v | tee /tmp/postgres-frozen-group-identity.log
|
|
passed=$(grep -c -- '^--- PASS: TestFrozenGroupBulk' /tmp/postgres-frozen-group-identity.log || true)
|
|
if [ "$passed" -ne 4 ]; then
|
|
echo "expected 4 passing PostgreSQL frozen group tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL global-traffic heartbeat regressions
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^TestGlobalTrafficHeartbeatPostgres$' -count=1 -v | tee /tmp/postgres-global-traffic-heartbeat.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-global-traffic-heartbeat.log || true)
|
|
if [ "$passed" -ne 1 ]; then
|
|
echo "expected 1 passing global-traffic heartbeat test, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL node client reconciliation rollback
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^TestNode(ClientReconcileRollback|RefusedFirstAdoptionKeepsNodeSettings)Postgres$' -count=1 -v | tee /tmp/postgres-node-client-rollback.log
|
|
passed=$(grep -c -- '^--- PASS: TestNode' /tmp/postgres-node-client-rollback.log || true)
|
|
if [ "$passed" -ne 2 ]; then
|
|
echo "expected both PostgreSQL node client reconciliation rollback tests to pass, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL client usage history
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^TestClientUsageHistoryPostgres$' -count=1 -v | tee /tmp/postgres-usage-history.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-usage-history.log || true)
|
|
if [ "$passed" -ne 1 ]; then
|
|
echo "expected 1 passing PostgreSQL client usage history test, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL attach candidate selection
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^Test(AttachCandidatesSelection|FrozenAttachSelectionFollowsFilter)Postgres$' -count=1 -v | tee /tmp/postgres-attach-selection.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-attach-selection.log || true)
|
|
if [ "$passed" -ne 2 ]; then
|
|
echo "expected 2 passing PostgreSQL attach selection tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL scoped detach regressions
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^TestScopedDetach' -count=1 -v | tee /tmp/postgres-scoped-detach.log
|
|
test "$(grep -c -- '^--- PASS: TestScopedDetach' /tmp/postgres-scoped-detach.log)" -eq 3
|
|
|
|
- name: PostgreSQL depletion query regressions
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^TestDepletionQuery(Semantics|FreshnessAndReset|ConcurrentCommit|Renewals)$' -count=1 -v | tee /tmp/postgres-depletion-query.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-depletion-query.log || true)
|
|
if [ "$passed" -ne 4 ]; then
|
|
echo "expected 4 passing PostgreSQL depletion tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL database maintenance contention
|
|
run: |
|
|
set -o pipefail
|
|
go test -p=1 . ./internal/database ./internal/web/job -run '^Test(MaintenanceAcrossProcesses|PostgresRuntimeMaintenanceReacquiresAfterSessionLoss|PostgresPendingRestoreRetriesBeforeServing|DatabaseRestoreDrainsAnInFlightNodePoll)$' -count=1 -v | tee /tmp/postgres-maintenance.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-maintenance.log || true)
|
|
if [ "$passed" -ne 4 ]; then
|
|
echo "expected 4 passing PostgreSQL database maintenance tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL inbound migration contention
|
|
run: |
|
|
set -o pipefail
|
|
go test -p=1 ./internal/database ./internal/web/service -run '^(TestInitDBKeepsRestorePoolPrivate|TestMigrationRequirementsRejectsLiveNodeMergePostgres|TestInboundMigrationAllowsPostgresReaders)$' -count=1 -v | tee /tmp/postgres-inbound-migration.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-inbound-migration.log || true)
|
|
if [ "$passed" -ne 3 ]; then
|
|
echo "expected 3 passing PostgreSQL inbound migration and restore tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL slim inbound cache regressions
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^TestSlimInboundListReusesOnlyTheMatchingSettingsRevision$' -count=1 -v | tee /tmp/postgres-slim-inbound-cache.log
|
|
passed=$(grep -c -- '^--- PASS: TestSlimInboundListReusesOnlyTheMatchingSettingsRevision ' /tmp/postgres-slim-inbound-cache.log || true)
|
|
if [ "$passed" -ne 1 ]; then
|
|
echo "expected the PostgreSQL slim inbound cache regression to pass, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL node snapshot regressions
|
|
run: |
|
|
set -o pipefail
|
|
go test -p=1 ./internal/database ./internal/web/service -run '^(TestSnapshotRevisionsDirectWritesAndRollback|TestNodeSnapshotUnchangedAvoidsSettingsAndDetectsDirectEdits|TestNodeSnapshotMergeSkipsUnchangedStructureAndPreservesDeltas|TestNodeSnapshotReadDoesNotHoldTrafficWriter|TestNodeSnapshotCanceledReadReleasesConnection|TestNodeSnapshotReopenInvalidatesCatalog|TestNodeSnapshotCachedAliasPreservesTraffic|TestNodeSnapshotAliasInvalidCacheFallsBack|TestNodeSnapshotAliasValidatesEntireMapping|TestNodeSnapshotAliasQuotaDisableAndRenewal|TestSnapshotRevisionPostgresTypeDDL|TestSnapshotRevisionMigrationRecreationAndReopen)$' -count=1 -v | tee /tmp/postgres-node-snapshot.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-node-snapshot.log || true)
|
|
if [ "$passed" -ne 12 ]; then
|
|
echo "expected 12 passing node snapshot tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL node client reconciliation
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^Test(NodeFullReconciliation|NodeMerge(BatchesBaselinesForActiveClients|LetsSubscriptionTouchDuringClientReconciliationPostgres)$)' -count=1 -v | tee /tmp/postgres-node-client-reconciliation.log
|
|
passed=$(grep -c -- '^--- PASS: TestNodeFullReconciliation' /tmp/postgres-node-client-reconciliation.log || true)
|
|
if [ "$passed" -ne 4 ]; then
|
|
echo "expected 4 passing node client reconciliation tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
for test in TestNodeMergeBatchesBaselinesForActiveClients TestNodeMergeLetsSubscriptionTouchDuringClientReconciliationPostgres; do
|
|
if ! grep -q -- "^--- PASS: $test " /tmp/postgres-node-client-reconciliation.log; then
|
|
echo "expected PostgreSQL regression to pass: $test" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
- name: PostgreSQL node counter reset regressions
|
|
run: |
|
|
set -o pipefail
|
|
go test -p 1 ./internal/web/service ./internal/database -run '^(TestNodeFrozenDip_|TestMigrateNodeClientTrafficDippedWhileFrozenColumn$)' -count=1 -v | tee /tmp/postgres-node-counter-reset.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-node-counter-reset.log || true)
|
|
if [ "$passed" -ne 4 ]; then
|
|
echo "expected 3 node counter regressions and 1 migration test to pass, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL node merge contention
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^TestNodeMerge(LetsSubscriptionTouchDuringClientReconciliationPostgres|BatchesBaselinesForActiveClients)$' -count=1 -v | tee /tmp/postgres-node-merge-contention.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-node-merge-contention.log || true)
|
|
if [ "$passed" -ne 2 ]; then
|
|
echo "expected both PostgreSQL node merge contention tests to pass, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL node fleet count regressions
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^TestNode(FleetQuotaClassificationAtInt64Limits|OverviewCountsHostMembershipsAndUniqueFleetClients)$' -count=1 -v | tee /tmp/postgres-node-fleet.log
|
|
grep -q '^--- PASS: TestNodeFleetQuotaClassificationAtInt64Limits ' /tmp/postgres-node-fleet.log
|
|
grep -q '^--- PASS: TestNodeOverviewCountsHostMembershipsAndUniqueFleetClients ' /tmp/postgres-node-fleet.log
|
|
|
|
- name: PostgreSQL schema and migration tests
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/database -run '^(TestHostAutoMigrateCreatesColumns_Postgres|TestMigrate_Postgres|TestClientWeeklyRenewMigration_Postgres|TestMigrate_LegacyBooleanVerifyPeerCertByNameIsBlanked_Postgres|TestClientKeepAlivePostgresMigrationPreservesLegacyScalars|TestPostgresModelSettled_TracksSchemaPresence|TestEnsureClientGroupRows_Postgres)$' -count=1 -v | tee /tmp/postgres-schema.log
|
|
# All must pass. Counting, not SKIP-matching: renaming a test would
|
|
# otherwise leave this step green while testing nothing.
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-schema.log || true)
|
|
if [ "$passed" -lt 7 ]; then
|
|
echo "expected at least 7 passing PostgreSQL schema tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL subscription Host tests
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/sub -run '^TestSubHosts_Postgres$' -count=1 -v | tee /tmp/postgres-hosts.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-hosts.log || true)
|
|
if [ "$passed" -ne 1 ]; then
|
|
echo "expected passing PostgreSQL Host coverage, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: PostgreSQL Telegram lookup and legacy migration tests
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^(TestGetClientTrafficTgBot_IndexedPostgres|TestGetClientTrafficTgBot_SettingsSerializationStyles)$' -count=1 -v | tee /tmp/postgres-tgbot.log
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-tgbot.log || true)
|
|
if [ "$passed" -ne 2 ]; then
|
|
echo "expected 2 passing PostgreSQL Telegram lookup tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# The migration tests write and drop their own tables, so they need a
|
|
# scratch database instead of the durable one the panel tests use.
|
|
postgres-migration:
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
postgres:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: xui_scratch
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd "pg_isready -U postgres -d xui_scratch"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
env:
|
|
XUI_TEST_PG_DSN: "host=127.0.0.1 port=5432 user=postgres password=postgres dbname=xui_scratch sslmode=disable"
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: actions/setup-go@v7
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
- name: Stub internal/web/dist for go:embed
|
|
run: mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
|
|
- name: PostgreSQL migration tests
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/database -run '^(TestMigrateData_CompositeKeyTableLargerThanBatch|TestMigrateData_PreservesFalseDefaultedColumns|TestMigrateData_FailedCopyLeavesDestinationUntouched|TestClientHwidSchemaPostgres)$' -count=1 -v | tee /tmp/postgres-migration.log
|
|
# Count passes rather than assert no SKIP: a renamed or deleted test
|
|
# prints "no tests to run" and exits 0, leaving the step green for nothing.
|
|
passed=$(grep -c -- '^--- PASS' /tmp/postgres-migration.log || true)
|
|
if [ "$passed" -lt 4 ]; then
|
|
echo "expected at least 4 passing PostgreSQL migration tests, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
- name: SQLite import host settings
|
|
run: |
|
|
set -o pipefail
|
|
go test ./internal/web/service -run '^TestImportSQLiteIntoPostgresHostSettings$' -count=1 -v | tee /tmp/postgres-import-host-settings.log
|
|
passed=$(grep -c -- '^--- PASS: TestImportSQLiteIntoPostgresHostSettings ' /tmp/postgres-import-host-settings.log || true)
|
|
if [ "$passed" -ne 1 ]; then
|
|
echo "expected the SQLite import integration test to pass, got $passed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
codegen:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: actions/setup-go@v7
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
- uses: actions/setup-node@v7
|
|
with:
|
|
node-version-file: .nvmrc
|
|
- name: Regenerate schemas, examples and OpenAPI
|
|
run: npm run gen
|
|
working-directory: frontend
|
|
- name: Fail if generated files are stale (run 'npm run gen' and commit)
|
|
run: git diff --exit-code -- frontend/src/generated frontend/public/openapi.json
|
|
- name: Fail if the docs spec is not the panel's
|
|
run: cmp frontend/public/openapi.json docs/public/openapi.json
|
|
|
|
govulncheck:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: actions/setup-go@v7
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
- name: Stub internal/web/dist for go:embed
|
|
run: mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
|
|
- name: Install govulncheck
|
|
run: go install golang.org/x/vuln/cmd/govulncheck@latest
|
|
- name: Run govulncheck
|
|
run: govulncheck ./...
|
|
|
|
# Race + shuffle hygiene gate: data races and order-dependent tests fail the build.
|
|
race:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: actions/setup-go@v7
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
- name: Stub internal/web/dist for go:embed
|
|
run: mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
|
|
- name: Race + shuffle
|
|
run: |
|
|
go list ./... | grep -v '/frontend/node_modules/' > /tmp/go-packages.txt
|
|
# internal/web/service runs ~10x slower under -race and overruns the 10m default.
|
|
mapfile -t go_packages < /tmp/go-packages.txt
|
|
go test -race -shuffle=on -count=1 -timeout 25m "${go_packages[@]}"
|
|
|
|
# A real master and node panel, each its own process, driven through node sync.
|
|
# A SKIP here means the binary was never handed over, so it fails the job.
|
|
node-e2e:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: actions/setup-go@v7
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
- name: Build legacy node protocol baseline
|
|
run: |
|
|
baseline_ref=c621ba9014a6aa21fd7c9ecf45655e44e24ebf13
|
|
git fetch --no-tags --depth=1 origin "$baseline_ref"
|
|
baseline_src=$(mktemp -d)
|
|
git archive "$baseline_ref" Makefile go.mod go.sum main.go internal scripts/install-amneziawg-kernel.sh | tar -x -C "$baseline_src"
|
|
(cd "$baseline_src" && make dist-stub && go build -o "$RUNNER_TEMP/x-ui-node-baseline" .)
|
|
echo "XUI_NODE_E2E_OLD_BINARY=$RUNNER_TEMP/x-ui-node-baseline" >> "$GITHUB_ENV"
|
|
- name: Master + node end to end
|
|
run: |
|
|
set -o pipefail
|
|
make node-e2e 2>&1 | tee /tmp/node-e2e.log
|
|
if grep -q -- '--- SKIP' /tmp/node-e2e.log; then echo "node-e2e skipped"; exit 1; fi
|
|
|
|
# The core pinned in go.mod as a real child process, driven over its gRPC API.
|
|
# A skip naming the binary means it was never handed over, so it fails the job.
|
|
xray-e2e:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: actions/setup-go@v7
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
- name: Real core end to end
|
|
run: |
|
|
set -o pipefail
|
|
make xray-e2e 2>&1 | tee /tmp/xray-e2e.log
|
|
if grep -q -- '_test.go:[0-9]*: .*XRAY_E2E_BINARY' /tmp/xray-e2e.log; then echo "a real-core test skipped"; exit 1; fi
|
|
|
|
# Brief native-fuzz smoke on the security-/parser-critical decoders. Each runs the
|
|
# generated corpus plus 30s of exploration; a crash here is a real input-handling bug.
|
|
fuzz-smoke:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: actions/setup-go@v7
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
- name: Stub internal/web/dist for go:embed
|
|
run: mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
|
|
- name: Fuzz critical parsers (smoke)
|
|
run: |
|
|
go test -run '^$' -fuzz 'FuzzParseLink$' -fuzztime=30s ./internal/util/link/
|
|
go test -run '^$' -fuzz 'FuzzDecodeCertPin$' -fuzztime=30s ./internal/web/runtime/
|
|
|
|
golangci:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: actions/setup-go@v7
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
- name: Stub internal/web/dist for go:embed
|
|
run: mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
|
|
- name: golangci-lint
|
|
uses: golangci/golangci-lint-action@v9
|
|
with:
|
|
# Pinned: "latest" let the lint result drift between runs, so the same
|
|
# commit could pass today and fail tomorrow on a new upstream release.
|
|
version: v2.15.0
|
|
|
|
# Lint the shell scripts and the workflows themselves. The three legacy
|
|
# scripts carry a warning backlog (unquoted expansions, masked return codes)
|
|
# and are gated on errors only; the scripts that are clean today are gated on
|
|
# everything.
|
|
shell-lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: actions/setup-go@v7
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
- name: actionlint
|
|
# The shellcheck integration is off: it reports the stylistic rules
|
|
# (SC2086, SC2046) that main's own workflows trip. The shell scripts
|
|
# the panel ships are linted by the shellcheck step below.
|
|
run: go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.12 -color -shellcheck=
|
|
- name: Install shellcheck
|
|
run: sudo apt-get update && sudo apt-get install -y shellcheck socat
|
|
- name: shellcheck
|
|
run: |
|
|
shellcheck --severity=style DockerInit.sh DockerEntrypoint.sh deploy/test/smoke-noninteractive.sh deploy/test/installer-panel-port.sh
|
|
shellcheck --severity=error install.sh update.sh x-ui.sh
|
|
shellcheck --severity=style -e SC1091 scripts/lib/ip-ssl.sh scripts/sync-ip-ssl-helpers.sh scripts/test/ip-ssl-*.sh
|
|
- name: IP certificate regressions (no ACME orders)
|
|
run: |
|
|
bash -n install.sh
|
|
bash -n x-ui.sh
|
|
bash scripts/sync-ip-ssl-helpers.sh --check
|
|
bash scripts/test/ip-ssl-test.sh
|
|
bash scripts/test/ip-ssl-entrypoint-test.sh
|
|
IP_SSL_LINUX_TEST=1 bash scripts/test/ip-ssl-listener-test.sh
|
|
bash scripts/test/ip-ssl-certificate-test.sh
|
|
- name: IP certificate lifecycle with upstream acme.sh (offline orders)
|
|
run: |
|
|
curl -fsSLo "$RUNNER_TEMP/acme-3.1.5.sh" https://raw.githubusercontent.com/acmesh-official/acme.sh/d5fc938d80e266dba3239f54cf4665432f17c00b/acme.sh
|
|
curl -fsSLo "$RUNNER_TEMP/acme-3.1.6.sh" https://raw.githubusercontent.com/acmesh-official/acme.sh/807da6498377ee5e0cf43a78091f46f12dc59a89/acme.sh
|
|
bash scripts/test/ip-ssl-acme-lifecycle-test.sh "$RUNNER_TEMP/acme-3.1.5.sh" "$RUNNER_TEMP/acme-3.1.6.sh"
|
|
- name: Installer panel port regression tests
|
|
run: bash deploy/test/installer-panel-port.sh
|
|
|
|
frontend:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: actions/setup-node@v7
|
|
with:
|
|
node-version-file: .nvmrc
|
|
cache: npm
|
|
cache-dependency-path: frontend/package-lock.json
|
|
- name: Install
|
|
run: npm ci
|
|
working-directory: frontend
|
|
- name: Lint
|
|
run: npm run lint
|
|
working-directory: frontend
|
|
- name: Format check
|
|
run: npm run format:check
|
|
working-directory: frontend
|
|
- name: Typecheck
|
|
run: npm run typecheck
|
|
working-directory: frontend
|
|
- name: Install Playwright Chromium (Storybook story tests)
|
|
run: npx playwright install --with-deps chromium
|
|
working-directory: frontend
|
|
- name: Test
|
|
run: npm test
|
|
working-directory: frontend
|
|
- name: Build
|
|
run: npm run build
|
|
working-directory: frontend
|
|
- name: Build Storybook
|
|
run: npm run build-storybook
|
|
working-directory: frontend
|
|
- name: Inbound keyboard and accessibility tree
|
|
working-directory: frontend
|
|
run: |
|
|
set -euo pipefail
|
|
./node_modules/.bin/vite preview --outDir storybook-static --host 127.0.0.1 --port 6006 > /tmp/inbound-preview.log 2>&1 &
|
|
preview_pid=$!
|
|
trap 'kill "$preview_pid" 2>/dev/null || true' EXIT
|
|
curl --retry 30 --retry-connrefused --retry-delay 1 --retry-max-time 45 -fsS http://127.0.0.1:6006/iframe.html > /dev/null
|
|
node tools/check-inbound-keyboard.mjs http://127.0.0.1:6006
|
|
- name: Audit
|
|
run: npm run audit
|
|
working-directory: frontend
|