|
| 1 | +name: Run test and build |
| 2 | +description: Test and build action, reused among workflows |
| 3 | +inputs: |
| 4 | + SEGMENT_KEY: |
| 5 | + required: true |
| 6 | + ARTIFACTORY_HOST: |
| 7 | + required: true |
| 8 | + ARTIFACTORY_PASSWORD: |
| 9 | + required: true |
| 10 | + ARTIFACTORY_USERNAME: |
| 11 | + required: true |
| 12 | + GARASIGN_PASSWORD: |
| 13 | + required: true |
| 14 | + GARASIGN_USERNAME: |
| 15 | + required: true |
| 16 | + SNYK_TOKEN: |
| 17 | + required: true |
| 18 | + JIRA_API_TOKEN: |
| 19 | + required: true |
| 20 | + |
| 21 | +runs: |
| 22 | + using: "composite" |
| 23 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 24 | + steps: |
| 25 | + - name: Install Deps Ubuntu |
| 26 | + if: ${{ runner.os == 'Linux' }} |
| 27 | + run: sudo apt-get update -y && sudo apt-get -y install libkrb5-dev libsecret-1-dev net-tools libstdc++6 gnome-keyring |
| 28 | + shell: bash |
| 29 | + |
| 30 | + # Default Python (3.12) doesn't have support for distutils because of |
| 31 | + # which the dep install fails constantly on macos |
| 32 | + # https://github.com/nodejs/node-gyp/issues/2869 |
| 33 | + - uses: actions/setup-python@v4 |
| 34 | + with: |
| 35 | + python-version: '3.11' |
| 36 | + |
| 37 | + - name: Run node-gyp bug workaround script |
| 38 | + run: | |
| 39 | + curl -sSfLO https://raw.githubusercontent.com/mongodb-js/compass/42e6142ae08be6fec944b80ff6289e6bcd11badf/.evergreen/node-gyp-bug-workaround.sh && bash node-gyp-bug-workaround.sh |
| 40 | + shell: bash |
| 41 | + |
| 42 | + - name: Set SEGMENT_KEY |
| 43 | + env: |
| 44 | + SEGMENT_KEY: ${{ inputs.SEGMENT_KEY }} |
| 45 | + run: | |
| 46 | + echo "SEGMENT_KEY=${SEGMENT_KEY}" >> $GITHUB_ENV |
| 47 | + shell: bash |
| 48 | + |
| 49 | + - name: Validate SEGMENT_KEY |
| 50 | + run: | |
| 51 | + if [ -z "${SEGMENT_KEY}" ]; then |
| 52 | + echo "SEGMENT_KEY is not set or is empty" |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | + shell: bash |
| 56 | + |
| 57 | + - name: Install npm |
| 58 | + run: npm install -g [email protected] |
| 59 | + shell: bash |
| 60 | + |
| 61 | + - name: Install Dependencies |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + npm ci --omit=optional |
| 65 | +
|
| 66 | + - name: Run Checks |
| 67 | + run: npm run check |
| 68 | + # the glob here just fails |
| 69 | + if: ${{ runner.os != 'Windows' }} |
| 70 | + shell: bash |
| 71 | + |
| 72 | + - name: Run Tests |
| 73 | + run: | |
| 74 | + npm run test |
| 75 | + shell: bash |
| 76 | + |
| 77 | + - name: Build .vsix |
| 78 | + env: |
| 79 | + NODE_OPTIONS: "--require ./scripts/no-npm-list-fail.js" |
| 80 | + # NOTE: --githubBranch is "The GitHub branch used to infer relative links in README.md." |
| 81 | + run: | |
| 82 | + npx vsce package --githubBranch main |
| 83 | + shell: bash |
| 84 | + |
| 85 | + - name: Check .vsix filesize |
| 86 | + run: npm run check-vsix-size |
| 87 | + shell: bash |
| 88 | + |
| 89 | + - name: Sign .vsix |
| 90 | + if: runner.os == 'Linux' |
| 91 | + env: |
| 92 | + ARTIFACTORY_HOST: ${{ inputs.ARTIFACTORY_HOST }} |
| 93 | + ARTIFACTORY_PASSWORD: ${{ inputs.ARTIFACTORY_PASSWORD }} |
| 94 | + ARTIFACTORY_USERNAME: ${{ inputs.ARTIFACTORY_USERNAME }} |
| 95 | + GARASIGN_PASSWORD: ${{ inputs.GARASIGN_PASSWORD }} |
| 96 | + GARASIGN_USERNAME: ${{ inputs.GARASIGN_USERNAME }} |
| 97 | + run: | |
| 98 | + bash scripts/sign-vsix.sh |
| 99 | + ls *.vsix.sig |
| 100 | + shell: bash |
| 101 | + |
| 102 | + - name: Upload artifacts |
| 103 | + uses: actions/upload-artifact@v2 |
| 104 | + with: |
| 105 | + name: VSIX built on ${{ runner.os }} |
| 106 | + path: | |
| 107 | + *.vsix |
| 108 | + *.vsix.sig |
| 109 | +
|
| 110 | + - name: Run Snyk Test |
| 111 | + if: runner.os == 'Linux' |
| 112 | + shell: bash |
| 113 | + env: |
| 114 | + SNYK_TOKEN: ${{ inputs.SNYK_TOKEN }} |
| 115 | + run: | |
| 116 | + npm run snyk-test > /dev/null 2>&1 |
| 117 | +
|
| 118 | + - name: Create Jira Tickets |
| 119 | + if: > |
| 120 | + runner.os == 'Linux' && |
| 121 | + ( |
| 122 | + github.event_name == 'push' && github.ref == 'refs/heads/main' || |
| 123 | + github.event_name == 'workflow_dispatch' || |
| 124 | + github.event_name == 'schedule' |
| 125 | + ) |
| 126 | + shell: bash |
| 127 | + env: |
| 128 | + JIRA_API_TOKEN: ${{ inputs.JIRA_API_TOKEN }} |
| 129 | + JIRA_BASE_URL: "https://jira.mongodb.org" |
| 130 | + JIRA_PROJECT: "VSCODE" |
| 131 | + JIRA_VULNERABILITY_BUILD_INFO: "- [GitHub Run|https://github.com/mongodb-js/vscode/actions/runs/${{github.run_id}}/jobs/${{github.job}}]" |
| 132 | + run: | |
| 133 | + npm run create-vulnerability-tickets > /dev/null |
| 134 | +
|
| 135 | + - name: Generate Vulnerability Report (Fail on >= High) |
| 136 | + if: runner.os == 'Linux' |
| 137 | + continue-on-error: ${{ github.event_name == 'pull_request' }} |
| 138 | + shell: bash |
| 139 | + run: | |
| 140 | + # The standard output is suppressed since Github Actions logs are |
| 141 | + # available for everyone with read access to the repo, which is everyone that is |
| 142 | + # logged in for public repos. |
| 143 | + # This command is only here to fail on failures for `main` and tags. |
| 144 | + npm run generate-vulnerability-report > /dev/null |
0 commit comments