Skip to content

Commit 3f28087

Browse files
committed
chore: init-nix
1 parent 6b110df commit 3f28087

File tree

6 files changed

+205
-94
lines changed

6 files changed

+205
-94
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.github/workflows/ci.yml

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,26 @@ jobs:
2626
- uses: actions/checkout@v4
2727
with:
2828
fetch-depth: 0
29-
- uses: pnpm/action-setup@v4
30-
with:
31-
run_install: false
32-
- uses: actions/setup-node@v4
33-
id: cache
29+
- name: Install Nix
30+
uses: DeterminateSystems/nix-installer-action@v10
31+
32+
- name: Configure Nix Cache
33+
uses: cachix/cachix-action@v14
3434
with:
35-
node-version-file: '.node-version'
36-
cache: 'pnpm'
35+
# TODO: Create a cache on cachix.org for your project and add the name here
36+
name: ping-javascript-sdk
37+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
3738

38-
- run: pnpm install --frozen-lockfile
39+
- name: Install Dependencies
40+
run: nix develop --command pnpm install --frozen-lockfile
3941

4042
# This line enables distribution
4143
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
42-
- run: pnpm dlx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yml" --stop-agents-after="e2e-ci" --with-env-vars="CODECOV_TOKEN"
43-
- run: pnpm nx sync:check
44+
- name: Start Nx Cloud CI Run
45+
run: nix develop --command pnpm dlx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yml" --stop-agents-after="e2e-ci" --with-env-vars="CODECOV_TOKEN"
46+
47+
- name: Check Sync
48+
run: nix develop --command pnpm nx sync:check
4449

4550
- name: Cache Playwright browsers
4651
uses: actions/cache@v4
@@ -50,16 +55,23 @@ jobs:
5055
restore-keys: |
5156
${{ runner.os }}-playwright-
5257
53-
- run: pnpm exec playwright install
58+
- name: Install Playwright Browsers
59+
run: nix develop --command pnpm exec playwright install
5460

5561
- uses: nrwl/nx-set-shas@v4
5662
# This line is needed for nx affected to work when CI is running on a PR
5763
- run: git branch --track main origin/main
5864

59-
- run: pnpm exec nx-cloud record -- nx format:check
60-
- run: pnpm exec nx affected -t build typecheck lint test e2e-ci
61-
- run: npx nx-cloud fix-ci
65+
- name: Run Core Nx Commands
66+
run: |
67+
nix develop --command -- <<EOF
68+
pnpm exec nx-cloud record -- nx format:check
69+
pnpm exec nx affected -t build typecheck lint test e2e-ci
70+
EOF
71+
72+
- name: Fix CI (if necessary)
6273
if: always()
74+
run: nix develop --command npx nx-cloud fix-ci
6375

6476
- uses: codecov/codecov-action@v5
6577
with:
@@ -76,14 +88,12 @@ jobs:
7688
retention-days: 30
7789

7890
- name: Ensure builds run
79-
run: pnpm nx run-many -t build
80-
env:
81-
NX_CLOUD_DISTRIBUTED_EXECUTION: false
91+
run: nix develop --command pnpm nx run-many -t build
8292

8393
- run: pnpm pkg-pr-new publish './packages/*' './packages/sdk-effects/*' --packageManager=pnpm
8494

8595
- name: build docs
86-
run: pnpm generate-docs
96+
run: nix develop --command pnpm generate-docs
8797

8898
- name: preview-docs
8999
uses: rajyan/preview-pages@v1
@@ -109,20 +119,20 @@ jobs:
109119
- name: Calculate bundle sizes
110120
id: bundle-analysis
111121
run: |
112-
# Make script executable
113-
chmod +x ./scripts/bundle-sizes.sh
114-
115-
# Check if baseline exists
116-
if [ -f "previous_sizes.json" ]; then
117-
echo "✅ Using baseline size data from main branch"
118-
echo "Baseline data preview:"
119-
cat previous_sizes.json | head -5
120-
else
121-
echo "⚠️ No baseline size data found - this will be the first measurement"
122-
fi
123-
124-
# Run the bundle size calculation
125-
./scripts/bundle-sizes.sh
122+
nix develop --command -- <<EOF
123+
# Make script executable
124+
chmod +x ./scripts/bundle-sizes.sh
125+
# Check if baseline exists
126+
if [ -f "previous_sizes.json" ]; then
127+
echo "✅ Using baseline size data from main branch"
128+
echo "Baseline data preview:"
129+
cat previous_sizes.json | head -5
130+
else
131+
echo "⚠️ No baseline size data found - this will be the first measurement"
132+
fi
133+
# Run the bundle size calculation
134+
./scripts/bundle-sizes.sh
135+
EOF
126136
127137
- name: Upload current stats as artifact
128138
uses: actions/upload-artifact@v4

