@@ -11,45 +11,67 @@ jobs:
1111
1212 steps :
1313 - name : Checkout PR
14- uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
14+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
15+ with :
16+ fetch-depth : ${{ github.event_name == 'pull_request' && 2 || 0 }}
17+
18+ - name : Get changed files
19+ id : changed-files
20+ run : |
21+ if ${{ github.event_name == 'pull_request' }}; then
22+ echo "changed_files=$(git diff --name-only --diff-filter=ACM -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
23+ else
24+ echo "changed_files=$(git diff --name-only --diff-filter=ACM ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
25+ fi
1526
16- - name : Use Node.js LTS (18.x)
17- uses : actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d
27+ - name : Enable corepack to fix https://github.com/actions/setup-node/pull/901
28+ run : corepack enable pnpm
29+
30+ - name : Use Node.js LTS (22.x)
31+ uses : actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
1832 with :
19- node-version : ' 18'
33+ node-version : 22.x
34+ cache : ' pnpm'
2035
2136 - name : Install project dependencies
22- run : npm ci
37+ run : corepack pnpm install --frozen-lockfile
2338
2439 - name : Run exercism/javascript ci precheck (stub files, config integrity) for changed exercises
25- run : |
26- PULL_REQUEST_URL=$(jq -r ".pull_request.url" "$GITHUB_EVENT_PATH")
27- curl --url $"${PULL_REQUEST_URL}/files?per_page=100" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | \
28- jq -c '.[] | select(.status == "added" or .status == "modified") | select(.filename | match("\\.(js|jsx|md|json)$")) | .filename' | \
29- xargs -r npx babel-node scripts/pr-check
40+ run : corepack pnpm node scripts/pr.mjs ${{ steps.changed-files.outputs.changed_files }}
3041
3142 ci :
3243 runs-on : ubuntu-22.04
3344
3445 strategy :
3546 matrix :
36- node-version : ['18', '20' ]
47+ node-version : [22.x ]
3748
3849 steps :
3950 - name : Checkout PR
40- uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
51+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
52+ with :
53+ fetch-depth : ${{ github.event_name == 'pull_request' && 2 || 0 }}
54+
55+ - name : Get changed files
56+ id : changed-files
57+ run : |
58+ if ${{ github.event_name == 'pull_request' }}; then
59+ echo "changed_files=$(git diff --name-only --diff-filter=ACM -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
60+ else
61+ echo "changed_files=$(git diff --name-only --diff-filter=ACM ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
62+ fi
63+
64+ - name : Enable corepack to fix https://github.com/actions/setup-node/pull/901
65+ run : corepack enable pnpm
4166
4267 - name : Use Node.js ${{ matrix.node-version }}
43- uses : actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d
68+ uses : actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
4469 with :
4570 node-version : ${{ matrix.node-version }}
71+ cache : ' pnpm'
4672
4773 - name : Install project dependencies
48- run : npm ci
74+ run : corepack pnpm install --frozen-lockfile
4975
5076 - name : Run exercism/javascript ci (runs tests) for changed/added exercises
51- run : |
52- PULL_REQUEST_URL=$(jq -r ".pull_request.url" "$GITHUB_EVENT_PATH")
53- curl --url $"${PULL_REQUEST_URL}/files?per_page=100" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | \
54- jq -c '.[] | select(.status == "added" or .status == "modified") | select(.filename | match("\\.(js|jsx|md|json)$")) | .filename' | \
55- xargs -r npx babel-node scripts/pr
77+ run : corepack pnpm node scripts/pr.mjs ${{ steps.changed-files.outputs.changed_files }}
0 commit comments