Skip to content

Commit

Permalink
Yarn 4 + ESLint 9 + PnP Support (3) (#1506)
Browse files Browse the repository at this point in the history
[no important files changed]

* Upgrade to Yarn 4, ESLint 9, and add PnP support

* Upgrade SDKs

* Sync

* Format files

* Fix .vscode files, upgrade all tests to new format

* Update workflows to Node LTS @ 20

* Fix lint issues

* Remove babel transpilation for common actions

* Simplify changed files check

* Ensure tsconfig.json is present

* Switch to corepack yarn
  • Loading branch information
SleeplessByte authored Jul 30, 2024
1 parent 84e5841 commit 4da603e
Show file tree
Hide file tree
Showing 1,361 changed files with 15,441 additions and 102,726 deletions.
13 changes: 0 additions & 13 deletions .eslintignore

This file was deleted.

14 changes: 0 additions & 14 deletions .eslintrc

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/action-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ jobs:
git clone $HEAD_REPO .
git checkout -b "$HEAD_REF" "origin/$HEAD_REF"
- name: Use Node.js LTS (18.x)
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
- name: Use Node.js LTS (20.x)
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: '18'
node-version: 20.x
- name: Install project development dependencies
run: npm install --no-save
- name: 'Format code'
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 yarn
corepack yarn install
- name: 'Sync exercises'
run: yarn sync
run: corepack yarn sync

- name: 'Commit changes'
run: |
Expand Down
34 changes: 20 additions & 14 deletions .github/workflows/ci.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,41 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
- name: Use Node.js LTS (18.x)
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Use Node.js LTS (20.x)
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: 18.x
node-version: 20.x

- name: Install project dependencies
run: yarn install --frozen-lockfile
run: |
corepack enable yarn
corepack yarn install --immutable
- name: Run exercism/typescript ci precheck (checks config, lint code, and runs tests) for all exercises
run: yarn ci:check
run: corepack yarn ci:check

ci:
runs-on: ubuntu-22.04

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

steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: ${{ matrix.node-version }}

- name: Install project dependencies
run: yarn install --frozen-lockfile
run: |
corepack enable yarn
corepack yarn install --immutable
- name: Run exercism/typescript ci (checks config, lint code, and runs tests) for all exercises
run: yarn ci
run: corepack yarn ci

impersonate:
# This job tries to run tests for the 'hello-world' exercise, but
Expand All @@ -54,7 +58,7 @@ jobs:
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- name: Use Node.js 20.x
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: 20.x

Expand All @@ -69,8 +73,10 @@ jobs:
- name: Install project dependencies
working-directory: exercises/practice/hello-world
run: yarn install --no-immutable
run: |
corepack enable yarn
corepack yarn install --immutable
- name: Run tests
working-directory: exercises/practice/hello-world
run: yarn test
run: corepack yarn test
66 changes: 42 additions & 24 deletions .github/workflows/pr.ci.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,64 @@ jobs:

steps:
- name: Checkout PR
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac

- name: Use Node.js LTS (18.x)
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- name: Get changed files
id: changed-files
run: |
if ${{ github.event_name == 'pull_request' }}; then
echo "changed_files=$(git diff --name-only --diff-filter=ACM -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
else
echo "changed_files=$(git diff --name-only --diff-filter=ACM ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
fi
- name: Use Node.js LTS (20.x)
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: 18.x
node-version: 20.x

- name: Install project dependencies
run: yarn install --frozen-lockfile
run: |
corepack enable yarn
corepack yarn install --immutable
- name: Run exercism/typescript 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|ts|tsx|md|json)$")) | .filename' | \
xargs -r yarn dlx -p @babel/core -p @babel/node babel-node scripts/pr-check
run: corepack yarn node scripts/pr-check.mjs ${{ steps.changed-files.outputs.changed_files }}

ci:
runs-on: ubuntu-22.04

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

steps:
- name: Checkout PR
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- name: Get changed files
id: changed-files
run: |
if ${{ github.event_name == 'pull_request' }}; then
echo "changed_files=$(git diff --name-only --diff-filter=ACM -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
else
echo "changed_files=$(git diff --name-only --diff-filter=ACM ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
fi
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: ${{ matrix.node-version }}

- name: Install project dependencies
run: yarn install --frozen-lockfile
run: |
corepack enable yarn
corepack yarn install --immutable
- name: Run exercism/typescript 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|ts|tsx|md|json)$")) | .filename' | \
xargs -r yarn dlx -p @babel/core -p @babel/node babel-node scripts/pr
run: corepack yarn node scripts/pr.mjs ${{ steps.changed-files.outputs.changed_files }}

impersonate:
# This job tries to run tests for the 'hello-world' exercise, but
Expand All @@ -62,9 +78,9 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Use Node.js 20.x
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: 20.x

Expand All @@ -79,8 +95,10 @@ jobs:
- name: Install project dependencies
working-directory: exercises/practice/hello-world
run: yarn install --no-immutable
run: |
corepack enable yarn
corepack yarn install --no-immutable
- name: Run tests
working-directory: exercises/practice/hello-world
run: yarn test
run: corepack yarn test
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ bin/configlet.exe
!/.yarn/versions

# Maintainer specific generated files
/exercises/**/yarn.lock
/tmp_exercises
/tmp
exercise-package.json
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
exercises/**/README.md
!/README.md

.vscode/**/*
.yarn/**/*

# Originates from https://github.com/exercism/org-wide-files
CODE_OF_CONDUCT.md
LICENSE
Expand Down
8 changes: 1 addition & 7 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,5 @@
"singleQuote": true,
"arrowParens": "always",
"printWidth": 80,
"endOfLine": "lf",
"overrides": [
{
"files": "*.ts",
"options": { "parser": "typescript" }
}
]
"endOfLine": "lf"
}
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"arcanis.vscode-zipfs",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}
12 changes: 11 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{
"cSpell.words": ["exercism"]
"cSpell.words": [
"exercism"
],
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
},
"eslint.nodePath": ".yarn/sdks",
"prettier.prettierPath": ".yarn/sdks/prettier/index.cjs",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
Loading

0 comments on commit 4da603e

Please sign in to comment.