ci(fa02): consolidated Windows SDK and trusted disposable five-service rollback/security gates [skip ci]
This commit is contained in:
1 parent
25650b95a7
commit
ab21605591
1 file changed
+163
-2
@@ -139,7 +139,7 @@ jobs:
|
||||
if: ${{ (github.event_name != 'pull_request_target' || (github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.ref == 'main')) && (github.event_name != 'workflow_dispatch' || github.event.inputs.p01_only != 'true' && (github.event_name != 'workflow_dispatch' || github.event.inputs.python_only != 'true')) }}
|
||||
runs-on: ubuntu-latest
|
||||
container: node:22-alpine
|
||||
timeout-minutes: 45
|
||||
timeout-minutes: 100
|
||||
steps:
|
||||
- name: CI-07 provision Docker Buildx CLI
|
||||
run: |
|
||||
@@ -174,11 +174,123 @@ jobs:
|
||||
docker buildx build --builder "$builder" --progress=plain --no-cache --load -f docker/Dockerfile.proxy -t "$tag-proxy" .
|
||||
docker image inspect "$tag-ingestion" "$tag-web" "$tag-proxy" >/dev/null
|
||||
echo DATASTACK_THREE_IMAGES_BUILD_PASS
|
||||
- name: FA02 checkout frozen previous tested source for disposable rollback
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
github-server-url: https://dev.ivib.cc
|
||||
persist-credentials: false
|
||||
ref: ea3b3038fbd8851613a80098e540346d47c62079
|
||||
path: fa02-baseline
|
||||
- name: FA02 isolated five-service startup, fixture restore and previous-image rollback
|
||||
run: |
|
||||
set -eu
|
||||
project="dsfa02${GITHUB_RUN_ID:-0}${GITHUB_RUN_ATTEMPT:-1}"
|
||||
candidate="datastack-p03-${GITHUB_SHA:-local}"
|
||||
previous="datastack-fa02-baseline-${GITHUB_RUN_ID:-0}"
|
||||
compose() { docker compose -f docker/docker-compose.yml -p "$project" "$@"; }
|
||||
if docker ps -aq --filter "label=com.docker.compose.project=$project" | grep -q .; then
|
||||
echo "FAIL_CLOSED: pre-existing Compose project $project"; exit 1
|
||||
fi
|
||||
for vol in "${project}_datastack-data" "${project}_pgdata" "${project}_redisdata"; do
|
||||
if docker volume inspect "$vol" >/dev/null 2>&1; then echo "FAIL_CLOSED: existing volume $vol"; exit 1; fi
|
||||
done
|
||||
# The daemon must not host known production services; no production containers or volumes are touched.
|
||||
if docker ps --format '{{.Names}}' | grep -Ev '^(GITEA-ACTIONS-TASK-|buildx_buildkit_)' | grep -Eiq 'coolify|traefik|production|readbox|zitplane'; then
|
||||
echo "FAIL_CLOSED: production-like containers found on Actions Docker host"; exit 1
|
||||
fi
|
||||
testdir="$(mktemp -d /tmp/datastack-fa02-XXXXXX)"
|
||||
created=0
|
||||
cleanup() {
|
||||
if [ "$created" -eq 1 ]; then
|
||||
compose down --volumes --remove-orphans >/dev/null 2>&1 || echo "RUN_OWNED_COMPOSE_CLEANUP_FAILED"
|
||||
fi
|
||||
rm -rf "$testdir"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
for svc in ingestion web proxy; do
|
||||
docker image inspect "$candidate-$svc" >/dev/null
|
||||
done
|
||||
# Use cached old accepted images when available; otherwise build the frozen prior source
|
||||
# inside a run-owned BuildKit builder without modifying its files or any live service.
|
||||
need_previous=0
|
||||
for svc in ingestion web proxy; do
|
||||
if ! docker image inspect "$previous-$svc" >/dev/null 2>&1; then need_previous=1; fi
|
||||
done
|
||||
if [ "$need_previous" -eq 1 ]; then
|
||||
baseline_builder="dsfa02rollback${GITHUB_RUN_ID:-0}"
|
||||
baseline_cleanup() { docker buildx rm --force "$baseline_builder" >/dev/null 2>&1 || true; }
|
||||
trap 'baseline_cleanup; cleanup' EXIT
|
||||
docker buildx create --name "$baseline_builder" --driver docker-container --use
|
||||
docker buildx inspect "$baseline_builder" --bootstrap
|
||||
for svc in ingestion web proxy; do
|
||||
dockerfile="server"
|
||||
if [ "$svc" = web ]; then dockerfile="web"; fi
|
||||
if [ "$svc" = proxy ]; then dockerfile="proxy"; fi
|
||||
docker buildx build --builder "$baseline_builder" --progress=plain --no-cache --load \
|
||||
-f "fa02-baseline/docker/Dockerfile.$dockerfile" -t "$previous-$svc" fa02-baseline
|
||||
done
|
||||
baseline_cleanup
|
||||
trap cleanup EXIT
|
||||
fi
|
||||
for svc in ingestion web proxy; do
|
||||
docker image tag "$candidate-$svc" "$project-$svc"
|
||||
done
|
||||
# Only disposable, generated secrets; never print secret values or use real production data.
|
||||
export SERVICE_REALBASE64_64_JWT="$(node -e "console.log(require('node:crypto').randomBytes(48).toString('base64'))")"
|
||||
export SERVICE_REALBASE64_64_ADMINSESSION="$(node -e "console.log(require('node:crypto').randomBytes(48).toString('base64'))")"
|
||||
export SERVICE_REALBASE64_64_ADMININSTALL="$(node -e "console.log(require('node:crypto').randomBytes(48).toString('base64'))")"
|
||||
export SERVICE_REALBASE64_64_INTERNAL="$(node -e "console.log(require('node:crypto').randomBytes(48).toString('base64'))")"
|
||||
export SERVICE_PASSWORD_64_POSTGRES="$(node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))")"
|
||||
export SERVICE_HEX_32_DATABASENAME="$(node -e "console.log(require('node:crypto').randomBytes(16).toString('hex'))")"
|
||||
export DATASTACK_ADMIN_EMAIL=fa02-ci@example.invalid
|
||||
export DATASTACK_CORS_ORIGINS=http://localhost.invalid
|
||||
docker compose -f docker/docker-compose.yml -p "$project" config --quiet
|
||||
created=1
|
||||
compose up -d --no-build --wait --wait-timeout 240
|
||||
compose ps
|
||||
for svc in postgres redis web ingestion proxy; do
|
||||
test "$(compose ps --status running -q "$svc" | wc -l)" -eq 1
|
||||
done
|
||||
echo DATASTACK_DISPOSABLE_FIVE_SERVICE_HEALTH_PASS
|
||||
# Disposable PostgreSQL backup and restore into a second, isolated database.
|
||||
compose exec -T postgres sh -c 'psql -q -U datastack "$POSTGRES_DB" -v ON_ERROR_STOP=1 -c "CREATE TABLE fa02_disposable_fixture (id integer PRIMARY KEY, message text NOT NULL); INSERT INTO fa02_disposable_fixture VALUES (1, '\''test-only'\'');"'
|
||||
compose exec -T postgres sh -c 'pg_dump -U datastack "$POSTGRES_DB"' > "$testdir/pg.sql"
|
||||
test -s "$testdir/pg.sql"
|
||||
compose exec -T postgres createdb -U datastack fa02_disposable_restore
|
||||
compose exec -T postgres psql -q -v ON_ERROR_STOP=1 -U datastack -d fa02_disposable_restore < "$testdir/pg.sql"
|
||||
restored="$(compose exec -T postgres psql -At -U datastack -d fa02_disposable_restore -c 'SELECT message FROM fa02_disposable_fixture WHERE id = 1')"
|
||||
test "$restored" = test-only
|
||||
echo DATASTACK_DISPOSABLE_POSTGRES_BACKUP_RESTORE_PASS
|
||||
# Redis AOF and CSV storage fixtures: no user/production records.
|
||||
compose exec -T redis redis-cli SET fa02:disposable:probe stable-fixture >/dev/null
|
||||
compose exec -T redis redis-cli SAVE >/dev/null
|
||||
compose exec -T ingestion sh -c 'mkdir -p /app/storage/data/fa02-disposable && printf "clientId,eventId,timestamp,payload\nfa02,1,now,test-only\n" > /app/storage/data/fa02-disposable/probe.csv'
|
||||
compose exec -T ingestion cat /app/storage/data/fa02-disposable/probe.csv > "$testdir/csv.bak"
|
||||
compose exec -T web cmp /app/storage/data/fa02-disposable/probe.csv /app/storage/data/fa02-disposable/probe.csv
|
||||
compose exec -T ingestion rm /app/storage/data/fa02-disposable/probe.csv
|
||||
compose exec -T ingestion sh -c 'cat > /app/storage/data/fa02-disposable/probe.csv' < "$testdir/csv.bak"
|
||||
test "$(compose exec -T web sha256sum /app/storage/data/fa02-disposable/probe.csv | cut -d ' ' -f1)" = "$(sha256sum "$testdir/csv.bak" | cut -d ' ' -f1)"
|
||||
compose restart redis
|
||||
compose up -d --no-build --wait --wait-timeout 240
|
||||
test "$(compose exec -T redis redis-cli GET fa02:disposable:probe | tr -d '\r')" = stable-fixture
|
||||
echo DATASTACK_DISPOSABLE_REDIS_CSV_RECOVERY_PASS
|
||||
# Roll back only the disposable Compose project's application-image tags to the
|
||||
# accepted frozen baseline; fixtures and Docker host production resources untouched.
|
||||
for svc in ingestion web proxy; do
|
||||
docker image tag "$previous-$svc" "$project-$svc"
|
||||
done
|
||||
compose up -d --no-build --force-recreate --wait --wait-timeout 240
|
||||
test "$(compose exec -T redis redis-cli GET fa02:disposable:probe | tr -d '\r')" = stable-fixture
|
||||
test "$(compose exec -T ingestion sha256sum /app/storage/data/fa02-disposable/probe.csv | cut -d ' ' -f1)" = "$(sha256sum "$testdir/csv.bak" | cut -d ' ' -f1)"
|
||||
for svc in postgres redis web ingestion proxy; do
|
||||
test "$(compose ps --status running -q "$svc" | wc -l)" -eq 1
|
||||
done
|
||||
echo DATASTACK_DISPOSABLE_PREVIOUS_IMAGE_ROLLBACK_PASS
|
||||
|
||||
windows-compatibility:
|
||||
if: ${{ (github.event_name != 'pull_request_target' || (github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.ref == 'main')) && (github.event_name != 'workflow_dispatch' || github.event.inputs.quality_only != 'true' && (github.event_name != 'workflow_dispatch' || github.event.inputs.python_only != 'true')) }}
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 25
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -210,6 +322,28 @@ jobs:
|
||||
$ErrorActionPreference = 'Stop'
|
||||
npx.cmd --yes tsx@4.20.6 --test tests/files-manager.test.ts
|
||||
if ($LASTEXITCODE -ne 0) { throw 'FF01 Windows Files Manager regression failed' }
|
||||
- name: FA02 Windows Python SDK full acceptance
|
||||
shell: powershell
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$venv = Join-Path $env:RUNNER_TEMP 'datastack-fa02-python'
|
||||
python -m venv $venv
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Windows Python venv creation failed' }
|
||||
$py = Join-Path $venv 'Scripts\python.exe'
|
||||
& $py -m pip install -e ./sdk/python/datastack -e ./sdk-python
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Windows SDK install failed' }
|
||||
& $py -m compileall -q ./sdk/python/datastack ./sdk-python
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Windows SDK compile failed' }
|
||||
& $py -m unittest discover -s tests -p '*_test.py' -v
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Windows SDK regression failed' }
|
||||
Write-Output 'DATASTACK_FA02_WINDOWS_PYTHON_PASS'
|
||||
- name: FA02 Windows ESLint acceptance
|
||||
shell: powershell
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
npm run lint
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Windows ESLint failed' }
|
||||
Write-Output 'DATASTACK_FA02_WINDOWS_ESLINT_PASS'
|
||||
|
||||
security-audit:
|
||||
if: ${{ (github.event_name != 'pull_request_target' || (github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.ref == 'main')) && (github.event_name != 'workflow_dispatch' || github.event.inputs.p01_only != 'true' && (github.event_name != 'workflow_dispatch' || github.event.inputs.python_only != 'true')) }}
|
||||
@@ -262,3 +396,30 @@ jobs:
|
||||
NODE
|
||||
git diff --exit-code -- package.json package-lock.json
|
||||
echo DATASTACK_SECURITY_TRIAGE_INVENTORY_PASS
|
||||
- name: FA02 verify installed older-major security backports and exact lock
|
||||
run: |
|
||||
set -eu
|
||||
npm ci --no-audit --no-fund
|
||||
for patch in patches/cloudcmd-got-security.patch patches/cloudcmd-glob-security.patch patches/cloudcmd-minimatch-security.patch patches/cloudcmd-file-type-security.patch; do
|
||||
git apply --reverse --check "$patch"
|
||||
echo DATASTACK_SECURITY_VERIFIED_BACKPORT "$patch"
|
||||
done
|
||||
node <<'NODE'
|
||||
const fs = require('node:fs');
|
||||
const assert = require('node:assert/strict');
|
||||
const pkgs = [
|
||||
['got@10.7.0', 'node_modules/got/dist/source/request-as-event-emitter.js', 'Cannot redirect to UNIX socket'],
|
||||
['glob@10.5.0', 'node_modules/glob/dist/commonjs/walker.js', 'return cb()'],
|
||||
['minimatch@9.0.9', 'node_modules/glob/node_modules/minimatch/dist/commonjs/index.js', 'braceExpandMax'],
|
||||
['minimatch@10.2.6', 'node_modules/onezip/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js', 'braceExpandMax'],
|
||||
['file-type@16.5.4 join-io', 'node_modules/join-io/node_modules/ponse/node_modules/file-type/core.js', 'previousPosition'],
|
||||
['file-type@16.5.4 restbox', 'node_modules/restbox/node_modules/ponse/node_modules/file-type/core.js', 'previousPosition'],
|
||||
];
|
||||
for (const [pkg, path, needle] of pkgs) {
|
||||
assert.ok(fs.readFileSync(path, 'utf8').includes(needle), 'missing patched marker: ' + pkg);
|
||||
console.log('FA02_PATCHED_EXECUTABLE_SOURCE_VERIFIED', pkg);
|
||||
}
|
||||
console.log('FA02_NPM_ADVISORY_METADATA_MAY_STILL_FLAG_OLDER_VERSIONS');
|
||||
NODE
|
||||
git diff --exit-code -- package.json package-lock.json
|
||||
echo DATASTACK_FA02_SECURITY_SOURCE_AND_LOCK_GATE_PASS
|
||||
Reference in new issue
Block a user