I'm currently having issues with my performance tests running in the pipeline. I'm using Artillery to execute performance tests on a nightly CRON schedule and the workflow leverages Artillery's container: artilleryio/artillery:latest
.
The issue I'm having is I can't run npm ci
in the pipeline. I haven't been able to find a solution online. The only solution I've seen is npm clean cache
, but that isn't working.
Error:
npm ERR! code 1
npm ERR! git dep preparation failed
npm ERR! command /usr/local/bin/node /__t/node/16.20.0/x64/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/github/home/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm ERR! code FETCH_ERROR
npm ERR! npm ERR! errno FETCH_ERROR
npm ERR! npm ERR! invalid json response body at https://registry.npmjs.org/jsesc reason: Invalid response body while trying to fetch https://registry.npmjs.org/jsesc: EACCES: permission denied, mkdir '/github/home/.npm/_cacache/content-v2/sha512/b6/68'
I'm able to run the Artillery perf tests locally. This is only an issue running npm ci
in the pipeline using the Artillery container.
Workflow:
jobs:
performance-tests:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
environment:
name: dev
container: artilleryio/artillery:latest
steps:
- name: NPM Clean
run: npm cache clean --force
- name: NPM Install
run: npm ci
- name: Run Performance Tests
env:
# Insert required env variables for e2e tests below
AUTHORIZATION_LOGIN_PATH: ""
run: //home/node/artillery/bin/run run -o notification.json test/performance/perf-tests.yml
- name: Generate Performance Test
run: //home/node/artillery/bin/run report --output notification.html notification.json
You can also use Artillery’s official GitHub Action for this, so you can just do:
jobs:
artillery:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Run performance tests
uses: artilleryio/action-cli@v1
with:
command: run test/performance/perf-tests.yml
Their documentation has more relevant info and use cases too: