@@ -20,108 +20,74 @@ concurrency:
2020
2121jobs :
2222 nix-matrix :
23- runs-on : ubuntu-latest
23+ runs-on :
24+ group : self-hosted-runners-nix
25+ labels :
26+ - aarch64-darwin
2427 outputs :
2528 matrix : ${{ steps.set-matrix.outputs.matrix }}
2629 steps :
27- - uses : actions/checkout@v4
28- - uses : cachix/install-nix-action@v30
30+ - name : Checkout Repo
31+ uses : actions/checkout@v4
2932 - id : set-matrix
3033 name : Generate Nix Matrix
3134 run : |
3235 set -Eeu
36+ # fast eval
37+ nix-eval-jobs --flake '.#githubActions.matrix'
38+ # capture the output
3339 matrix="$(nix eval --json '.#githubActions.matrix')"
3440 echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
3541
3642 build-run-image :
3743 name : ${{ matrix.name }} (${{ matrix.system }})
3844 needs : nix-matrix
39- runs-on : ${{ matrix.os }}
45+ runs-on :
46+ group : ${{ matrix.os == 'blacksmith-32vcpu-ubuntu-2404' && '' || 'self-hosted-runners-nix' }}
47+ labels :
48+ - ${{ matrix.os }}
4049 strategy :
4150 fail-fast : false
4251 matrix : ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
43- timeout-minutes : 180
4452 steps :
4553 - name : Checkout Repo
46- uses : supabase/postgres/.github/actions/shared-checkout@HEAD
54+ uses : actions/checkout@v4
55+ - name : aws-oidc
56+ uses :
aws-actions/[email protected] 57+ with :
58+ aws-region : us-east-2
59+ role-to-assume : arn:aws:iam::279559813984:role/supabase-github-oidc-role # Shared Services
60+ role-session-name : gha-oidc-${{ github.run_id }}
4761 - name : aws-creds
48- uses : aws-actions/configure-aws-credentials@v4
49- if : ${{ github.secret_source == 'Actions' }}
62+ uses :
aws-actions/[email protected] 5063 with :
51- role-to-assume : ${{ secrets.DEV_AWS_ROLE }}
52- aws-region : " us-east-1"
53- output-credentials : true
54- role-duration-seconds : 7200
55- - name : Setup AWS credentials for Nix
56- if : ${{ github.secret_source == 'Actions' }}
57- run : |
58- sudo -H aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
59- sudo -H aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
60- sudo -H aws configure set aws_session_token $AWS_SESSION_TOKEN
61- - name : write secret key
62- # use python so we don't interpolate the secret into the workflow logs, in case of bugs
64+ disable-retry : true
65+ aws-region : us-east-2
66+ role-to-assume : arn:aws:iam::436098097459:role/nix-artifacts-deploy-role # supabase-dev
67+ role-session-name : gha-oidc-${{ github.run_id }}
68+ role-chaining : true
69+ role-skip-session-tagging : true
70+ role-duration-seconds : 900 # TODO: switch to 18000 (5 hours)
71+ - name : Write creds files
6372 run : |
64- sudo mkdir -p /etc/nix
65- sudo -E python -c "import os; file = open('/etc/nix/nix-secret-key', 'w'); file.write(os.environ['NIX_SIGN_SECRET_KEY']); file.close()"
66- env :
67- NIX_SIGN_SECRET_KEY : ${{ secrets.NIX_SIGN_SECRET_KEY }}
68- - name : Setup cache script
69- if : ${{ github.secret_source == 'Actions' }}
70- run : |
71- cat << 'EOF' | sudo tee /etc/nix/upload-to-cache.sh > /dev/null
72- #!/usr/bin/env bash
73- set -euf
74- export IFS=' '
75- /nix/var/nix/profiles/default/bin/nix copy --to 's3://nix-postgres-artifacts?secret-key=/etc/nix/nix-secret-key' $OUT_PATHS
73+ umask 006
74+ cat > /etc/nix/aws/nix-aws-credentials <<EOF
75+ [ci-uploader]
76+ aws_access_key_id = ${AWS_ACCESS_KEY_ID}
77+ aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}
78+ aws_session_token = ${AWS_SESSION_TOKEN}
7679 EOF
77- sudo chmod +x /etc/nix/upload-to-cache.sh
78- - name : Install nix
79- uses : cachix/install-nix-action@v27
80- if : ${{ github.secret_source == 'Actions' }}
81- with :
82- install_url : https://releases.nixos.org/nix/nix-2.29.1/install
83- extra_nix_config : |
84- substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com
85- trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
86- post-build-hook = /etc/nix/upload-to-cache.sh
87- - name : Install nix
88- uses : cachix/install-nix-action@v27
89- if : ${{ github.secret_source == 'None' }}
90- with :
91- install_url : https://releases.nixos.org/nix/nix-2.29.1/install
92- extra_nix_config : |
93- substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com
94- trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
95- - name : Aggressive disk cleanup for DuckDB build
96- if : matrix.runner == 'macos-latest-xlarge'
80+ - name : nix-fast-build
9781 run : |
98- nix --version
99- echo "=== BEFORE CLEANUP ==="
100- df -h
101- # Remove major space consumers
102- sudo rm -rf /usr/share/dotnet || true
103- sudo rm -rf /usr/local/lib/android || true
104- sudo rm -rf /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform || true
105- sudo rm -rf /Applications/Xcode.app/Contents/Developer/Platforms/watchOS.platform || true
106- sudo rm -rf /Applications/Xcode.app/Contents/Developer/Platforms/tvOS.platform || true
107- # Clean everything possible
108- sudo rm -rf /opt/ghc || true
109- sudo rm -rf /usr/local/share/boost || true
110- sudo rm -rf /opt/homebrew || true
111- sudo xcrun simctl delete all 2>/dev/null || true
112- # Aggressive cache cleanup
113- sudo rm -rf /System/Library/Caches/* 2>/dev/null || true
114- sudo rm -rf /Library/Caches/* 2>/dev/null || true
115- sudo rm -rf ~/Library/Caches/* 2>/dev/null || true
116- sudo rm -rf /private/var/log/* 2>/dev/null || true
117- sudo rm -rf /tmp/* 2>/dev/null || true
118- echo "=== AFTER CLEANUP ==="
119- df -h
120- - run : nix build -L '.#${{ matrix.attr }}'
121- env :
122- AWS_ACCESS_KEY_ID : ${{ env.AWS_ACCESS_KEY_ID }}
123- AWS_SECRET_ACCESS_KEY : ${{ env.AWS_SECRET_ACCESS_KEY }}
124- AWS_SESSION_TOKEN : ${{ env.AWS_SESSION_TOKEN }}
82+ declare -a args=(
83+ '--no-nom'
84+ '--skip-cached'
85+ '--systems=${{ env.system }}'
86+ '--option' 'accept-flake-config' 'true'
87+ '--retries=3'
88+ )
89+ args+=('--flake=${{ env.flake }}#${{ matrix.attr }}')
90+ nix run '${{ env.flake }}#nix-fast-build' -- "${args[@]}"
12591
12692 run-tests :
12793 needs : build-run-image
0 commit comments