diff --git a/.github/workflows/client-participation-alpha-ci.yml b/.github/workflows/client-participation-alpha-ci.yml index 4b88d49387..1d25a51b2d 100644 --- a/.github/workflows/client-participation-alpha-ci.yml +++ b/.github/workflows/client-participation-alpha-ci.yml @@ -28,25 +28,8 @@ jobs: cache: "npm" cache-dependency-path: client-participation-alpha/package-lock.json - - name: Install dependencies - run: npm ci - working-directory: client-participation-alpha - - - name: Check formatting - run: npm run format -- --check - working-directory: client-participation-alpha - - - name: Run linter - run: npm run lint - working-directory: client-participation-alpha - - - name: Run tests with coverage - run: npm run test:coverage - working-directory: client-participation-alpha - - - name: Build - run: npm run build - working-directory: client-participation-alpha + - name: Install, check and test (ci/local/client-alpha.sh) + run: make check-client-alpha - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 diff --git a/.github/workflows/collective-statement-recordings.yml b/.github/workflows/collective-statement-recordings.yml index f881eddcef..3ae136d162 100644 --- a/.github/workflows/collective-statement-recordings.yml +++ b/.github/workflows/collective-statement-recordings.yml @@ -36,30 +36,18 @@ jobs: fetch-depth: 0 persist-credentials: false - name: The collective-statement recordings never change together with the code they record - run: sh ci/collective_statement_golden_guard.sh "origin/${{ github.base_ref }}" + env: + BASE_REF: origin/${{ github.base_ref }} + run: make check-collective-statement-guard replay: runs-on: ubuntu-24.04 timeout-minutes: 20 - services: - postgres: - image: postgres:17.11@sha256:f4c66b820c6f974249089d3d16d86a3698eae11e8746eb6644b2271031e91232 - env: - POSTGRES_PASSWORD: generatedlocal - ports: ["127.0.0.1:5481:5432"] - options: >- - --health-cmd "pg_isready -U postgres" - --health-interval 2s --health-timeout 2s --health-retries 30 steps: - uses: actions/checkout@v4 with: persist-credentials: false - # Started by hand rather than as a service: -sharedDb needs a command - # argument, and without it DynamoDB Local keys its data by access key. - - name: Start DynamoDB Local - run: docker run -d --name csrec-dynamodb -p 127.0.0.1:8481:8000 amazon/dynamodb-local:3.3.1@sha256:ff89bd48ff32cd8d9be5fee8873b65b8854dc408f1afe881be6eb00247bc0dab -jar DynamoDBLocal.jar -sharedDb -inMemory - - uses: actions/setup-node@v4 with: # The recordings were made on this Node; V8's error wording can @@ -72,33 +60,9 @@ jobs: with: python-version: "3.12" - - name: Install server dependencies and the reset routine's boto3 (delphi's locked versions) - run: | - npm ci --prefix server --no-audit --no-fund - python -m pip install --quiet boto3==1.34.70 botocore==1.34.162 s3transfer==0.10.4 - - - name: The harness's own rules (expected differences, refusal of foreign stores) - working-directory: server - run: node --test characterization/collective-statement/expected.test.cjs characterization/collective-statement/safety.test.cjs - - - name: Replay every recorded case against the current routes - working-directory: server - env: - CSREC_PG_ADMIN_URL: postgres://postgres:generatedlocal@127.0.0.1:5481/postgres - DYNAMODB_ENDPOINT: http://127.0.0.1:8481 - CSREC_PYTHON: python - TZ: UTC - run: node characterization/collective-statement/main.cjs replay - - - name: Every listed mutation of the route fails exactly its named cases - working-directory: server - env: - CSREC_PG_ADMIN_URL: postgres://postgres:generatedlocal@127.0.0.1:5481/postgres - DYNAMODB_ENDPOINT: http://127.0.0.1:8481 - CSREC_PYTHON: python - TZ: UTC - run: node characterization/collective-statement/mutations.cjs - - - name: Remove DynamoDB Local - if: always() - run: docker rm -f csrec-dynamodb + # PostgreSQL 17.11 (host port 5481) and DynamoDB Local (8481), both pinned + # by digest, the server modules, the reset routine's boto3 (delphi's locked + # versions), the harness's own rules, the replay and the mutation check live + # in ci/local/collective-statement.sh: `make check-collective-statement`. + - name: Harness rules, replay of every recorded case, every listed mutation + run: make check-collective-statement diff --git a/.github/workflows/cypress-tests.yml b/.github/workflows/cypress-tests.yml index bb7313c280..e72e7f67ae 100644 --- a/.github/workflows/cypress-tests.yml +++ b/.github/workflows/cypress-tests.yml @@ -34,159 +34,15 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Install mkcert - run: | - # Install mkcert for certificate generation - curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64" - chmod +x mkcert-v*-linux-amd64 - sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert - - # Install CA in system trust store - mkcert -install - - - name: Generate certificates - run: | - # Create certificate directory in workspace (not home directory) - mkdir -p ./.simulacrum/certs - cd ./.simulacrum/certs - - # Generate certificates for all required hostnames - mkcert -cert-file localhost.pem -key-file localhost-key.pem \ - localhost 127.0.0.1 ::1 oidc-simulator host.docker.internal - - # Copy mkcert root CA for other containers - cp "$(mkcert -CAROOT)/rootCA.pem" ./rootCA.pem - - # List generated files for debugging - echo "Generated certificates:" - ls -la - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Create test.env with CI-specific paths - run: | - # Update AUTH_CERTS_PATH to use workspace-relative path - sed -i 's|AUTH_CERTS_PATH=.*|AUTH_CERTS_PATH=./.simulacrum/certs|' test.env - - # Copy test.env to .env for docker-compose variable interpolation - cp test.env .env - - # Show relevant env vars for debugging - echo "Auth-related environment variables:" - grep -E "AUTH_|CERT|DATABASE_URL|POSTGRES_" test.env || true - - - name: Build Docker images - run: | - # Build postgres with --no-cache to ensure latest migrations are used - # Docker layer caching can cause old migration files to persist - docker compose -f docker-compose.test.yml --env-file test.env build --no-cache postgres - - # Build remaining services (caching OK for these) - docker compose -f docker-compose.test.yml --env-file test.env build - - - name: Start services - run: | - # Start all services in detached mode - docker compose -f docker-compose.test.yml --env-file test.env up -d - - # Wait for services to be ready - echo "Waiting for services to start..." - sleep 30 - - # Show running containers - docker compose -f docker-compose.test.yml ps - - - name: Run Database Migrations - env: - DATABASE_URL: postgres://postgres:PdwPNS2mDN73Vfbc@localhost:5432/polis-test - POSTGRES_DB: polis-test - POSTGRES_HOST: postgres:5432 - POSTGRES_PASSWORD: PdwPNS2mDN73Vfbc - POSTGRES_PORT: 5432 - POSTGRES_USER: postgres - run: | - echo "Installing postgres-client..." - sudo apt-get update && sudo apt-get install -y postgresql-client - - echo "Making migration script executable..." - chmod +x server/bin/run-migrations.sh - - echo "Running migrations..." - ./server/bin/run-migrations.sh - - - name: Check service health - run: | - # Check if key services are responding - echo "Checking postgres..." - docker compose -f docker-compose.test.yml exec -T postgres pg_isready -U postgres || true - - echo "Checking oidc-simulator..." - curl -k -f https://localhost:3000/.well-known/jwks.json || true - - echo "Checking server API..." - curl -f http://localhost/api/v3/participationInit || true - - - name: Show postgres initialization logs - if: always() - run: | - echo "=== Postgres container logs (shows migration execution) ===" - docker compose -f docker-compose.test.yml logs postgres | head -200 - - - name: Show service logs - if: always() - run: | - # Show logs from critical services for debugging - echo "=== NGINX Proxy logs ===" - docker compose -f docker-compose.test.yml logs nginx-proxy || true - - echo "=== OIDC Simulator logs ===" - docker compose -f docker-compose.test.yml logs oidc-simulator || true - - echo "=== Server logs ===" - docker compose -f docker-compose.test.yml logs server || true - - - name: Run auth setup test - run: | - cd e2e - npm install dotenv - - # Copy test.env to e2e directory for Cypress to read - cp ../test.env .env - - # Update AUTH_CERTS_PATH to be relative to e2e directory - sed -i 's|AUTH_CERTS_PATH=.*|AUTH_CERTS_PATH=../.simulacrum/certs|' .env - - # Set environment variables for the test script - export AUTH_CERTS_PATH=../.simulacrum/certs - export CYPRESS_BASE_URL=http://localhost - export AUTH_ISSUER=https://localhost:3000/ - - # Run the validation script - node test-auth-setup.js - - - name: Install Cypress dependencies - run: | - cd e2e - npm ci - + # Certificates, the edited test.env, the image builds (postgres without the + # cache), the stack with readiness waits, the migration re-run, the auth + # setup check, Cypress and teardown all live in ci/local/e2e.sh, so + # `make check-e2e` gives the same verdict on any Docker host. - name: Run Cypress E2E tests - run: | - cd e2e - - # Set environment variables for Cypress - export NODE_EXTRA_CA_CERTS=$(pwd)/../.simulacrum/certs/rootCA.pem - export CYPRESS_BASE_URL=http://localhost - export AUTH_ISSUER=https://localhost:3000/ - export AUTH_CERTS_PATH=$(pwd)/../.simulacrum/certs - - # Run all Cypress tests - npm test - - - name: Show math engine logs - if: failure() - run: | - docker compose -f docker-compose.test.yml logs --tail 300 math-python || true + run: make check-e2e - name: Upload Cypress screenshots if: failure() @@ -203,8 +59,3 @@ jobs: name: cypress-videos path: e2e/cypress/videos if-no-files-found: ignore - - - name: Clean up - if: always() - run: | - docker compose -f docker-compose.test.yml down -v \ No newline at end of file diff --git a/.github/workflows/delphi-characterization.yml b/.github/workflows/delphi-characterization.yml index 78d3d6349c..4d5ac89596 100644 --- a/.github/workflows/delphi-characterization.yml +++ b/.github/workflows/delphi-characterization.yml @@ -26,25 +26,11 @@ jobs: replay: runs-on: ubuntu-24.04 timeout-minutes: 20 - services: - postgres: - image: postgres:17.11 - env: - POSTGRES_PASSWORD: generatedlocal - ports: ["5472:5432"] - options: >- - --health-cmd "pg_isready -U postgres" - --health-interval 2s --health-timeout 2s --health-retries 30 steps: - uses: actions/checkout@v4 with: persist-credentials: false - # Started by hand rather than as a service: -sharedDb needs a command - # argument, and without it DynamoDB Local keys its data by access key. - - name: Start DynamoDB Local - run: docker run -d --name p2zero-dynamodb -p 127.0.0.1:8472:8000 amazon/dynamodb-local:3.3.1@sha256:ff89bd48ff32cd8d9be5fee8873b65b8854dc408f1afe881be6eb00247bc0dab -jar DynamoDBLocal.jar -sharedDb -inMemory - - uses: actions/setup-node@v4 with: node-version: "22" @@ -55,31 +41,9 @@ jobs: with: python-version: "3.12" - - name: Install server dependencies - working-directory: server - run: npm ci --no-audit --no-fund - - - name: Codec golden test (Python writes, reads the file Node wrote) - working-directory: delphi - run: | - python -m pip install --quiet pyyaml - python -m unittest tests.test_delphi_storage_codec -v - - - name: Codec golden test (Node reads the files Python wrote, writes the cross file) - working-directory: server - run: npx jest --config characterization/delphi/jest.codec.config.json - - - name: Fixtures regenerate byte for byte - run: python3 server/characterization/delphi/generate.py --check - - - name: Replay every recorded case against the current routes - working-directory: server - env: - P2ZERO_PG_ADMIN_URL: postgres://postgres:generatedlocal@127.0.0.1:5472/postgres - DYNAMODB_ENDPOINT: http://127.0.0.1:8472 - TZ: UTC - run: node characterization/delphi/main.cjs replay - - - name: Remove DynamoDB Local - if: always() - run: docker rm -f p2zero-dynamodb + # PostgreSQL 17.11 (host port 5472) and DynamoDB Local pinned by digest + # (8472, -sharedDb -inMemory), the server modules, the codec tests in both + # languages, the fixture regeneration check and the replay live in + # ci/local/delphi-characterization.sh: `make check-delphi-characterization`. + - name: Codec, fixtures and replay of every recorded case + run: make check-delphi-characterization diff --git a/.github/workflows/jest-client-admin-test.yml b/.github/workflows/jest-client-admin-test.yml index d8b51e2738..b531431792 100644 --- a/.github/workflows/jest-client-admin-test.yml +++ b/.github/workflows/jest-client-admin-test.yml @@ -24,13 +24,8 @@ jobs: cache: 'npm' cache-dependency-path: client-admin/package-lock.json - - name: Install dependencies - run: npm ci - working-directory: client-admin - - - name: Run Jest tests with coverage - run: npm run test:coverage - working-directory: client-admin + - name: Install, check and test (ci/local/client-admin.sh) + run: make check-client-admin - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 diff --git a/.github/workflows/jest-client-report-test.yml b/.github/workflows/jest-client-report-test.yml index 9af47e58ef..3c17c23b54 100644 --- a/.github/workflows/jest-client-report-test.yml +++ b/.github/workflows/jest-client-report-test.yml @@ -22,10 +22,5 @@ jobs: with: node-version: '24' - - name: Install dependencies - run: npm install - working-directory: client-report - - - name: Run Jest tests - run: npm test - working-directory: client-report \ No newline at end of file + - name: Install and run the Jest tests (ci/local/client-report.sh) + run: make check-client-report diff --git a/.github/workflows/jest-server-test.yml b/.github/workflows/jest-server-test.yml index fe54f8593e..b259aaf18b 100644 --- a/.github/workflows/jest-server-test.yml +++ b/.github/workflows/jest-server-test.yml @@ -32,7 +32,9 @@ jobs: fetch-depth: 0 - name: The vote-path golden never changes together with server code - run: sh ci/vote_path_golden_guard.sh "origin/${{ github.base_ref }}" + env: + BASE_REF: origin/${{ github.base_ref }} + run: make check-vote-path-guard server-integration-tests: runs-on: ubuntu-latest @@ -41,89 +43,12 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Install mkcert - run: | - # Install mkcert for certificate generation - curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64" - chmod +x mkcert-v*-linux-amd64 - sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert - - # Install CA in system trust store - mkcert -install - - - name: Generate certificates - run: | - # Create certificate directory in workspace (not home directory) - mkdir -p ./.simulacrum/certs - cd ./.simulacrum/certs - - # Generate certificates for all required hostnames - mkcert -cert-file localhost.pem -key-file localhost-key.pem \ - localhost 127.0.0.1 ::1 oidc-simulator host.docker.internal - - # Copy mkcert root CA to the certs directory for Docker containers - cp "$(mkcert -CAROOT)/rootCA.pem" ./rootCA.pem - - # List generated files for debugging - echo "Generated certificates:" - ls -la - + # Certificates, the edited test.env, the service list, readiness waits, the + # jest environment and teardown all live in ci/local/server-integration.sh, + # so `make check-server-integration` gives the same verdict on any Docker host. - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Create test.env with CI-specific paths - run: | - # Update AUTH_CERTS_PATH to use workspace-relative path - sed -i 's|AUTH_CERTS_PATH=.*|AUTH_CERTS_PATH=./.simulacrum/certs|' test.env - # Update JWKS_URI to use localhost for OIDC simulator - sed -i 's|JWKS_URI=.*|JWKS_URI=https://localhost:3000/.well-known/jwks.json|' test.env - - # Copy test.env to .env for docker-compose variable interpolation - cp test.env .env - - # Also copy test.env to server directory for the test environment - cp test.env server/.env - - # Show relevant env vars for debugging - echo "Environment variables:" - grep -E "AUTH_|CERT|DATABASE_URL|POSTGRES_|JWT_|JWKS_URI" test.env || true - - - name: Build Docker images - run: | - # Build only the services these tests need (tests run on host). - # The math engine (math-python) is intentionally excluded: the server - # integration tests insert math_* rows directly and gate all live-math - # assertions behind a hasMathData flag, so they pass with or without it. - docker compose -f docker-compose.test.yml --env-file test.env build \ - postgres file-server ses-local oidc-simulator dynamodb - - - name: Start services - run: | - # Start only required services in detached mode (exclude server + math-python) - docker compose -f docker-compose.test.yml --env-file test.env up -d \ - postgres file-server ses-local oidc-simulator dynamodb minio minio-init - - # Wait for services to be ready - echo "Waiting for services to start..." - sleep 30 - - # Show running containers - docker compose -f docker-compose.test.yml ps - - - name: Check service health - run: | - # Check if key services are responding - echo "Checking postgres..." - docker compose -f docker-compose.test.yml exec -T postgres pg_isready -U postgres || true - - echo "Checking oidc-simulator..." - curl -k -f https://localhost:3000/.well-known/jwks.json || true - - echo "Checking DynamoDB..." - curl -f http://localhost:8000 || true - # Alternative check using AWS CLI if available - aws dynamodb list-tables --endpoint-url http://localhost:8000 --region us-east-1 2>/dev/null || true - - name: Setup Node.js uses: actions/setup-node@v4 with: @@ -131,36 +56,14 @@ jobs: cache: 'npm' cache-dependency-path: server/package-lock.json - - name: Install server dependencies - run: | - cd server - npm ci - - name: Generated contract files match the TypeBox source - run: | - # Fails when a committed generated file (server, client-participation-alpha, - # client-report) differs from what server/src/contracts would generate. - # Fix with `npm run contract:generate` in server/ and commit the result. - cd server - npm run contract:check + # Fails when a committed generated file (server, client-participation-alpha, + # client-report) differs from what server/src/contracts would generate. + # Fix with `npm run contract:generate` in server/ and commit the result. + run: make check-contracts - name: Run server integration tests - run: | - cd server - - NODE_EXTRA_CA_CERTS=$(pwd)/../.simulacrum/certs/rootCA.pem \ - CI=true \ - NODE_ENV=test \ - DATABASE_URL=postgres://postgres:PdwPNS2mDN73Vfbc@localhost:5432/polis-test \ - STATIC_FILES_HOST=localhost \ - DYNAMODB_ENDPOINT=http://localhost:8000 \ - SES_ENDPOINT=http://localhost:8005 \ - AWS_S3_ENDPOINT=http://localhost:9000 \ - AWS_S3_BUCKET_NAME=polis-delphi \ - AWS_ACCESS_KEY_ID=DUMMYIDEXAMPLE \ - AWS_SECRET_ACCESS_KEY=DUMMYEXAMPLEKEY \ - AWS_REGION=us-east-1 \ - npm test -- --ci --coverage --maxWorkers=2 + run: make check-server-integration - name: Upload test coverage if: always() @@ -169,21 +72,3 @@ jobs: name: coverage-report path: server/coverage if-no-files-found: ignore - - - name: Show service logs - if: failure() - run: | - # Show logs from critical services for debugging - echo "=== OIDC Simulator logs ===" - docker compose -f docker-compose.test.yml logs oidc-simulator | tail -100 - - echo "=== Postgres logs ===" - docker compose -f docker-compose.test.yml logs postgres | tail -100 - - echo "=== DynamoDB logs ===" - docker compose -f docker-compose.test.yml logs dynamodb | tail -100 - - - name: Clean up - if: always() - run: | - docker compose -f docker-compose.test.yml down -v diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 88e6843ede..1df7f56d0f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -32,34 +32,7 @@ jobs: restore-keys: | ${{ runner.os }}-node- - - name: "Install & Build: client-admin" - working-directory: client-admin - run: npm install - - - name: "ESLint: client-admin" - working-directory: client-admin - run: npm run lint - - - name: "Install & Build: server" - working-directory: server - run: npm install - - - name: "ESLint: server" - working-directory: server - run: npm run lint - - - name: "Install & Build: client-report" - working-directory: client-report - run: npm install - - - name: "ESLint: client-report" - working-directory: client-report - run: npm run lint - - - name: "Install & Build: e2e" - working-directory: e2e - run: npm install - - - name: "ESLint: e2e" - working-directory: e2e - run: npm run lint + # Install and ESLint client-admin, server, client-report and e2e, in that + # order: ci/local/lint.sh (`make check-lint`). + - name: "Install and ESLint: client-admin, server, client-report, e2e" + run: make check-lint diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 938a58c270..2777094a2f 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -45,141 +45,20 @@ jobs: echo "Disk space after cleanup:" df -h - - name: 2. Create .env file for CI - run: | - if [ -f "test.env" ]; then - cp test.env .env - echo "Using test.env for CI." - else - echo "::error::test.env file not found!" - exit 1 - fi - - # Add hostnames for container-to-container networking - # The 'delphi' service in 'docker-compose.test.yml' reads these - echo "POSTGRES_HOST=postgres" >> .env - echo "DYNAMODB_ENDPOINT=http://dynamodb:8000" >> .env - echo "AWS_S3_ENDPOINT=http://minio:9000" >> .env - # BuildKit is required by `RUN --mount=type=cache` in the npm Dockerfiles. - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: 3. Build Docker images - run: | - # Build all services in the test file (including delphi) - docker compose -f docker-compose.test.yml --env-file .env build - - - name: 4. Start all services - run: | - # Start all services (including delphi) in detached mode - # The 'delphi' container will start and run 'tail -f /dev/null' - docker compose -f docker-compose.test.yml --env-file .env up -d - - echo "Waiting for services to be healthy..." - sleep 20 # Wait for containers to start - docker compose -f docker-compose.test.yml ps - - - name: 5. Check service health - run: | - # Wait for postgres to be ready - echo "Checking postgres..." - docker compose -f docker-compose.test.yml exec -T postgres \ - bash -c 'until pg_isready -U $POSTGRES_USER; do sleep 5; done' - echo "Postgres is ready." - - # The opt-in Postgres integration tests (require_polis_postgres) run here - # against the compose `postgres` service, whose image bakes the polis - # migrations (server/postgres/migrations/*.sql via docker-entrypoint-initdb.d), - # so the votes / votes_latest_unique schema + on_vote_insert_update_unique_table - # rule are already applied. The pytest step exports POLIS_TEST_POSTGRES_URL; - # the cold-start generator under test is already baked into the delphi image - # (Dockerfile `COPY scripts/ ./scripts/`), built from this checkout. - - name: 6. Run Delphi Pytest - run: | - echo "Copying test files into container..." - docker compose -f docker-compose.test.yml cp delphi/tests delphi:/app/tests - docker compose -f docker-compose.test.yml cp delphi/real_data delphi:/app/real_data - echo "Copying coverage script into container..." - docker compose -f docker-compose.test.yml cp delphi/generate_coverage_md.py delphi:/app/generate_coverage_md.py - echo "Copying script to be tested into container..." - docker compose -f docker-compose.test.yml cp delphi/polismath/run_math_pipeline.py delphi:/app/run_math_pipeline.py - docker compose -f docker-compose.test.yml cp delphi/umap_narrative delphi:/app/umap_narrative - echo "Copying the compose files into container..." - # tests/test_compose_math_env.py asserts that every stack's delphi service - # receives the MATH_ENV its math service writes under. /app/tests has no - # checkout above it, so put the two files it parses beside it; without - # them the test skips instead of guarding the report pipeline's math_env. - docker compose -f docker-compose.test.yml cp docker-compose.yml delphi:/app/docker-compose.yml - docker compose -f docker-compose.test.yml cp docker-compose.test.yml delphi:/app/docker-compose.test.yml - - # Wire a checkout-shaped root so delphi/tests/scripts collects AND RUNS the - # pure-Python inventory sweep + the DB-free gate unit tests (the conftest - # locator resolves POLIS_CHECKOUT_DIR). The scan inputs are copied in as REAL, - # traversable directories (NOT symlinks — os.walk would skip those). The set - # of inputs is DERIVED from the scanner's own declaration - # (`--print-scan-inputs`) so it can never diverge from what the sweep scans; - # a test asserts every declared input is present under /app/projgate. - echo "Wiring projection-gate scan inputs (derived from the scanner declaration)..." - docker compose -f docker-compose.test.yml exec -T delphi mkdir -p /app/projgate - # Iterate a CAPTURED list, not `... | while read`: a `docker compose exec` - # inside a while-read loop drains the piped stdin and truncates the list to - # its first item (observed: only server/src copied). - # Recordings tests also load the packer and its digest helper from ci/. - # battery_coverage.py is already included in the declared delphi/scripts. - # test_compose_math_env.py reads the deploy hook's per-role compose lines. - # test_before_install_hook.py runs scripts/before_install.sh against a fake docker. - # test_compose_math_env.py also reads the stop hook's per-role stop lines. - # Representative payload tests import the box planner/gate and their - # helpers from this same checkout root; keep their relative paths intact. - # Light-shadow triage tests also import the compare/triage modules. - for rel in $(python3 delphi/scripts/projection_inventory.py --print-scan-inputs) \ - ci/p022_recordings_manifest.py ci/p022_battery_digest.py \ - ci/private_cert/images/gate.py ci/private_cert/images/probe.py \ - ci/private_cert/images/attribution.py ci/private_cert/images/diagnostic_projection.py ci/private_cert/images/selection_context.py \ - ci/private_cert/images/g12.py ci/private_cert/images/near_ties.py ci/private_cert/control.py \ - ci/private_cert/image_admission.py ci/probe_box/receipt.py \ - ci/probe_box/contracts.py ci/probe_box/light_shadow.py ci/probe_box/light_shadow_queries.py \ - ci/private_cert/images/light_shadow_compare.py ci/private_cert/images/light_shadow_triage.py \ - ci/private_cert/images/recipe.py \ - scripts/after_install.sh scripts/before_install.sh scripts/application_stop.sh; do - docker compose -f docker-compose.test.yml exec -T delphi mkdir -p "/app/projgate/$(dirname "$rel")" - docker compose -f docker-compose.test.yml cp "$rel" "delphi:/app/projgate/$rel" \ - || { echo "failed to copy scan input: $rel"; exit 1; } - done - - echo "Running tests and generating coverage report..." - docker compose \ - -f docker-compose.test.yml \ - --env-file .env \ - exec -T \ - -e AWS_DEFAULT_REGION=us-east-1 \ - -e AWS_REGION=us-east-1 \ - -e AWS_ACCESS_KEY_ID=dummy \ - -e AWS_SECRET_ACCESS_KEY=dummy \ - -e SKIP_GOLDEN=1 \ - -e POSTGRES_CONNECT_TIMEOUT=5 \ - -e POLIS_CHECKOUT_DIR=/app/projgate \ - delphi \ - bash -c " \ - set -e; \ - echo '--- Setting up DynamoDB Tables ---'; \ - python create_dynamodb_tables.py --region us-east-1; \ - echo '--- Running Pytest ---'; \ - export PYTHONPATH=\$PYTHONPATH:/app; \ - export POLIS_TEST_POSTGRES_URL=\"postgresql://\$DATABASE_USER:\$DATABASE_PASSWORD@\$DATABASE_HOST/\$DATABASE_NAME\"; \ - pytest --cov=polismath --cov=run_math_pipeline --cov=./umap_narrative --cov-report=xml:/app/coverage.xml /app/tests --ignore=/app/tests/test_pakistan_conversation.py - echo '--- Generating Coverage Comment Text ---'; \ - python /app/generate_coverage_md.py > /app/coverage-comment.md \ - " - - - name: 7. Copy coverage report from container - if: success() - run: | - echo "Copying coverage-comment.md from delphi container..." - docker compose -f docker-compose.test.yml cp delphi:/app/coverage-comment.md . - echo "=== Coverage Report ===" - cat coverage-comment.md + # The .env additions, the image builds, the stack with readiness waits, the + # copy-in of tests and projection-gate scan inputs, pytest with coverage, + # service logs on failure and teardown all live in ci/local/delphi-python.sh, + # so `make check-delphi-python` gives the same verdict on any Docker host. + # The opt-in Postgres integration tests (require_polis_postgres) run against + # the compose `postgres` service, whose image bakes the polis migrations. + - name: Run Delphi Pytest + env: + DELPHI_COVERAGE_OUT: ${{ github.workspace }} + run: make check-delphi-python - name: 8. Upload Coverage Report if: success() @@ -236,19 +115,3 @@ jobs: console.log(`Unexpected error posting comment: ${error.message}`); } } - - - name: 10. Show service logs on failure - if: failure() - run: | - echo "=== Delphi service logs ===" - docker compose -f docker-compose.test.yml logs delphi || true - echo "=== Postgres service logs ===" - docker compose -f docker-compose.test.yml logs postgres || true - echo "=== DynamoDB service logs ===" - docker compose -f docker-compose.test.yml logs dynamodb || true - - - name: 11. Clean up services - if: always() - run: | - echo "Cleaning up services..." - docker compose -f docker-compose.test.yml down -v diff --git a/.github/workflows/queue-rs-ci.yml b/.github/workflows/queue-rs-ci.yml index b720928245..0e75fc1d77 100644 --- a/.github/workflows/queue-rs-ci.yml +++ b/.github/workflows/queue-rs-ci.yml @@ -30,35 +30,12 @@ jobs: name: queue-rs build, clippy and tests runs-on: ubuntu-24.04 timeout-minutes: 30 - services: - postgres: - image: postgres:17-alpine - env: - POSTGRES_USER: postgres - POSTGRES_DB: queue_acceptance - POSTGRES_HOST_AUTH_METHOD: trust - ports: - - 5432:5432 - options: >- - --health-cmd "pg_isready -U postgres -d queue_acceptance" - --health-interval 2s --health-timeout 3s --health-retries 30 - defaults: - run: - working-directory: queue-rs steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - - name: Toolchain (pinned by queue-rs/rust-toolchain.toml) - run: rustup show active-toolchain - - name: Clippy - run: | - cargo clippy --locked --all-targets -- -D warnings - cargo clippy --locked --all-targets --features jobs-integration -- -D warnings - - name: Unit and protocol tests - run: cargo test --locked - - name: Integration tests (PostgreSQL 17 service) - env: - POLIS_JOBS_TEST_DATABASE_URL: postgresql://postgres@127.0.0.1:5432/queue_acceptance - POLIS_JOBS_TEST_PYTHON: python3 - run: cargo test --locked --features jobs-integration --test jobs_integration -- --test-threads 4 + # The toolchain (pinned by queue-rs/rust-toolchain.toml), clippy, the unit + # and protocol tests, and the integration tests against a throwaway + # PostgreSQL 17 (host port 5432) live in ci/local/queue-rs.sh. + - name: Clippy, unit, protocol and integration tests + run: make check-queue-rs diff --git a/.github/workflows/routing-recordings.yml b/.github/workflows/routing-recordings.yml index 769fc682de..b5dfe654e1 100644 --- a/.github/workflows/routing-recordings.yml +++ b/.github/workflows/routing-recordings.yml @@ -25,8 +25,6 @@ jobs: with: {fetch-depth: 0} - uses: actions/setup-node@v4 with: {node-version: 22, cache: npm, cache-dependency-path: server/package-lock.json} - - run: npm ci --no-audit --no-fund - working-directory: server - - if: github.event_name == 'pull_request' - run: node server/characterization/routing/guard.cjs '${{ github.event.pull_request.base.sha }}' - - run: sh server/characterization/routing/check.sh + - run: make check-routing-recordings + env: + BASE_REF: '${{ github.event.pull_request.base.sha }}' diff --git a/.github/workflows/test-clojure.yml b/.github/workflows/test-clojure.yml index 8a57ebc640..587452102c 100644 --- a/.github/workflows/test-clojure.yml +++ b/.github/workflows/test-clojure.yml @@ -35,6 +35,6 @@ jobs: cli: 1.10.1.693 - name: Run Clojure tests - working-directory: math # Runs all except integration tests which require database and setup/teardown - run: "clojure -M:test" + # (ci/local/math.sh; it uses this job's clojure CLI). + run: make check-math diff --git a/.github/workflows/vote-convention-gate.yml b/.github/workflows/vote-convention-gate.yml index 9407f09fc2..6f2992b5e0 100644 --- a/.github/workflows/vote-convention-gate.yml +++ b/.github/workflows/vote-convention-gate.yml @@ -31,17 +31,14 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Lint and gate unit checks - run: | - python3 -m unittest ci/vote_convention/test_gate.py - python3 ci/vote_convention/sign_lint.py + run: make check-vote-sign-lint two-convention: name: two storage conventions runs-on: ubuntu-latest timeout-minutes: 30 env: - COMPOSE_PROJECT_NAME: vote-gate-${{ github.run_id }}-${{ github.run_attempt }} - VOTE_GATE_PG_PORT: '5470' + CHECK_PROJECT: vote-gate-${{ github.run_id }}-${{ github.run_attempt }} OUT: ${{ github.workspace }}/.vote-gate steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -53,31 +50,12 @@ jobs: node-version: '24' cache: npm cache-dependency-path: server/package-lock.json - - name: Install the locked engine requirements and the server modules - run: | - python -m pip install -r coordinator-rs/evidence/python-requirements.txt - npm ci --prefix server - - name: Fixture declarations, fixture writers, fold adapter, +1 pins (P-078 PR-G) - run: | - PYTHONPATH=delphi python -m unittest ci/vote_convention/test_fixtures_declared.py - node --test server/characterization/stored-votes.test.cjs - python coordinator-rs/ci/replay_pins_convention.py --check - - name: v0 (agree = -1) — provision both conventions, run every leg, verdict on v0 - env: - VOTE_GATE_V1: separate - PYTHON: python - run: ci/vote_convention/run.sh "$OUT" - - name: v1 (agree = +1) against v0 — expected red until PR-A/B/C - # The full byte comparison. Flip to required (remove continue-on-error) - # when PR-A and PR-B/C land. Exit 3: red, every red family expected. - continue-on-error: true - run: python ci/vote_convention/compare.py v1 "$OUT" - - name: v1 ratchet — no unexpected red (required) - # Accepts a v0/v1 difference only in a file pinned in expected-red-v1.json - # and only when it is sign-shaped. Fails on any other difference (including - # the must-hold families), an output missing from either leg's inventory, - # a failed export or an HTTP 5xx on either leg. - run: python ci/vote_convention/compare.py v1 "$OUT" --ratchet + # The locked engine requirements, the server modules, the fixture checks, + # both legs (Postgres on host port 5470), the v1 report (not required: + # exit 3 means every red family is expected) and the required ratchet + # live in ci/local/vote-gate.sh: `make check-vote-gate` runs it anywhere. + - name: Fixture checks, v0 verdict (required), v1 report, v1 ratchet (required) + run: make check-vote-gate - name: Keep the verdicts and outputs if: always() uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 diff --git a/.gitignore b/.gitignore index e1f3a61bb7..7bda26bca9 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,7 @@ __pycache__/ # two-convention gate outputs (ci/vote_convention/run.sh) .vote-gate/ + +# Local check entry points (ci/local/): state, venvs, tools, test certificates +.check/ +.simulacrum/ diff --git a/CLAUDE.md b/CLAUDE.md index e617009a48..7b76b7997b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -39,7 +39,16 @@ psql postgresql://postgres:oiPorg3Nrz0yqDLE@localhost:5432/polis-dev ### Testing +Every hosted CI check is a local entry point (`ci/local/`, docs/local-checks.md); the +workflows call the same targets: + ```bash +make check-fast # seconds: sign lint, golden guards, contracts, server unit, ESLint +make check-changed # the suites a change can reach (BASE_REF, default origin/edge) +make check # every check CI runs, same order, with a summary +make check- # one suite (make check-list) +``` + make e2e-run # Run E2E tests (Cypress) make e2e-run-interactive # Open Cypress GUI diff --git a/Makefile b/Makefile index 7fbf8ff6ea..a111463b4a 100644 --- a/Makefile +++ b/Makefile @@ -258,6 +258,32 @@ psql-shell: echo_vars ## Open psql shell for the default environment start-prodclone: ## Start with production clone database (USE_PRODCLONE=true) $(MAKE) USE_PRODCLONE=true start +# Local checks: every check hosted CI runs has a script in ci/local/. Workflows +# call the matching target except the documented coordinator exception. +# Knobs: BASE_REF (default origin/edge), CHECK_PROJECT, CHECK_PORT_BASE, CHECK_KEEP=1. +LOCAL_CHECK = ci/local/check.sh + +check: ## Every check CI runs, in CI's order, with a summary (one command, plain Docker host) + @$(LOCAL_CHECK) --gate + +check-fast: ## The fast-loop tier: lint, guards, contracts, server unit tests (seconds, no containers) + @$(LOCAL_CHECK) --fast + +check-changed: ## Only the suites whose inputs differ from BASE_REF (default origin/edge) + @$(LOCAL_CHECK) --changed + +check-ungated: ## Test sets no workflow runs yet (legacy client, cdk, ci/ Python) + @$(LOCAL_CHECK) --ungated + +check-list: ## List the check suites + @$(LOCAL_CHECK) --list + +check-routing-recordings: ## Replay routing recordings and enforce their guard + @$(LOCAL_CHECK) routing-recordings + +check-%: ## One suite, e.g. make check-server-integration (make check-list) + @$(LOCAL_CHECK) $* + # Helpful CLI shortcuts rbs: start-rebuild @@ -273,7 +299,8 @@ rbs: start-rebuild rm-ALL rm-containers rm-images rm-volumes \ start-FULL-REBUILD start-prodclone start-rebuild start-recreate \ test-recovery test-recovery-up test-recovery-down test-recovery-races \ - vote-convention-gate vote-sign-lint + vote-convention-gate vote-sign-lint \ + check check-fast check-changed check-ungated check-list check-routing-recordings help: ## Show this help message diff --git a/README.md b/README.md index f2279ee151..d574fe1b4b 100644 --- a/README.md +++ b/README.md @@ -284,6 +284,9 @@ To work on the **delphi** Python ML service outside Docker (run tests locally, g We use Cypress for automated, end-to-end browser testing for PRs on GitHub (see badge above). Please see [`e2e/README.md`](/e2e/README.md) for more information on running these tests locally. +Every check that CI runs can be run locally with one command on a plain Docker host: `make check` +(or `make check-` for one). See [`docs/local-checks.md`](/docs/local-checks.md). + ### Miscellaneous & troubleshooting #### Docker Problems diff --git a/ci/local/cdk.sh b/ci/local/cdk.sh new file mode 100755 index 0000000000..ccbf9a97e9 --- /dev/null +++ b/ci/local/cdk.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# The CDK stack's jest tests. No workflow runs them yet: an entry point, not a gate. +. "$(dirname "$0")/lib.sh" +check_init cdk +check_use_node 24 +check_npm cdk ci +cd "$CHECK_ROOT/cdk" +npx jest --ci diff --git a/ci/local/certs.sh b/ci/local/certs.sh new file mode 100755 index 0000000000..2577e29cac --- /dev/null +++ b/ci/local/certs.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# Test TLS certificates for the OIDC simulator and the services that trust it. +# +# ci/local/certs.sh writes .simulacrum/certs/{localhost.pem,localhost-key.pem,rootCA.pem} +# +# The CA lives inside the checkout (.simulacrum/ca, CAROOT) and is never installed +# into a system trust store or keychain: Node reads it from NODE_EXTRA_CA_CERTS +# and the containers mount .simulacrum/certs. mkcert comes from PATH, else a +# pinned, checksum-verified v1.4.4 release for this host's OS and architecture +# is downloaded into .check/bin once. +. "$(dirname "$0")/lib.sh" +CHECK_SUITE="${CHECK_SUITE:-certs}" + +MKCERT_VERSION=v1.4.4 +mkcert_sha256() { + case "$1" in + linux-amd64) echo 6d31c65b03972c6dc4a14ab429f2928300518b26503f58723e532d1b0a3bbb52 ;; + linux-arm64) echo b98f2cc69fd9147fe4d405d859c57504571adec0d3611c3eefd04107c7ac00d0 ;; + darwin-amd64) echo a32dfab51f1845d51e810db8e47dcf0e6b51ae3422426514bf5a2b8302e97d4e ;; + darwin-arm64) echo c8af0df44bce04359794dad8ea28d750437411d632748049d08644ffb66a60c6 ;; + *) return 1 ;; + esac +} + +ensure_mkcert() { + if command -v mkcert >/dev/null 2>&1; then MKCERT="$(command -v mkcert)"; return; fi + local os arch platform want bin + os="$(uname -s | tr '[:upper:]' '[:lower:]')" + case "$(uname -m)" in + x86_64|amd64) arch=amd64 ;; + arm64|aarch64) arch=arm64 ;; + *) check_die "no pinned mkcert for $(uname -m); put mkcert on PATH" ;; + esac + platform="$os-$arch" + want="$(mkcert_sha256 "$platform")" || check_die "no pinned mkcert for $platform; put mkcert on PATH" + bin="$CHECK_ROOT/.check/bin/mkcert" + if [ ! -x "$bin" ] || [ "$(check_sha256 "$bin")" != "$want" ]; then + mkdir -p "$CHECK_ROOT/.check/bin" + check_log "downloading mkcert $MKCERT_VERSION for $platform" + curl -fsSL -o "$bin.part" \ + "https://github.com/FiloSottile/mkcert/releases/download/$MKCERT_VERSION/mkcert-$MKCERT_VERSION-$platform" + [ "$(check_sha256 "$bin.part")" = "$want" ] || { rm -f "$bin.part"; check_die "mkcert checksum mismatch"; } + chmod +x "$bin.part"; mv "$bin.part" "$bin" + fi + MKCERT="$bin" +} + +ensure_mkcert +export CAROOT="${CAROOT:-$CHECK_ROOT/.simulacrum/ca}" +CERTS="$CHECK_ROOT/.simulacrum/certs" +mkdir -p "$CAROOT" "$CERTS" +# mkcert creates the CA in CAROOT on first use; nothing is installed anywhere. +if [ ! -f "$CERTS/localhost.pem" ] || [ ! -f "$CERTS/rootCA.pem" ] || [ ! -f "$CAROOT/rootCA.pem" ] \ + || ! cmp -s "$CAROOT/rootCA.pem" "$CERTS/rootCA.pem"; then + (cd "$CERTS" && "$MKCERT" -cert-file localhost.pem -key-file localhost-key.pem \ + localhost 127.0.0.1 ::1 oidc-simulator host.docker.internal) + cp "$CAROOT/rootCA.pem" "$CERTS/rootCA.pem" +fi +check_log "certificates in $CERTS (CA: $CAROOT; not installed in any trust store)" diff --git a/ci/local/changed-suites.sh b/ci/local/changed-suites.sh new file mode 100755 index 0000000000..d216f59592 --- /dev/null +++ b/ci/local/changed-suites.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash +# Which suites can a change reach? Prints their names, one line, gate order. +# +# ci/local/changed-suites.sh working tree (committed + uncommitted + untracked) vs BASE_REF +# ci/local/changed-suites.sh --base B --head H commits only: git diff B...H (what a pull request holds) +# ci/local/changed-suites.sh --is [...] exit 0 when that suite is reached, 1 when not +# ci/local/changed-suites.sh --path P [...] select for explicit paths (selector tests) +# +# Suites whose workflow has a path filter include that filter plus every input +# the shared entry point reads. The coordinator campaign's in-job gate keeps +# its exact hosted rule. Suites CI runs on every pull request use their inputs +# here, and run when unsure: a change to +# ci/local/lib.sh, suites.sh, docker-compose.test.yml or test.env reaches every +# suite that uses them. +set -euo pipefail +HERE="$(cd "$(dirname "$0")" && pwd)" +ROOT="$(cd "$HERE/../.." && pwd)" +. "$HERE/suites.sh" +BASE="${BASE_REF:-origin/edge}"; HEAD_REF=""; IS=""; CHANGED_PATHS="" +while [ $# -gt 0 ]; do + case "$1" in + --base) BASE="$2"; shift 2 ;; + --head) HEAD_REF="$2"; shift 2 ;; + --is) IS="$2"; shift 2 ;; + --path) CHANGED_PATHS="${CHANGED_PATHS}${CHANGED_PATHS:+ +}$2"; shift 2 ;; + *) echo "changed-suites: unknown argument $1" >&2; exit 2 ;; + esac +done +cd "$ROOT" +if [ -n "$CHANGED_PATHS" ]; then + changed="$CHANGED_PATHS" +elif [ -n "$HEAD_REF" ]; then + git rev-parse --verify --quiet "$BASE^{commit}" >/dev/null || { echo "changed-suites: $BASE is not a commit here" >&2; exit 2; } + # --no-renames: a rename lists the removed and the added path, so moving a + # file out of a directory still counts as touching it. + changed="$(git diff --name-only --no-renames "$BASE...$HEAD_REF")" +else + git rev-parse --verify --quiet "$BASE^{commit}" >/dev/null || { echo "changed-suites: $BASE is not a commit here" >&2; exit 2; } + mb="$(git merge-base "$BASE" HEAD)" + changed="$( { git diff --name-only --no-renames "$mb"; git ls-files -o --exclude-standard; } | sort -u)" +fi + +# The paths (extended regex, whole path) that reach a suite. +STACK='docker-compose\.test\.yml$|test\.env$|ci/local/(lib|certs)\.sh$' +pattern() { + case "$1" in + vote-sign-lint) echo '.' ;; + vote-path-guard) echo '^(server/|ci/vote_path_golden_guard\.sh$|\.github/workflows/jest-server-test\.yml$)' ;; + contracts) echo '^(server/|client-participation-alpha/|client-report/|\.github/workflows/jest-server-test\.yml$)' ;; + server-unit) echo '^(server/|test\.env$)' ;; + server-integration) echo "^(server/|oidc-simulator/|file-server/|client-admin/|client-report/|delphi/create_dynamodb_tables\.py$|ci/local/clock-skew\.cjs$|\.github/workflows/jest-server-test\.yml$|$STACK)" ;; + e2e) echo "^(server/|oidc-simulator/|file-server/|client-[a-z-]+/|delphi/|e2e/|\.github/workflows/cypress-tests\.yml$|$STACK)" ;; + coordinator) echo '^(coordinator-rs/|delphi/|math/|server/|\.github/workflows/coordinator-ci\.yml$)' ;; + vote-gate) echo '^(server/|delphi/|ci/vote_convention/|coordinator-rs/|\.github/workflows/vote-convention-gate\.yml$)' ;; + delphi-characterization) echo '^(server/|delphi/|ci/local/requirements-pyyaml\.txt$|\.github/workflows/delphi-characterization\.yml$)' ;; + collective-statement-guard) echo '^(server/|ci/collective_statement_golden_guard\.sh$|delphi/create_dynamodb_tables\.py$|\.github/workflows/collective-statement-recordings\.yml$)' ;; + collective-statement) echo '^(server/|delphi/create_dynamodb_tables\.py$|ci/local/requirements-collective-statement\.txt$|\.github/workflows/collective-statement-recordings\.yml$)' ;; + lint) echo '^(client-admin/|server/|client-report/|e2e/|\.github/workflows/lint\.yml$)' ;; + delphi-python) echo "^(delphi/.*\.py$|delphi/(tests|real_data|polismath|umap_narrative|scripts)/|delphi/requirements[^/]*\.txt$|delphi/Dockerfile$|docker-compose\.yml$|scripts/(after_install|before_install|application_stop)\.sh$|ci/p022_(recordings_manifest|battery_digest)\.py$|\.github/workflows/python-ci\.yml$|server/src/|ci/private_cert/|ci/probe_box/|$STACK)" ;; + routing-recordings) echo '^(server/|\.github/workflows/routing-recordings\.yml$)' ;; + queue-rs) echo '^(queue-rs/|server/postgres/migrations/|\.github/workflows/queue-rs-ci\.yml$)' ;; + client-alpha) echo '^(client-participation-alpha/)' ;; + client-admin) echo '^(client-admin/)' ;; + client-report) echo '^(client-report/)' ;; + math) echo '^(math/|\.github/workflows/test-clojure\.yml$)' ;; + client-participation) echo '^(client-participation/)' ;; + cdk) echo '^(cdk/)' ;; + ci-python) echo '^(ci/private_cert/|ci/probe_box/|ci/tests/|coordinator-rs/evidence/python-requirements\.txt$)' ;; + selector-test) echo '^(ci/local/(changed-suites|test_changed_suites|selector-test)\.(sh|py)$)' ;; + *) echo "changed-suites: unknown suite $1" >&2; return 2 ;; + esac +} + +reached() { + [ -n "$changed" ] || return 1 + local p + p="$(pattern "$1")" || exit 2 + # The shared harness reaches every suite that uses it. + printf '%s\n' "$changed" | grep -Eq "$p|^ci/local/$1\.sh$|^ci/local/(lib|check|suites|changed-suites)\.sh$|^Makefile$" +} + +if [ -n "$IS" ]; then + printf '%s\n' "$changed" | sed 's/^/changed: /' >&2 + # The coordinator campaign's required check keeps its own exact rule, so the + # shared harness files above do not widen it. + if [ "$IS" = coordinator ]; then + printf '%s\n' "$changed" | grep -Eq "$(pattern coordinator)" + else + reached "$IS" + fi + exit $? +fi +out="" +for s in $CHECK_GATE_SUITES $CHECK_UNGATED_SUITES $CHECK_TOOLING_SUITES; do + if reached "$s"; then out="$out $s"; fi +done +echo "${out# }" diff --git a/ci/local/check.sh b/ci/local/check.sh new file mode 100755 index 0000000000..52fbbdbc01 --- /dev/null +++ b/ci/local/check.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# Run one or more checks and print a summary. +# +# ci/local/check.sh ... run each in turn (all of them, even after a failure) +# ci/local/check.sh --gate every check CI runs (make check) +# ci/local/check.sh --fast the fast-loop tier (make check-fast) +# ci/local/check.sh --ungated test sets no workflow runs yet (make check-ungated) +# ci/local/check.sh --changed the suites whose inputs differ from BASE_REF (make check-changed) +# ci/local/check.sh --list list the suites +# Exit status: 0 when every suite passed, 1 otherwise. A per-run summary is kept +# in .check/summary-