.github/workflows/publish.yml

Lines changed: 56 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,18 @@ jobs:
4747
with:
4848
fetch-depth: 0
4949
token: ${{ secrets.GH_TOKEN }}
50-
- uses: pnpm/action-setup@v4
51-
with:
52-
run_install: false
53-
- uses: actions/setup-node@v4
54-
id: cache
55-
with:
56-
node-version-file: '.node-version'
57-
cache: 'pnpm'
58-
registry-url: 'https://registry.npmjs.org'
59-
60-
- name: Update npm
61-
run: npm install -g npm@latest
50+
- name: Install Nix
51+
uses: DeterminateSystems/nix-installer-action@v10
6252

63-
- run: pnpm install --frozen-lockfile
53+
- name: Install Dependencies
54+
run: |
55+
nix develop --command -- <<EOF
56+
npm install -g npm@latest
57+
pnpm install --frozen-lockfile
58+
EOF
6459
65-
- run: pnpm dlx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yml" --stop-agents-after="e2e-ci" --with-env-vars="CODECOV_TOKEN"
60+
- name: Start Nx Cloud CI Run
61+
run: nix develop --command pnpm dlx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yml" --stop-agents-after="e2e-ci" --with-env-vars="CODECOV_TOKEN"
6662

6763
- name: Cache Playwright browsers
6864
uses: actions/cache@v4
@@ -72,14 +68,13 @@ jobs:
7268
restore-keys: |
7369
${{ runner.os }}-playwright-
7470
75-
- run: pnpm exec playwright install
76-
77-
- uses: nrwl/nx-set-shas@v4
78-
79-
- name: setup pnpm config
80-
run: pnpm config set store-dir $PNPM_CACHE_FOLDER
81-
82-
- run: pnpm exec nx affected -t build lint test e2e-ci
71+
- name: Install Browsers, Configure Pnpm, and Run Nx Affected
72+
run: |
73+
nix develop --command -- <<EOF
74+
pnpm exec playwright install
75+
pnpm config set store-dir $PNPM_CACHE_FOLDER
76+
pnpm exec nx affected -t build lint test e2e-ci
77+
EOF
8378
8479
- uses: actions/upload-artifact@v4
8580
if: ${{ !cancelled() }}
@@ -94,8 +89,8 @@ jobs:
9489
uses: changesets/action@v1
9590
id: changesets
9691
with:
97-
publish: pnpm ci:release
98-
version: pnpm ci:version
92+
publish: nix develop --command pnpm ci:release
93+
version: nix develop --command pnpm ci:version
9994
title: Release PR
10095
branch: main
10196
commit: 'chore: version-packages'
@@ -122,12 +117,10 @@ jobs:
122117
token: ${{ secrets.CODECOV_TOKEN }}
123118

124119
- name: Ensure builds run
125-
run: pnpm nx run-many -t build
126-
env:
127-
NX_CLOUD_DISTRIBUTED_EXECUTION: false
120+
run: nix develop --command pnpm nx run-many -t build
128121

129122
- name: Build docs
130-
run: pnpm generate-docs
123+
run: nix develop --command pnpm generate-docs
131124

132125
- name: Publish api docs
133126
if: steps.changesets.outputs.published == 'true'
@@ -147,12 +140,14 @@ jobs:
147140

