diff --git a/.github/workflows/action-format.yml b/.github/workflows/action-format.yml index aafef6598d..a4d279086e 100644 --- a/.github/workflows/action-format.yml +++ b/.github/workflows/action-format.yml @@ -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 diff --git a/.github/workflows/action-sync.yml b/.github/workflows/action-sync.yml index 950f9230a8..7a3c59ec7d 100644 --- a/.github/workflows/action-sync.yml +++ b/.github/workflows/action-sync.yml @@ -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: | diff --git a/.github/workflows/ci.js.yml b/.github/workflows/ci.js.yml index a0bd09ed76..5dc5559e43 100644 --- a/.github/workflows/ci.js.yml +++ b/.github/workflows/ci.js.yml @@ -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 diff --git a/.github/workflows/pr.ci.js.yml b/.github/workflows/pr.ci.js.yml index ebb70812f8..ea5a3e22bd 100644 --- a/.github/workflows/pr.ci.js.yml +++ b/.github/workflows/pr.ci.js.yml @@ -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 }} diff --git a/.github/workflows/verify-code-formatting.yml b/.github/workflows/verify-code-formatting.yml index 8845830899..b0b20a468a 100644 --- a/.github/workflows/verify-code-formatting.yml +++ b/.github/workflows/verify-code-formatting.yml @@ -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 diff --git a/scripts/helpers.mjs b/scripts/helpers.mjs index ebb3590324..5c596663b7 100644 --- a/scripts/helpers.mjs +++ b/scripts/helpers.mjs @@ -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()); } @@ -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 = [