Skip to content

Commit

Permalink
fix: support cache computation on windows (#157)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
GerkinDev and EricRibeiro authored Sep 28, 2022
1 parent 543c774 commit 589b116
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
25 changes: 24 additions & 1 deletion .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -287,6 +306,10 @@ workflows:
filters:
tags:
only: /.*/
- integration-test-override-ci-windows:
filters:
tags:
only: /.*/
- integration-test-yarn:
filters:
tags:
Expand Down
14 changes: 10 additions & 4 deletions src/scripts/packages/determine-lockfile.sh
Original file line number Diff line number Diff line change
@@ -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

cp package.json $TARGET_DIR/node-project-package.json

0 comments on commit 589b116

Please sign in to comment.