Skip to content

Commit

Permalink
Switch to pnpm, ESLint 9, and helpful output (#852)
Browse files Browse the repository at this point in the history
* Switch to pnpm, ESLint 9, and helpful output

* Replace references of yarn with pnpm

* Use published packages

* Bump version of docker/build-push-action

* Attempt to enable pnpm to read prettier version

* Fix test

* Try lts/* for .nvmrc

* Fix tests

* Fix unbound variable issue

* Use pnpm list instead of why

* Correctly clear cache using store prune

* Attempt to fix formatting actions

* Disable store prune for now

* Prune dev dependencies

* Make binaries executable hopefully

* Log the .bin folder

* idk?

* Chown it then I guess?

* Don't symlink executables

* Attempt to own and execute as appuser

* Okay later then

* Remove all changes to ownership for now

* Print executability

* Log more things

* Debug promise

* Hopefully fix the slug issue

* Try alternatives

* Other alternatives

* Don't cd into output

* Correctly cd into directory when needed

* Hopefully detect the docker run issue

* Maybe chown will fix it?

* With full path

* Different ls options

* Print ls in case of not executable

* Fix typo

* idk

* Show whoami

* Show whomai for real

* Separate tests for jest bin file

* Woops, fix that remnant

* Ignore appuser for now

* Show me that env

* Re-enable appuser

* Debug etc/passwd

* Debug mounts

* Make tmp executable for now

* Also make this one executable temporarily

* Collate layers

* Try jest without corepack root

* Ensure no tmpfs for tests if running in docker without exec

* Woops, typo

* Fix empty continuation

* Probably fix issue with path?

* Remove :exec flag

* Make executable again

* Print mount before tests

* Always use bash please

* Remove option :exec not supported by --mount

* Hopefully make the tests work

* Remove color from expected results (docker only)

* Fix expected results for clock

* Add npm test
  • Loading branch information
SleeplessByte authored Nov 1, 2024
1 parent 93f6cba commit 9a4050b
Show file tree
Hide file tree
Showing 61 changed files with 7,357 additions and 9,626 deletions.
18 changes: 0 additions & 18 deletions .eslintignore

This file was deleted.

8 changes: 0 additions & 8 deletions .eslintrc.js

This file was deleted.

12 changes: 7 additions & 5 deletions .github/workflows/action-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ 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'
- name: Install project development dependencies
run: npm install --no-save
node-version: 20.x
- name: Enable pnpm
run: |
corepack enable pnpm
corepack pnpm -v
- name: 'Format code'
run: ./bin/format.sh

Expand Down
26 changes: 16 additions & 10 deletions .github/workflows/ci.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ jobs:
runs-on: ubuntu-22.04

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

- name: Install project dependencies
run: yarn install --immutable
run: |
corepack enable pnpm
corepack pnpm -v
corepack pnpm install --frozen-lockfile
- name: Run exercism/javascript-test-runner ci precheck (lint code)
run: bin/lint.sh
Expand All @@ -29,23 +32,26 @@ jobs:

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

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- 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 --immutable
run: |
corepack enable pnpm
corepack pnpm -v
corepack pnpm install --frozen-lockfile
- name: Build the test-runner (using Node ${{ matrix.node-version }})
run: bin/test.sh

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db
uses: docker/setup-buildx-action@4c0219f9ac95b02789c1075625400b2acbff50b1
with:
install: true

Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/pr.ci.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ jobs:
- name: Checkout PR
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- name: Use Node.js LTS (18.x)
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
- name: Use Node.js LTS
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: 18.x
node-version-file: .nvmrc

- name: Install project dependencies
run: yarn install --immutable
run: |
corepack enable pnpm
corepack pnpm -v
corepack pnpm install --frozen-lockfile
- name: Run exercism/javascript ci precheck (lint code)
run: bin/lint.sh
Expand All @@ -29,25 +32,28 @@ jobs:

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

steps:
- name: Checkout PR
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install project dependencies
run: yarn install --immutable
run: |
corepack enable pnpm
corepack pnpm -v
corepack pnpm install --frozen-lockfile
- name: Build the test-runner (using Node ${{ matrix.node-version }})
run: bin/test.sh

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db
uses: docker/setup-buildx-action@4c0219f9ac95b02789c1075625400b2acbff50b1
with:
install: true

Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/verify-code-formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,15 @@ jobs:
- name: 'Checkout code'
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

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

- name: Enable pnpm
run: |
corepack enable pnpm
corepack pnpm -v
- name: 'Verify formatting of all files'
run: ./bin/check-formatting.sh
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node-linker=hoisted
symlink=false
prefer-symlinked-executables=false
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/*
28 changes: 0 additions & 28 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

This file was deleted.

874 changes: 0 additions & 874 deletions .yarn/releases/yarn-3.6.0.cjs

This file was deleted.

7 changes: 0 additions & 7 deletions .yarnrc.yml

This file was deleted.

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 5.0.0

- Update dependencies including core-js
- Switch to pnpm
- Rework `run.sh` for console friendly output
- Use ESLint 9 (Flat Config)

## 4.0.0

- Update dependencies including core-js
Expand Down
46 changes: 35 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:18-bullseye-slim as runner
# Node.js 18 (curently LTS)
# Debian bullseye
FROM node:20-bookworm-slim AS runner
# Node.js 20 (curently LTS)
# Debian bookwork

# fetch latest security updates
RUN set -ex; \
Expand All @@ -18,17 +18,41 @@ RUN adduser --disabled-password --gecos "" appuser
WORKDIR /opt/test-runner
COPY . .

# Install pnpm so it will be available read-only
# https://github.com/nodejs/corepack/issues/183#issue-1379672431
# https://github.com/nodejs/corepack/blob/bc13d40037d0b1bfd386e260ae741f55505b5c7c/tests/main.test.ts#L483
RUN mkdir -p /idk/corepack
ENV COREPACK_HOME=/idk/corepack

RUN set -ex; \
corepack enable pnpm; \
# corepack pack -o ./corepack.tgz; \
# COREPACK_ENABLE_NETWORK=0 corepack install -g ./corepack.tgz;
#
# https://github.com/nodejs/corepack/pull/446#issue-2218976611
corepack install; \
corepack pnpm --version; \
#
# https://github.com/nodejs/corepack/issues/414#issuecomment-2096218732
# https://github.com/nodejs/corepack/blob/bc13d40037d0b1bfd386e260ae741f55505b5c7c/sources/folderUtils.ts#L26-L31
chmod 444 /idk/corepack/lastKnownGood.json; \
chmod 555 /idk/corepack;

# Build the test runner
RUN set -ex; \
# install all the development modules (used for building)
yarn plugin import workspace-tools; \
yarn install; \
yarn build; \
rm -rf node_modules; \
# install only the node_modules we need for production
yarn workspaces focus --production; \
# clean our yarn cache
yarn cache clean;
# corepack pnpm store prune; \
corepack pnpm install; \
corepack pnpm build; \
corepack pnpm prune --prod;

# Disable network for corepack
ENV COREPACK_ENABLE_NETWORK=0
ENV COREPACK_ENABLE_STRICT=0

# Mark this as a docker run so we don't try to execute things in /tmp
ENV TMP_MAY_BE_NON_EXEC=1

# Execute everything as the appuser
USER appuser
ENTRYPOINT [ "/opt/test-runner/bin/run.sh" ]
Loading

0 comments on commit 9a4050b

Please sign in to comment.