Skip to content

Commit

Permalink
Force corepack usage
Browse files Browse the repository at this point in the history
  • Loading branch information
SleeplessByte committed Jul 30, 2024
1 parent 2fba90f commit 57c091b
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 56 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
- name: Install project dependencies
run: |
corepack enable yarn
yarn -v
yarn install --immutable
corepack yarn -v
corepack yarn install --immutable
- name: Run exercism/typescript-test-runner ci precheck (lint code)
run: bin/lint.sh
Expand All @@ -44,8 +44,8 @@ jobs:
- name: Install project dependencies
run: |
corepack enable yarn
yarn -v
yarn install --immutable
corepack yarn -v
corepack yarn install --immutable
- name: Build the test-runner (using Node ${{ matrix.node-version }})
run: bin/test.sh
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pr.ci.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
- name: Install project dependencies
run: |
corepack enable yarn
yarn -v
yarn install --immutable
corepack yarn -v
corepack yarn install --immutable
- name: Run exercism/javascript ci precheck (lint code)
run: bin/lint.sh
Expand All @@ -46,8 +46,8 @@ jobs:
- name: Install project dependencies
run: |
corepack enable yarn
yarn -v
yarn install --immutable
corepack yarn -v
corepack yarn install --immutable
- name: Build the test-runner (using Node ${{ matrix.node-version }})
run: bin/test.sh
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ RUN chmod 555 /idk/corepack
# Build the test runner
RUN set -ex; \
# install all the development modules (used for building)
yarn cache clean; \
yarn install; \
yarn build;
# yarn cache clean; \
corepack yarn cache clean; \
corepack yarn install; \
corepack yarn build;
# corepack yarn cache clean; \
#
# install only the node_modules we need for production
# I don't know how to get this to work with zero-installs enabled
#
# TODO: yarn workspaces focus --production;
# TODO: corepack yarn workspaces focus --production;

# Disable network for corepack
ENV COREPACK_ENABLE_NETWORK=0
Expand All @@ -59,6 +59,6 @@ ENV YARN_ENABLE_OFFLINE_MODE=1
ENV YARN_ENABLE_HARDENED_MODE=0

# Let's check to be certain
RUN yarn --version
RUN corepack yarn --version

ENTRYPOINT [ "/opt/test-runner/bin/run.sh" ]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ corepack yarn build

If you're developing this, you can run this via `yarn` or the provided shell script.

- `.sh` enabled systems (UNIX, WSL): `yarn execute:dev`
- `.sh` enabled systems (UNIX, WSL): `corepack yarn execute:dev`
- `.bat` fallback (cmd.exe, Git Bash for Windows): _unsupported_

You'll want these `:dev` variants because it will _build_ the required code (it will transpile from TypeScript to JavaScript, which is necessary to run this in Node environments, unlike Deno environments).
When on Windows, if you're using Git Bash for Windows or a similar terminal, the `.sh` files will work, but will open a new window (which closes after execution).
The `.bat` scripts will work in the same terminal.
In this case it might be much easier to run `bin/run.sh` directly, so a new shell won't open.

You can also manually build using `yarn` or `yarn build`, and then run the script directly: `./bin/run.sh arg1 arg2 arg3`.
You can also manually build using `corepack yarn` or `corepack yarn build`, and then run the script directly: `./bin/run.sh arg1 arg2 arg3`.

## Running the Solution's Tests

Expand Down Expand Up @@ -120,7 +120,7 @@ corepack yarn dlx @yarnpkg/sdks vscode
### Testing

Running the tests of the test-runner itself can be achieved by using the `test` script from `package.json`.
The tests delegate to the _build output_, which is why `yarn test` first calls `yarn build` before running `jest`.
The tests delegate to the _build output_, which is why `corepack yarn test` first calls `corepack yarn build` before running `corepack yarn test:bare`.
**The tests take over a minute to run on a decent machine**.

[web-exercism]: https://exercism.io
Expand Down
28 changes: 14 additions & 14 deletions bin/check-formatting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ corepack enable yarn

if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then
echo "[format] pulling prettier version from yarn.lock using sed"
EXERCISM_PRETTIER_VERSION="$(yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')"
EXERCISM_PRETTIER_VERSION="$(corepack yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')"
echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}"
fi

if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then
echo "Version could not be pulled using sed" >&2
echo "[format] pulling prettier version from yarn.lock using grep"
EXERCISM_PRETTIER_VERSION="$(yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')"
EXERCISM_PRETTIER_VERSION="$(corepack yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')"
echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}"
fi

