From 589b11670efb218c5c67d23ced3aaf155adf7a69 Mon Sep 17 00:00:00 2001 From: Gerkin Date: Wed, 28 Sep 2022 23:10:23 +0200 Subject: [PATCH] fix: support cache computation on windows (#157) * fix: support cache computation on windows On windows runners, the cache keys fails to be computed because of the `checksum` function that can't find the file in /tmp. Indeed, it seems that bash `/tmp` is not the runner's `C:\tmp` directory. See https://app.circleci.com/pipelines/github/KnodesCommunity/typedoc-plugins/693/workflows/897cb674-230e-46ae-99f5-b10d93f4b723/jobs/3872/parallel-runs/0/steps/0-106 for an example of failed step * Update determine-lockfile.sh * Add quote to variable expansion * remove trailing backslash * ci: add tests for the windows executor Co-authored-by: Eric Ribeiro --- .circleci/test-deploy.yml | 25 +++++++++++++++++++++- src/scripts/packages/determine-lockfile.sh | 14 ++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index e73a4b5..2e89db7 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -29,7 +29,11 @@ executors: machine: machine: image: ubuntu-2004:202111-01 - + windows: + machine: + image: windows-server-2022-gui:current + shell: bash.exe + resource_class: windows.medium jobs: # Install Node.js into a non-node container. integration-test-install-specified-version: @@ -110,6 +114,21 @@ jobs: cache-version: override-v3 app-dir: "~/project/sample" - run: cd ~/project/sample && npm run test + integration-test-override-ci-windows: + executor: windows + steps: + - checkout + - run: + name: Install Node.js + command: | + nvm install lts + nvm use lts + - node/install-packages: + override-ci-command: npm install + cache-path: ~/project/node_modules + cache-version: override-v3 + app-dir: "~/project/sample" + - run: cd ~/project/sample && npm run test integration-test-yarn: executor: name: node/default @@ -287,6 +306,10 @@ workflows: filters: tags: only: /.*/ + - integration-test-override-ci-windows: + filters: + tags: + only: /.*/ - integration-test-yarn: filters: tags: diff --git a/src/scripts/packages/determine-lockfile.sh b/src/scripts/packages/determine-lockfile.sh index 6002d23..9ab65c5 100644 --- a/src/scripts/packages/determine-lockfile.sh +++ b/src/scripts/packages/determine-lockfile.sh @@ -1,12 +1,18 @@ +TARGET_DIR="/tmp" +if [ -n "$HOMEDRIVE" ]; then + TARGET_DIR="$HOMEDRIVE\\tmp" +fi + # Link corresponding lock file to a temporary file used by cache commands if [ -f "package-lock.json" ]; then echo "Found package-lock.json file, assuming lockfile" - cp package-lock.json /tmp/node-project-lockfile + cp package-lock.json $TARGET_DIR/node-project-lockfile elif [ -f "npm-shrinkwrap.json" ]; then echo "Found npm-shrinkwrap.json file, assuming lockfile" - cp npm-shrinkwrap.json /tmp/node-project-lockfile + cp npm-shrinkwrap.json $TARGET_DIR/node-project-lockfile elif [ -f "yarn.lock" ]; then echo "Found yarn.lock file, assuming lockfile" - cp yarn.lock /tmp/node-project-lockfile + cp yarn.lock $TARGET_DIR/node-project-lockfile fi -cp package.json /tmp/node-project-package.json \ No newline at end of file + +cp package.json $TARGET_DIR/node-project-package.json