From e255a87c7a0f12f975ff4ca546ab063960dce9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Tue, 18 Jun 2024 08:50:32 +0200 Subject: [PATCH] Enable corepack if `packageManager` is defined (#241) --- .github/actions/base-setup/action.yml | 5 +++++ .github/workflows/tests.yml | 8 +++++++- package.json | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/actions/base-setup/action.yml b/.github/actions/base-setup/action.yml index a4193d8..d944efb 100644 --- a/.github/actions/base-setup/action.yml +++ b/.github/actions/base-setup/action.yml @@ -73,6 +73,11 @@ runs: id: yarn-cache-dir-path shell: bash run: | + # Enable corepack if the project defines packageManager + if [ -f package.json ]; then + export HAS_PKG_MANAGER=$(grep -e \"packageManager\"\: package.json) + if [ ! -z "$HAS_PKG_MANAGER" ]; then corepack enable; fi + fi CACHE_DIR=$(yarn config get cacheFolder) [[ "$CACHE_DIR" == "undefined" ]] && CACHE_DIR=$(yarn cache dir) echo "dir=$CACHE_DIR" >> $GITHUB_OUTPUT diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2e14051..2350dde 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -62,7 +62,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + - uses: ./.github/actions/base-setup - name: Run Linters run: | hatch run typing:test @@ -162,6 +162,9 @@ jobs: run: | mkdir -p ${TEST_FOLDER}/tests/example.spec.ts-snapshots pushd ${TEST_FOLDER} + + # Prevent yarn to look up in the folder hierarchy + touch yarn.lock yarn init -yp yarn add -D @playwright/test cat package.json | jq '. += {"scripts": {"start": "echo starting...", "test:update": "yarn playwright test -u"}}' > new_package.json @@ -205,6 +208,9 @@ jobs: run: | mkdir -p ${TEST_FOLDER}/tests/example.spec.ts-snapshots pushd ${TEST_FOLDER} + + # Prevent yarn to look up in the folder hierarchy + touch yarn.lock yarn init -yp yarn add -D @playwright/test cat package.json | jq '. += {"scripts": {"test:update": "yarn playwright test -u"}}' > new_package.json diff --git a/package.json b/package.json index d661637..07ae36b 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "@jupyterlab/maintainer-tools", "version": "0.25.9", - "private": true + "private": true, + "packageManager": "yarn@3.5.0" }