Skip to content

Commit 194355a

Browse files
authored
fix(ci): run static analysis reporting only once per version MONGOSH-1804 (#2025)
1 parent 778ce7a commit 194355a

File tree

8 files changed

+283
-220
lines changed

8 files changed

+283
-220
lines changed

.evergreen.yml

Lines changed: 183 additions & 39 deletions
Large diffs are not rendered by default.

.evergreen/compile-artifact.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,5 @@ npm run create-purls-file
100100
cp .sbom/purls.txt dist/.purls.txt
101101

102102
cat dist/.purls.txt
103+
104+
npm run create-dependency-sbom-lists
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
set -x
4+
5+
npm run create-static-analysis-report -- --first-party-deps-list-files="${FIRST_PARTY_DEPENDENCY_FILENAMES}"
6+
(cd .sbom && tar czvf ../static-analysis-report.tgz codeql.md codeql.sarif.json)

.evergreen/download-crypt-shared-and-generate-sbom.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,3 @@ set -x
1515
docker pull artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:1.0
1616
docker run --rm -v ${PWD}:/pwd artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:1.0 update \
1717
--purls /pwd/dist/.purls.txt --sbom_out /pwd/dist/.sbom.json
18-
19-
npm run create-static-analysis-report
20-
(cd .sbom && tar czvf ../static-analysis-report.tgz codeql.md codeql.sarif.json)

.evergreen/evergreen.yml.in

Lines changed: 69 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ functions:
398398
DISTRO_ID: ${distro_id}
399399
NODE_JS_VERSION: ${node_js_version}
400400
MONGOSH_SHARED_OPENSSL: ${mongosh_shared_openssl}
401-
upload_sbom_and_static_analysis:
401+
GITHUB_PR_NUMBER: ${github_pr_number}
402+
upload_sbom:
402403
- command: s3.put
403404
params:
404405
aws_key: ${aws_key}
@@ -417,16 +418,6 @@ functions:
417418
bucket: mciuploads
418419
permissions: public-read
419420
content_type: text/plain
420-
- command: s3.put
421-
params:
422-
aws_key: ${aws_key}
423-
aws_secret: ${aws_secret}
424-
local_file: src/static-analysis-report.tgz
425-
remote_file: mongosh/binaries/${revision}/${revision_order_id}/mongosh-${executable_os_id}${extra_upload_tag}-static-analysis-report.tgz
426-
bucket: mciuploads
427-
permissions: private
428-
visibility: signed
429-
content_type: application/json
430421
upload_compiled_artifact:
431422
- command: shell.exec
432423
params:
@@ -452,6 +443,16 @@ functions:
452443
bucket: mciuploads
453444
permissions: public-read
454445
content_type: application/x-gzip
446+
upload_first_party_deps_list:
447+
- command: s3.put
448+
params:
449+
aws_key: ${aws_key}
450+
aws_secret: ${aws_secret}
451+
local_file: src/.sbom/first-party-deps.json
452+
remote_file: mongosh/binaries/${revision}/${revision_order_id}/mongosh-${executable_os_id}${extra_upload_tag}-first-party-deps.json
453+
bucket: mciuploads
454+
permissions: public-read
455+
content_type: application/json
455456
download_compiled_artifact:
456457
- command: s3.get
457458
type: setup
@@ -521,9 +522,44 @@ functions:
521522
PACKAGE_VARIANT: ${package_variant}
522523
ARTIFACTORY_USERNAME: ${artifactory_username}
523524
ARTIFACTORY_PASSWORD: ${artifactory_password}
524-
# for static analysis report generation
525+
create_static_analysis_report:
526+
<%
527+
let firstPartyDepsFilenames = [];
528+
for (const { executableOsId, packages } of RELEASE_PACKAGE_MATRIX) {
529+
const filename = `mongosh-${executableOsId}-first-party-deps.json`;
530+
firstPartyDepsFilenames.push(filename); %>
531+
- command: s3.get
532+
params:
533+
aws_key: ${aws_key}
534+
aws_secret: ${aws_secret}
535+
local_file: src/.sbom/<% out(filename) %>
536+
remote_file: mongosh/binaries/${revision}/${revision_order_id}/<% out(filename) %>
537+
bucket: mciuploads
538+
<% } %>
539+
- command: shell.exec
540+
params:
541+
working_dir: src
542+
shell: bash
543+
script: |
544+
set -e
545+
export NODE_JS_VERSION=${node_js_version}
546+
source .evergreen/setup-env.sh
547+
.evergreen/create-static-analysis-report.sh
548+
env:
549+
NODE_JS_VERSION: ${node_js_version}
550+
FIRST_PARTY_DEPENDENCY_FILENAMES: <% out(firstPartyDepsFilenames.map(f => `.sbom/${f}`).join(',')) %>
525551
GITHUB_TOKEN: ${github_token}
526552
GITHUB_PR_NUMBER: ${github_pr_number}
553+
- command: s3.put
554+
params:
555+
aws_key: ${aws_key}
556+
aws_secret: ${aws_secret}
557+
local_file: src/static-analysis-report.tgz
558+
remote_file: mongosh/binaries/${revision}/${revision_order_id}/mongosh-static-analysis-report.tgz
559+
bucket: mciuploads
560+
permissions: private
561+
visibility: signed
562+
content_type: application/x-gzip
527563
package_artifact:
528564
- command: expansions.write
529565
type: setup
@@ -1095,6 +1131,7 @@ tasks:
10951131
mongosh_server_test_version: "latest-alpha-enterprise"
10961132
mongosh_test_force_api_strict: "1"
10971133
- name: compile_artifact
1134+
tags: ["compile-artifact"]
10981135
depends_on:
10991136
- name: compile_ts
11001137
variant: linux_unit
@@ -1109,6 +1146,9 @@ tasks:
11091146
- func: upload_compiled_artifact
11101147
vars:
11111148
node_js_version: "<% out(NODE_JS_VERSION_20) %>"
1149+
- func: upload_first_party_deps_list
1150+
vars:
1151+
node_js_version: "<% out(NODE_JS_VERSION_20) %>"
11121152

11131153
- name: generate_license_and_vulnerability_report
11141154
tags: ["extra-integration-test"]
@@ -1202,6 +1242,7 @@ tasks:
12021242
<% for (const { executableOsId, compileBuildVariant, packages } of RELEASE_PACKAGE_MATRIX) {
12031243
for (const { name: packageVariant } of packages) { %>
12041244
- name: add_crypt_shared_and_sbom_<% out(packageVariant.replace(/-/g, '_')) %>
1245+
tags: ["add-sbom-task"]
12051246
depends_on:
12061247
- name: compile_artifact
12071248
variant: <% out(compileBuildVariant) %>
@@ -1217,7 +1258,7 @@ tasks:
12171258
vars:
12181259
package_variant: <% out(packageVariant) %>
12191260
executable_os_id: <% out(executableOsId) %>
1220-
- func: upload_sbom_and_static_analysis
1261+
- func: upload_sbom
12211262
vars:
12221263
executable_os_id: <% out(executableOsId) %>
12231264
extra_upload_tag: -<% out(packageVariant) %>-sbom
@@ -1338,6 +1379,19 @@ tasks:
13381379
throw new Error(`pkg ${name} is missing a valid smoke test indicator`);
13391380
} %>
13401381
<% } } } %>
1382+
- name: create_static_analysis_report
1383+
tags: ["extra-integration-test"]
1384+
depends_on:
1385+
- name: ".compile-artifact"
1386+
variant: "*"
1387+
commands:
1388+
- func: checkout
1389+
- func: install
1390+
vars:
1391+
node_js_version: "<% out(NODE_JS_VERSION_20) %>"
1392+
- func: create_static_analysis_report
1393+
vars:
1394+
node_js_version: "<% out(NODE_JS_VERSION_20) %>"
13411395

13421396
###
13431397
# RELEASE TASKS
@@ -1453,10 +1507,11 @@ buildvariants:
14531507
- name: test_connectivity
14541508
- name: test_apistrict
14551509
- name: linux_coverage
1456-
display_name: "Coverage Check"
1510+
display_name: "Coverage and Static Analysis Check"
14571511
run_on: ubuntu2004-small
14581512
tasks:
14591513
- name: check_coverage
1514+
- name: create_static_analysis_report
14601515
- name: linux_package
14611516
display_name: "Ubuntu 20.04 x64 (Packaging)"
14621517
run_on: ubuntu2004-small

0 commit comments

Comments
 (0)