npm-audit-nodejs-12-ci.yml 1.03 KB
Newer Older
1
npm_audit_dependency_check:
SBassett's avatar
SBassett committed
2
    image: docker-registry.wikimedia.org/nodejs12-devel:0.0.1
SBassett's avatar
SBassett committed
3
    stage: test
SBassett's avatar
SBassett committed
4
    allow_failure: false
Mstyles's avatar
Mstyles committed
5
    
SBassett's avatar
SBassett committed
6
    variables:
7
        NPM_AUDIT_OPTIONS: "--moderate=true --skip-dev=true --report=true"
Mstyles's avatar
Mstyles committed
8
9
   
    before_script:
SBassett's avatar
SBassett committed
10
        - apt-get update -yqq && apt-get install -yqq git
Mstyles's avatar
Mstyles committed
11
12
        - npm install -g audit-ci

SBassett's avatar
SBassett committed
13
    script:
14
15
16
17
18
19
20
21
22
        - |
          root_dir=$(pwd)
          file_list=$(git diff-tree --no-commit-id --name-only -r $CI_COMMIT_SHA -- \
          {*package.json,*package-lock.json,*/package.json,*/package-lock.json})

          for f in $file_list; do
            npm_dir="$(dirname "$f")"
            cd $root_dir/$npm_dir
            npm install
SBassett's avatar
SBassett committed
23
24
25
            echo -e "\n "
            echo -e "----- $f -----"
            echo -e "\n "
26
27
            audit-ci ${NPM_AUDIT_OPTIONS}
          done
Mstyles's avatar
Mstyles committed
28
29
30
31
32
33
34
35
    
    # only run on changes to package and package.lock .json
    only:
        changes:
            - package.json
            - package-lock.json
            - "**/*package.json"
            - "**/*package-lock.json"