148141
- name: Calculate baseline bundle sizes
149142
run: |
150-
chmod +x ./scripts/bundle-sizes.sh
151-
rm -f previous_sizes.json
152-
echo "📊 Calculating fresh baseline bundle sizes for main branch"
153-
./scripts/bundle-sizes.sh
154-
echo "✅ Baseline bundle sizes calculated"
155-
cat previous_sizes.json
143+
nix develop --command -- <<EOF
144+
chmod +x ./scripts/bundle-sizes.sh
145+
rm -f previous_sizes.json
146+
echo "📊 Calculating fresh baseline bundle sizes for main branch"
147+
./scripts/bundle-sizes.sh
148+
echo "✅ Baseline bundle sizes calculated"
149+
cat previous_sizes.json
150+
EOF
156151
157152
- name: Upload baseline bundle sizes
158153
uses: actions/upload-artifact@v4
@@ -177,20 +172,23 @@ jobs:
177172
with:
178173
fetch-depth: 0
179174
ref: ${{ inputs.branch }}
180-
- uses: pnpm/action-setup@v4
181-
with:
182-
run_install: false
183-
- uses: actions/setup-node@v4
184-
with:
185-
node-version-file: '.node-version'
186-
cache: 'pnpm'
187175

188-
- name: Update npm
189-
run: npm install -g npm@latest
176+
- name: Install Nix
177+
uses: DeterminateSystems/nix-installer-action@v10
190178

191-
- run: pnpm install --frozen-lockfile
179+
- name: Configure Nix Cache
180+
uses: cachix/cachix-action@v14
181+
with:
182+
name: ping-javascript-sdk # Matches the cache name in ci.yml
183+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
192184

193-
- run: pnpm dlx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yml" --stop-agents-after="e2e-ci" --with-env-vars="CODECOV_TOKEN"
185+
- name: Install Dependencies and Start CI Run
186+
run: |
187+
nix develop --command -- <<EOF
188+
npm install -g npm@latest
189+
pnpm install --frozen-lockfile
190+
pnpm dlx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yml" --stop-agents-after="e2e-ci" --with-env-vars="CODECOV_TOKEN"
191+
EOF
194192
195193
- name: Cache Playwright browsers
196194
uses: actions/cache@v4
@@ -200,16 +198,13 @@ jobs:
200198
restore-keys: |
201199
${{ runner.os }}-playwright-
202200
203-
- run: pnpm exec playwright install
204-
205-
- uses: nrwl/nx-set-shas@v4
206-
with:
207-
main-branch-name: main
208-
209-
- name: setup pnpm config
210-
run: pnpm config set store-dir $PNPM_CACHE_FOLDER
211-
212-
- run: pnpm exec nx run-many -t build test e2e-ci
201+
- name: Install Browsers, Configure Pnpm, and Run Nx
202+
run: |
203+
nix develop --command -- <<EOF
204+
pnpm exec playwright install
205+
pnpm config set store-dir $PNPM_CACHE_FOLDER
206+
pnpm exec nx run-many -t build test e2e-ci
207+
EOF
213208
214209
- uses: actions/upload-artifact@v4
215210
if: ${{ !cancelled() }}
@@ -219,11 +214,11 @@ jobs:
219214
./**/.playwright/**
220215
retention-days: 30
221216

222-
- name: Version Packages as prerelease
223-
run: pnpm changeset version --snapshot ${{ inputs.prerelease }}
217+
- name: Version and Publish Packages
218+
run: |
219+
nix develop --command -- <<EOF
220+
pnpm changeset version --snapshot ${{ inputs.prerelease }}
221+
pnpm publish -r --tag ${{ inputs.dist_tag }} --no-git-checks --access ${{ inputs.access }}
222+
EOF
224223
env:
225224
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
226-
227-
# The actual npm publish that must occur in the authorized file
228-
- name: Publish packages with dist-tag
229-
run: pnpm publish -r --tag ${{ inputs.dist_tag }} --no-git-checks --access ${{ inputs.access }}

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,9 @@ test-output
8282

8383
# Gemini local knowledge base files
8484
GEMINI.md
85-
**/GEMINI.md
85+
**/GEMINI.md
86+
87+
# Nix and direnv
88+
.direnv/
89+
result*
90+
!.envrc

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)