.gitlab-ci.yml 3.4 KB
Newer Older
1 2 3 4
include:
  - template: SAST.gitlab-ci.yml
  - template: Dependency-Scanning.gitlab-ci.yml
  - template: License-Scanning.gitlab-ci.yml
5
  - template: Secret-Detection.gitlab-ci.yml
6

7 8 9 10 11 12 13 14 15 16 17
# run the pipeline only on MRs, tags, and default branch
workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_TAG
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

default:
  tags:
    - gitlab-org

18
image: node:14-slim
19 20 21

stages:
  - test
22
  - package
23
  - publish
24 25 26 27

lint:
  stage: test
  script:
28
    - npm ci
29 30
    - cd src/webview && npm ci && cd ../.. # webview dependencies
    - npm run lint
31

32 33 34 35 36 37 38 39
lint_commit:
  stage: test
  script:
    - apt-get update && apt-get install -y git
    - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME && git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME && git checkout $CI_COMMIT_SHA
    - cd scripts/commit-lint && npm ci
    - node lint.js
  rules:
40
    - if: '$CI_MERGE_REQUEST_IID && $CI_PROJECT_VISIBILITY == "public"' # lint.js script makes an API call without authentication
41 42
      when: always

43 44 45 46 47 48 49
check-ci-variables:
  stage: test
  script:
    - npm ci
    - npm run update-ci-variables
  allow_failure: true # could be caused by changes in gitlab-org/gitlab repo, not related to current branch

T
Tomas Vik 已提交
50 51 52
test-unit:
  stage: test
  script:
T
Tomas Vik 已提交
53
    - apt-get update && apt-get install -y git
T
Tomas Vik 已提交
54
    - npm ci
K
Kev 已提交
55
    - npm run test-unit -- --coverage
F
Felix Haase 已提交
56 57 58 59 60
  artifacts:
    when: always
    reports:
      junit:
        - reports/unit.xml
T
Tomas Vik 已提交
61

62 63 64 65 66 67
test-integration:
  stage: test
  variables:
    DISPLAY: ':99.0'
  script:
    - apt-get update
T
Tomas Vik 已提交
68
    - apt-get install -y xvfb libxtst6 libnss3 libgtk-3-0 libxss1 libasound2 libsecret-1-0 git
69
    - npm ci
70 71
    - echo $DISPLAY
    - /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
T
Tomas Vik 已提交
72
    - npm run test-integration
F
Felix Haase 已提交
73 74 75 76 77
  artifacts:
    when: always
    reports:
      junit:
        - reports/integration.xml
78

79 80 81 82 83 84 85
test-webview:
  stage: test
  script:
    - cd src/webview
    - npm ci
    - npm run test

T
Tomas Vik 已提交
86
.package:
87
  stage: package
88
  script:
89 90
    - npm ci
    - cd src/webview && npm install && npm run build && cd ../.. # build webview
91 92 93 94
    - npx vsce package
  artifacts:
    paths:
      - '*.vsix'
T
Tomas Vik 已提交
95 96 97 98 99

package_release:
  extends: .package
  artifacts:
      expire_in: 1 year
100 101 102
  only:
    - tags

T
Tomas Vik 已提交
103 104 105 106 107 108 109
# We test that packaging works to prevent failed releases
# Without this task we would only find out packaging errors after tagging a release
package_test:
  extends: .package
  artifacts:
      expire_in: 10 days

110 111 112
publish_marketplace:
  stage: publish
  script:
T
Tomas Vik 已提交
113
    - npx vsce publish --packagePath *.vsix -p $AZURE_ACCESS_TOKEN
114 115 116
  when: manual
  only:
    - tags
117 118 119 120 121 122 123 124 125

publish_open_vsx:
  stage: publish
  script:
    - npx ovsx publish *.vsix -p $OPENVSX_ACCESS_TOKEN
  when: manual
  only:
    - tags

126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
# Override security scanning rules to run every time this pipeline does
# This potentially can be made obsolete once:
# https://gitlab.com/gitlab-org/gitlab/-/issues/217668 lands
.secure-jobs-config: &secure-jobs-config
  needs: []
  rules:
    - when: on_success

retire-js-dependency_scanning:
  <<: *secure-jobs-config

gemnasium-dependency_scanning:
  <<: *secure-jobs-config

license_scanning:
  <<: *secure-jobs-config

eslint-sast:
  <<: *secure-jobs-config

nodejs-scan-sast:
  <<: *secure-jobs-config

149
secret_detection:
150
  <<: *secure-jobs-config
151 152 153
  # We can't run the secrets detection on tags: https://gitlab.com/gitlab-org/gitlab/-/issues/254199
  rules:
    - if: $CI_COMMIT_TAG
154
      when: 'never'