Skip to content

Commit

Permalink
Start switching workflows to pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
SleeplessByte committed Oct 18, 2024
1 parent d4028e4 commit a11146d
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 44 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/action-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,18 @@ jobs:
git clone $HEAD_REPO .
git checkout -b "$HEAD_REF" "origin/$HEAD_REF"
- name: Use Node.js LTS (18.x)
- name: Enable corepack to fix https://github.com/actions/setup-node/pull/901
run: corepack enable pnpm

- name: Use Node.js LTS (20.x)
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: '18'
node-version: 20.x
cache: 'pnpm'

- name: Install project development dependencies
run: npm install --no-save
run: corepack pnpm install --no-save

- name: 'Format code'
run: ./bin/format.sh

Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/action-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ jobs:
git checkout -b "$HEAD_REF" "origin/$HEAD_REF"
- name: 'Install dependencies'
run: yarn install
run: |
corepack enable pnpm
corepack pnpm install
- name: 'Sync exercises'
run: npx babel-node scripts/sync
run: corepack pnpm node scripts/sync.mjs

- name: 'Commit changes'
run: |
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/ci.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,41 @@ jobs:

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Use Node.js LTS (18.x)
- name: Enable corepack to fix https://github.com/actions/setup-node/pull/901
run: corepack enable pnpm

- name: Use Node.js LTS (20.x)
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: '18'
node-version: 20.x
cache: 'pnpm'

- name: Install project dependencies
run: npm ci
run: corepack pnpm install --frozen-lockfile

- name: Run exercism/javascript ci precheck (checks config, lint code, and runs tests) for all exercises
run: npx babel-node scripts/ci-check
run: corepack pnpm node scripts/ci-check.mjs

ci:
runs-on: ubuntu-22.04

strategy:
matrix:
node-version: ['18', '20']
node-version: [20.x, 22.x]

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Enable corepack to fix https://github.com/actions/setup-node/pull/901
run: corepack enable pnpm

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Install project dependencies
run: npm ci
run: corepack pnpm install --frozen-lockfile

- name: Run exercism/javascript ci (checks config, lint code, and runs tests) for all exercises
run: npx babel-node scripts/ci
run: corepack pnpm node scripts/ci.mjs
28 changes: 13 additions & 15 deletions .github/workflows/pr.ci.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,42 @@ jobs:
steps:
- name: Checkout PR
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Enable corepack to fix https://github.com/actions/setup-node/pull/901
run: corepack enable pnpm

- name: Use Node.js LTS (18.x)
- name: Use Node.js LTS (20.x)
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: '18'
node-version: 20.x
cache: 'pnpm'

- name: Install project dependencies
run: npm ci
run: corepack pnpm install --frozen-lockfile

- name: Run exercism/javascript ci precheck (stub files, config integrity) for changed exercises
run: |
PULL_REQUEST_URL=$(jq -r ".pull_request.url" "$GITHUB_EVENT_PATH")
curl --url $"${PULL_REQUEST_URL}/files?per_page=100" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | \
jq -c '.[] | select(.status == "added" or .status == "modified") | select(.filename | match("\\.(js|jsx|md|json)$")) | .filename' | \
xargs -r npx babel-node scripts/pr-check
run: corepack pnpm node scripts/pr.mjs ${{ steps.changed-files.outputs.changed_files }}

ci:
runs-on: ubuntu-22.04

strategy:
matrix:
node-version: ['18', '20']
node-version: [20.x, 22.x]

steps:
- name: Checkout PR
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Enable corepack to fix https://github.com/actions/setup-node/pull/901
run: corepack enable pnpm

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Install project dependencies
run: npm ci
run: corepack pnpm install --frozen-lockfile

- name: Run exercism/javascript ci (runs tests) for changed/added exercises
run: |
PULL_REQUEST_URL=$(jq -r ".pull_request.url" "$GITHUB_EVENT_PATH")
curl --url $"${PULL_REQUEST_URL}/files?per_page=100" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | \
jq -c '.[] | select(.status == "added" or .status == "modified") | select(.filename | match("\\.(js|jsx|md|json)$")) | .filename' | \
xargs -r npx babel-node scripts/pr
run: corepack pnpm node scripts/pr.mjs ${{ steps.changed-files.outputs.changed_files }}
7 changes: 1 addition & 6 deletions .github/workflows/verify-code-formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ jobs:
steps:
- name: 'Checkout code'
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Use Node.js LTS (18.x)
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: '18'
- name: Install project development dependencies
run: npm i

- name: 'Verify formatting of all files'
run: ./bin/check-formatting.sh
15 changes: 4 additions & 11 deletions scripts/helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ export function assertAssignment(assignment, shouldExist = true) {
}

shell.echo("[Failure] that's not a valid assignment reference");
const chalk = require('chalk');

if (assignment.split(path.sep).length === 1) {
// prettier-ignore
shell.echo(`
Expected ${chalk.cyan(`{type}${path.sep}{slug}`)}, actual: ${chalk.yellow(assignment)}.
- Use ${chalk.green(`concept${path.sep}${assignment}`)} if ${chalk.yellow(assignment)} is a concept exercise.
- Use ${chalk.green(`practice${path.sep}${assignment}`)} if ${chalk.yellow(assignment)} is a practice exercise.
Expected ${`{type}${path.sep}{slug}`}, actual: ${assignment}.
- Use ${`concept${path.sep}${assignment}`} if ${assignment} is a concept exercise.
- Use ${`practice${path.sep}${assignment}`} if ${assignment} is a practice exercise.
`.trim());
}

Expand Down Expand Up @@ -172,13 +171,7 @@ export function cleanUp() {
// These packages will be skipped while performing checksum. In other words,
// these packages are only interesting for maintaining this repository and not
// for the student.
const SKIP_PACKAGES_FOR_CHECKSUM = [
'shelljs',
'@babel/node',
'prettier',
'diff',
'chalk',
];
const SKIP_PACKAGES_FOR_CHECKSUM = ['shelljs', 'prettier'];

// These fields may differ between package.json files.
const SKIP_FIELDS_FOR_CHECKSUM = [
Expand Down

0 comments on commit a11146d

Please sign in to comment.