diff --git a/.github/workflows/docker-image-test.yml b/.github/workflows/docker-image-test.yml index b8eb0fc4c0..29df0903f2 100644 --- a/.github/workflows/docker-image-test.yml +++ b/.github/workflows/docker-image-test.yml @@ -1,12 +1,6 @@ name: Docker Image Test on: - pull_request: - types: [opened, reopened, synchronize] - push: - branches: - - develop - - release/* workflow_call: secrets: DEV_AWS_ROLE: @@ -27,7 +21,7 @@ permissions: jobs: check-changes: - name: Check Docker Image Changes + name: skippable runs-on: blacksmith-2vcpu-ubuntu-2404 outputs: should_run: ${{ steps.check.outputs.should_run }} @@ -121,14 +115,3 @@ jobs: docker ps -a --filter "name=pg-test-${{ matrix.name }}" -q | xargs -r docker rm -f || true docker rmi "pg-docker-test:${{ matrix.name }}" || true docker rmi "supabase-postgres:${{ matrix.name }}-analyze" || true - - skip-notification: - name: Docker Image Test (Skipped) - needs: check-changes - if: needs.check-changes.outputs.should_run == 'false' - runs-on: ubuntu-latest - steps: - - name: Report skipped - run: | - echo "Docker image tests skipped - inputs unchanged" - echo "Input hash: ${{ needs.check-changes.outputs.input_hash }}" diff --git a/.github/workflows/nix-build.yml b/.github/workflows/nix-build.yml index e286015cca..856526bdf2 100644 --- a/.github/workflows/nix-build.yml +++ b/.github/workflows/nix-build.yml @@ -19,7 +19,7 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: - nix-eval: + eval: runs-on: blacksmith-32vcpu-ubuntu-2404 outputs: packages_matrix: ${{ steps.gen-matrix.outputs.packages_matrix }} @@ -46,17 +46,15 @@ jobs: sudo pkill -9 nix-daemon || true sleep 2 - nix-build-packages-aarch64-linux: - name: >- - ${{ matrix.name }}${{ matrix.postgresql_version && format(' - Postgres {0}', matrix.postgresql_version) || '' }} - (aarch64-linux) - needs: nix-eval + builds-aarch64-linux: + name: ${{ matrix.name }}${{ matrix.postgresql_version || '' }} + needs: eval runs-on: ${{ matrix.runs_on.group && matrix.runs_on || matrix.runs_on.labels }} - if: ${{ fromJSON(needs.nix-eval.outputs.packages_matrix).aarch64_linux != null }} + if: ${{ fromJSON(needs.eval.outputs.packages_matrix).aarch64_linux != null }} strategy: fail-fast: false max-parallel: 25 - matrix: ${{ fromJSON(needs.nix-eval.outputs.packages_matrix).aarch64_linux }} + matrix: ${{ fromJSON(needs.eval.outputs.packages_matrix).aarch64_linux }} steps: - name: Checkout Repo if: ${{ matrix.attr != '' }} @@ -74,19 +72,17 @@ jobs: with: attr: .#${{ matrix.attr }} - nix-build-checks-aarch64-linux: - name: >- - ${{ matrix.name }}${{ matrix.postgresql_version && format(' - Postgres {0}', matrix.postgresql_version) || '' }} - (aarch64-linux) + checks-aarch64-linux: + name: ${{ matrix.name }}${{ matrix.postgresql_version || '' }} needs: - - nix-eval - - nix-build-packages-aarch64-linux + - eval + - builds-aarch64-linux runs-on: ${{ matrix.runs_on.group && matrix.runs_on || matrix.runs_on.labels }} - if: ${{ fromJSON(needs.nix-eval.outputs.checks_matrix).aarch64_linux != null }} + if: ${{ fromJSON(needs.eval.outputs.checks_matrix).aarch64_linux != null }} strategy: fail-fast: false max-parallel: 25 - matrix: ${{ fromJSON(needs.nix-eval.outputs.checks_matrix).aarch64_linux }} + matrix: ${{ fromJSON(needs.eval.outputs.checks_matrix).aarch64_linux }} steps: - name: Checkout Repo if: ${{ matrix.attr != '' }} @@ -104,17 +100,15 @@ jobs: with: attr: .#${{ matrix.attr }} - nix-build-packages-aarch64-darwin: - name: >- - ${{ matrix.name }}${{ matrix.postgresql_version && format(' - Postgres {0}', matrix.postgresql_version) || '' }} - (aarch64-darwin) - needs: nix-eval + builds-aarch64-darwin: + name: ${{ matrix.name }}${{ matrix.postgresql_version || '' }} + needs: eval runs-on: ${{ matrix.attr != '' && matrix.runs_on.group && matrix.runs_on || matrix.runs_on.labels }} - if: ${{ fromJSON(needs.nix-eval.outputs.packages_matrix).aarch64_darwin != null }} + if: ${{ fromJSON(needs.eval.outputs.packages_matrix).aarch64_darwin != null }} strategy: fail-fast: false max-parallel: 25 - matrix: ${{ fromJSON(needs.nix-eval.outputs.packages_matrix).aarch64_darwin }} + matrix: ${{ fromJSON(needs.eval.outputs.packages_matrix).aarch64_darwin }} steps: - name: Checkout Repo if: ${{ matrix.attr != '' }} @@ -135,19 +129,17 @@ jobs: with: attr: .#${{ matrix.attr }} - nix-build-checks-aarch64-darwin: - name: >- - ${{ matrix.name }}${{ matrix.postgresql_version && format(' - Postgres {0}', matrix.postgresql_version) || '' }} - (aarch64-darwin) + checks-aarch64-darwin: + name: ${{ matrix.name }}${{ matrix.postgresql_version || '' }} needs: - - nix-eval - - nix-build-packages-aarch64-darwin + - eval + - builds-aarch64-darwin runs-on: ${{ matrix.attr != '' && matrix.runs_on.group && matrix.runs_on || matrix.runs_on.labels }} - if: ${{ fromJSON(needs.nix-eval.outputs.checks_matrix).aarch64_darwin != null }} + if: ${{ fromJSON(needs.eval.outputs.checks_matrix).aarch64_darwin != null }} strategy: fail-fast: false max-parallel: 25 - matrix: ${{ fromJSON(needs.nix-eval.outputs.checks_matrix).aarch64_darwin }} + matrix: ${{ fromJSON(needs.eval.outputs.checks_matrix).aarch64_darwin }} steps: - name: Checkout Repo if: ${{ matrix.attr != '' }} @@ -165,17 +157,15 @@ jobs: with: attr: .#${{ matrix.attr }} - nix-build-packages-x86_64-linux: - name: >- - ${{ matrix.name }}${{ matrix.postgresql_version && format(' - Postgres {0}', matrix.postgresql_version) || '' }} - (x86_64-linux) - needs: nix-eval + builds-x86_64-linux: + name: ${{ matrix.name }}${{ matrix.postgresql_version || '' }} + needs: eval runs-on: ${{ matrix.attr != '' && matrix.runs_on.group && matrix.runs_on || matrix.runs_on.labels }} - if: ${{ fromJSON(needs.nix-eval.outputs.packages_matrix).x86_64_linux != null }} + if: ${{ fromJSON(needs.eval.outputs.packages_matrix).x86_64_linux != null }} strategy: fail-fast: false max-parallel: 25 - matrix: ${{ fromJSON(needs.nix-eval.outputs.packages_matrix).x86_64_linux }} + matrix: ${{ fromJSON(needs.eval.outputs.packages_matrix).x86_64_linux }} steps: - name: Checkout Repo if: ${{ matrix.attr != '' }} @@ -193,19 +183,17 @@ jobs: with: attr: .#${{ matrix.attr }} - nix-build-checks-x86_64-linux: - name: >- - ${{ matrix.name }}${{ matrix.postgresql_version && format(' - Postgres {0}', matrix.postgresql_version) || '' }} - (x86_64-linux) + checks-x86_64-linux: + name: ${{ matrix.name }}${{ matrix.postgresql_version || '' }} needs: - - nix-eval - - nix-build-packages-x86_64-linux + - eval + - builds-x86_64-linux runs-on: ${{ matrix.attr != '' && matrix.runs_on.group && matrix.runs_on || matrix.runs_on.labels }} - if: ${{ fromJSON(needs.nix-eval.outputs.checks_matrix).x86_64_linux != null }} + if: ${{ fromJSON(needs.eval.outputs.checks_matrix).x86_64_linux != null }} strategy: fail-fast: false max-parallel: 25 - matrix: ${{ fromJSON(needs.nix-eval.outputs.checks_matrix).x86_64_linux }} + matrix: ${{ fromJSON(needs.eval.outputs.checks_matrix).x86_64_linux }} steps: - name: Checkout Repo if: ${{ matrix.attr != '' }} @@ -223,13 +211,13 @@ jobs: with: attr: .#${{ matrix.attr }} - nix-build-checks: + checks: name: Nix Checks ✅ runs-on: blacksmith-2vcpu-ubuntu-2404 needs: - - nix-build-checks-aarch64-darwin - - nix-build-checks-aarch64-linux - - nix-build-checks-x86_64-linux + - checks-aarch64-darwin + - checks-aarch64-linux + - checks-x86_64-linux steps: - name: Check dependent job results if: contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') @@ -237,41 +225,37 @@ jobs: jq -rn --argjson needs '${{ toJSON(needs) }}' '$needs|to_entries[]|select(.value.result!="success")|"::error::"+.key+": "+.value.result' exit 1 - run-testinfra: + amis: needs: - - nix-eval - - nix-build-packages-aarch64-linux - - nix-build-packages-aarch64-darwin - - nix-build-packages-x86_64-linux + - builds-aarch64-linux + - builds-x86_64-linux uses: ./.github/workflows/testinfra-ami-build.yml secrets: DEV_AWS_ROLE: ${{ secrets.DEV_AWS_ROLE }} NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }} - run-tests: + schema: needs: - - nix-eval - - nix-build-packages-aarch64-linux - - nix-build-packages-aarch64-darwin - - nix-build-packages-x86_64-linux + - builds-aarch64-linux + - builds-x86_64-linux uses: ./.github/workflows/test.yml - docker-image-test: - needs: nix-build-packages-aarch64-linux + containers: + needs: builds-aarch64-linux uses: ./.github/workflows/docker-image-test.yml secrets: DEV_AWS_ROLE: ${{ secrets.DEV_AWS_ROLE }} NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }} - nix-ci-check: + check: name: Nix CI ✅ if: always() runs-on: blacksmith-2vcpu-ubuntu-2404 needs: - - docker-image-test - - nix-build-checks - - run-testinfra - - run-tests + - amis + - checks + - containers + - schema steps: - name: Check dependent job results if: contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c484a295eb..1170b46b64 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,10 +8,10 @@ permissions: id-token: write jobs: - prepare: + gen-matrix: runs-on: blacksmith-4vcpu-ubuntu-2404 outputs: - postgres_versions: ${{ steps.set-versions.outputs.postgres_versions }} + postgres_major_versions: ${{ steps.set-versions.outputs.postgres_major_versions }} steps: - name: Checkout Repo uses: supabase/postgres/.github/actions/shared-checkout@HEAD @@ -20,18 +20,13 @@ jobs: id: set-versions run: | VERSIONS=$(nix run nixpkgs#yq-go -- -o=json -I=0 '.postgres_major' ansible/vars.yml) - echo "postgres_versions=$VERSIONS" >> $GITHUB_OUTPUT - build: - needs: prepare + echo "postgres_major_versions=$VERSIONS" >> $GITHUB_OUTPUT + verify: + needs: gen-matrix strategy: matrix: - postgres_version: ${{ fromJson(needs.prepare.outputs.postgres_versions) }} - include: - - runner: large-linux-x86 - arch: amd64 - - runner: large-linux-arm - arch: arm64 - runs-on: ${{ matrix.runner }} + postgres_major_version: ${{ fromJson(needs.gen-matrix.outputs.postgres_major_versions) }} + runs-on: blacksmith-4vcpu-ubuntu-2404 timeout-minutes: 180 env: POSTGRES_PORT: 5478 @@ -42,32 +37,6 @@ jobs: - uses: ./.github/actions/nix-install-ephemeral - - name: Set PostgreSQL version environment variable - run: echo "POSTGRES_MAJOR_VERSION=${{ matrix.postgres_version }}" >> $GITHUB_ENV - - - name: Strip quotes from pg major and set env var - run: | - stripped_version=$(echo "${{ matrix.postgres_version }}" | sed 's/^"\(.*\)"$/\1/') - echo "PGMAJOR=$stripped_version" >> $GITHUB_ENV - - - name: Generate common-nix.vars.pkr.hcl - run: | - PG_VERSION=$(nix run nixpkgs#yq-go -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml) - PG_VERSION=$(echo $PG_VERSION | tr -d '"') # Remove any surrounding quotes - echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl - echo "" >> common-nix.vars.pkr.hcl - - - id: settings - run: sed -r 's/(\s|\")+//g' common-nix.vars.pkr.hcl >> $GITHUB_OUTPUT - - - name: Generate args - id: args - run: | - ARGS=$(nix run nixpkgs#yq-go -- 'to_entries | map(select(.value|type == "!!str")) | map(.key + "=" + .value) | join("\n")' ansible/vars.yml) - echo "result<> $GITHUB_OUTPUT - echo "$ARGS" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - name: Resolve git sha id: resolve-git-sha uses: ./.github/actions/resolve-git-sha @@ -76,9 +45,9 @@ jobs: - name: verify schema.sql is committed run: | - nix run github:supabase/postgres/${{ steps.resolve-git-sha.outputs.sha }}#dbmate-tool -- --version ${{ env.PGMAJOR }} --flake-url github:supabase/postgres/${{ steps.resolve-git-sha.outputs.sha }} - if ! git diff --exit-code --quiet migrations/schema-${{ env.PGMAJOR }}.sql; then + nix run github:supabase/postgres/${{ steps.resolve-git-sha.outputs.sha }}#dbmate-tool -- --version ${{ matrix.postgres_major_version }} --flake-url github:supabase/postgres/${{ steps.resolve-git-sha.outputs.sha }} + if ! git diff --exit-code --quiet migrations/schema-${{ matrix.postgres_major_version }}.sql; then echo "Detected changes in schema.sql:" - git diff migrations/schema-${{ env.PGMAJOR }}.sql + git diff migrations/schema-${{ matrix.postgres_major_version }}.sql exit 1 fi diff --git a/.github/workflows/testinfra-ami-build.yml b/.github/workflows/testinfra-ami-build.yml index 7288358399..bacc6ed63a 100644 --- a/.github/workflows/testinfra-ami-build.yml +++ b/.github/workflows/testinfra-ami-build.yml @@ -36,7 +36,7 @@ jobs: VERSIONS=$(nix run nixpkgs#yq-go -- -o=json -I=0 '.postgres_major' ansible/vars.yml) echo "postgres_versions=$VERSIONS" >> "$GITHUB_OUTPUT" - test-ami-nix: + build: needs: gen-matrix strategy: fail-fast: false @@ -190,7 +190,7 @@ jobs: fi report-disk-usage: - needs: test-ami-nix + needs: build runs-on: blacksmith-2vcpu-ubuntu-2404 steps: - name: Download AMI disk usage