Expand All @@ -24,23 +24,23 @@ if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work."
echo "Please see https://exercism.org/docs/building/markdown/style-guide for guidance."
echo "---------------------------------------------------"
echo "$(yarn -v)"
echo "$(corepack yarn -v)"
echo ""
echo "This is what yarn why reports:"
echo "$ yarn why prettier"
echo "$(yarn why prettier)"
echo "This is what corepack yarn why reports:"
echo "$ corepack yarn why prettier"
echo "$(corepack yarn why prettier)"
echo ""
echo "And yarn info reports the following:"
echo "$ yarn info prettier --name-only"
echo "$(yarn info prettier --name-only)"
echo "And corepack yarn info reports the following:"
echo "$ corepack yarn info prettier --name-only"
echo "$(corepack yarn info prettier --name-only)"
echo ""
echo "This is the version that can be extracted using grep:"
echo "$ yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+'"
echo "└─ $(yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')"
echo "$ corepack yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+'"
echo "└─ $(corepack yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')"
echo ""
echo "This is the version that can be extracted using sed:"
echo "$ yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p'"
echo "└─ $(yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')"
echo "$ corepack yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p'"
echo "└─ $(corepack yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')"
echo ""
echo "These files are found in the repo root:"
echo "$(ls -p | grep -v /)"
Expand All @@ -50,4 +50,4 @@ else
echo "[format] running with prettier@$EXERCISM_PRETTIER_VERSION"
fi

yarn dlx "prettier@$EXERCISM_PRETTIER_VERSION" --check "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}"
corepack yarn dlx "prettier@$EXERCISM_PRETTIER_VERSION" --check "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}"
28 changes: 14 additions & 14 deletions bin/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ corepack enable yarn

if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then
echo "[format] pulling prettier version from yarn.lock using sed"
EXERCISM_PRETTIER_VERSION="$(yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')"
EXERCISM_PRETTIER_VERSION="$(corepack yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')"
echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}"
fi

if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then
echo "Version could not be pulled using sed" >&2
echo "[format] pulling prettier version from yarn.lock using grep"
EXERCISM_PRETTIER_VERSION="$(yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')"
EXERCISM_PRETTIER_VERSION="$(corepack yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')"
echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}"
fi

Expand All @@ -24,23 +24,23 @@ if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work."
echo "Please see https://exercism.org/docs/building/markdown/style-guide for guidance."
echo "---------------------------------------------------"
echo "$(yarn -v)"
echo "$(corepack yarn -v)"
echo ""
echo "This is what yarn why reports:"
echo "$ yarn why prettier"
echo "$(yarn why prettier)"
echo "This is what corepack yarn why reports:"
echo "$ corepack yarn why prettier"
echo "$(corepack yarn why prettier)"
echo ""
echo "And yarn info reports the following:"
echo "$ yarn info prettier --name-only"
echo "$(yarn info prettier --name-only)"
echo "And corepack yarn info reports the following:"
echo "$ corepack yarn info prettier --name-only"
echo "$(corepack yarn info prettier --name-only)"
echo ""
echo "This is the version that can be extracted using grep:"
echo "$ yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+'"
echo "└─ $(yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')"
echo "$ corepack yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+'"
echo "└─ $(corepack yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')"
echo ""
echo "This is the version that can be extracted using sed:"
echo "$ yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p'"
echo "└─ $(yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')"
echo "$ corepack yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p'"
echo "└─ $(corepack yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')"
echo ""
echo "These files are found in the repo root:"
echo "$(ls -p | grep -v /)"
Expand All @@ -50,4 +50,4 @@ else
echo "[format] running with prettier@$EXERCISM_PRETTIER_VERSION"
fi

yarn dlx "prettier@$EXERCISM_PRETTIER_VERSION" --write "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}"
corepack yarn dlx "prettier@$EXERCISM_PRETTIER_VERSION" --write "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}"
2 changes: 1 addition & 1 deletion bin/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set -euo pipefail

corepack enable yarn
yarn lint
corepack yarn lint
4 changes: 2 additions & 2 deletions bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
set -euo pipefail

corepack enable yarn
yarn build || exit
yarn test:bare
corepack yarn build || exit
corepack yarn test:bare
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
"bin": "bin/run.sh",
"scripts": {
"execute": "./bin/run.sh",
"execute:dev": "yarn build && yarn execute",
"execute:dev": "corepack yarn build && corepack yarn execute",
"prebuild": "rimraf ./dist",
"build": "yarn tsc --project ./src/tsconfig.json --outDir ./dist",
"watch": "yarn build -w",
"prepack": "yarn build",
"prepublish": "yarn test:bare && yarn lint",
"lint": "yarn eslint src -c eslint.config.mjs && yarn eslint test -c eslint.config.mjs",
"test": "yarn build && yarn test:bare",
"test:bare": "yarn node test/smoke.test.mjs && yarn node test/skip.test.mjs && yarn node test/import.test.mjs"
"build": "corepack yarn tsc --project ./src/tsconfig.json --outDir ./dist",
"watch": "corepack yarn build -w",
"prepack": "corepack yarn build",
"prepublish": "corepack yarn test:bare && corepack yarn lint",
"lint": "corepack yarn eslint src -c eslint.config.mjs && corepack yarn eslint test -c eslint.config.mjs",
"test": "corepack yarn build && corepack yarn test:bare",
"test:bare": "corepack yarn node test/smoke.test.mjs && corepack yarn node test/skip.test.mjs && corepack yarn node test/import.test.mjs"
},
"dependencies": {
"@exercism/babel-preset-typescript": "^0.5.0",
Expand Down

0 comments on commit 57c091b

Please sign in to comment.