forked from Stellar-Paymaster/xlm-paymaster
-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (80 loc) · 3.63 KB
/
Copy pathnx-ci.yml
File metadata and controls
92 lines (80 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Nx CI – Remote Caching
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
env:
# When set, Nx will push/pull cache artefacts from Nx Cloud.
# Configure NX_CLOUD_AUTH_TOKEN as a GitHub Actions secret:
# Settings → Secrets and variables → Actions → New repository secret
NX_CLOUD_AUTH_TOKEN: ${{ secrets.NX_CLOUD_AUTH_TOKEN }}
NX_NO_CLOUD: true
jobs:
nx-ci:
name: Nx Build & Lint (with remote cache)
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Fetch enough history so Nx can compare against the base branch.
fetch-depth: 0
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
# ── Record timing BEFORE (used for the benchmark artifact) ──────────────
- name: Record CI start time
id: ci_start
run: echo "start=$(date +%s)" >> "$GITHUB_OUTPUT"
# ── Lint all projects (affected only on PRs, all on main) ───────────────
- name: Lint affected projects
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
npx nx affected --target=lint --base=origin/${{ github.base_ref }} --head=HEAD
else
npx nx run-many --target=lint --all
fi
# ── Format-check all projects ───────────────────────────────────────────
- name: Format check affected projects
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
npx nx affected --target=format:check --base=origin/${{ github.base_ref }} --head=HEAD
else
npx nx run-many --target=format:check --all
fi
# ── Record timing AFTER ─────────────────────────────────────────────────
- name: Record CI end time & report
if: always()
id: ci_end
run: |
END=$(date +%s)
START=${{ steps.ci_start.outputs.start }}
ELAPSED=$((END - START))
echo "Nx CI completed in ${ELAPSED}s"
echo "elapsed=${ELAPSED}" >> "$GITHUB_OUTPUT"
# ── Print Nx Cloud cache summary ────────────────────────────────────────
- name: Nx Cache Summary
if: always()
run: |
echo "──────────────────────────────────────────"
echo " Nx Remote Cache Summary"
echo "──────────────────────────────────────────"
if [ -n "$NX_CLOUD_AUTH_TOKEN" ]; then
echo " ✅ NX_CLOUD_AUTH_TOKEN is configured."
echo " Cache hits/misses are visible in the Nx Cloud dashboard:"
echo " https://cloud.nx.app"
else
echo " ⚠️ NX_CLOUD_AUTH_TOKEN is NOT set."
echo " Add it as a repository secret to enable remote caching."
fi
echo "──────────────────────────────────────────"