Skip to content

Commit 83b4fd5

Browse files
authored
chore: add dependency license verification (#752)
* chore: add dependency license verification * fix: remove incorrect error message in license check * fix: update to use codegen repo codebuild paths: * fix: use correct cache load name
1 parent 8ec490d commit 83b4fd5

11 files changed

+21995
-3
lines changed

.codebuild/e2e_workflow.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ batch:
3636
compute-type: BUILD_GENERAL1_MEDIUM
3737
depend-on:
3838
- build_linux
39+
- identifier: verify_dependency_licenses_extract
40+
buildspec: .codebuild/verify_dependency_licenses_extract.yml
41+
env:
42+
compute-type: BUILD_GENERAL1_MEDIUM
43+
depend-on:
44+
- build_linux
3945
- identifier: publish_to_local_registry
4046
buildspec: .codebuild/publish_to_local_registry.yml
4147
env:

.codebuild/e2e_workflow_base.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ batch:
3636
compute-type: BUILD_GENERAL1_MEDIUM
3737
depend-on:
3838
- build_linux
39+
- identifier: verify_dependency_licenses_extract
40+
buildspec: .codebuild/verify_dependency_licenses_extract.yml
41+
env:
42+
compute-type: BUILD_GENERAL1_MEDIUM
43+
depend-on:
44+
- build_linux
3945
- identifier: publish_to_local_registry
4046
buildspec: .codebuild/publish_to_local_registry.yml
4147
env:

.codebuild/pr_workflow.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ batch:
3434
buildspec: .codebuild/verify_api_extract.yml
3535
depend-on:
3636
- build_linux
37+
- identifier: verify_dependency_licenses_extract
38+
buildspec: .codebuild/verify_dependency_licenses_extract.yml
39+
env:
40+
compute-type: BUILD_GENERAL1_MEDIUM
41+
depend-on:
42+
- build_linux

.codebuild/release_workflow.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ batch:
3030
buildspec: .codebuild/verify_api_extract.yml
3131
depend-on:
3232
- build_linux
33+
- identifier: verify_dependency_licenses_extract
34+
buildspec: .codebuild/verify_dependency_licenses_extract.yml
35+
env:
36+
compute-type: BUILD_GENERAL1_MEDIUM
37+
depend-on:
38+
- build_linux
3339
- identifier: deploy
3440
buildspec: .codebuild/deploy.yml
3541
depend-on:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 0.2
2+
env:
3+
shell: bash
4+
phases:
5+
build:
6+
commands:
7+
- source ./shared-scripts.sh && _verifyDependencyLicensesExtract

.github/CODEOWNERS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
# API approval - public surface and dependencies.
55
**/API.md @aws-amplify/amplify-data-admins
66

7-
# Changes to CI/CD scripts/buildspecs need admin approval
7+
# Dependency Licensing approval
8+
dependency_licenses.txt @aws-amplify/amplify-data-admins
89

10+
# Changes to CI/CD scripts/buildspecs need admin approval
911
/scripts/ @aws-amplify/amplify-data-admins
1012
/shared-scripts.sh @aws-amplify/amplify-data-admins
1113
/.codebuild/ @aws-amplify/amplify-data-admins

dependency_licenses.txt

Lines changed: 21927 additions & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
"split-e2e-tests": "yarn ts-node ./scripts/split-e2e-tests.ts && git add .codebuild/e2e_workflow.yml",
4343
"view-test-artifacts": "yarn authenticate-e2e-profile && yarn ts-node ./scripts/view-test-artifacts.ts",
4444
"cloud-e2e-debug": "source scripts/cloud-utils.sh && cloudE2EDebug",
45-
"authenticate-e2e-profile": "source scripts/cloud-utils.sh && authenticateWithE2EProfile"
45+
"authenticate-e2e-profile": "source scripts/cloud-utils.sh && authenticateWithE2EProfile",
46+
"extract-dependency-licenses": "./scripts/extract-dependency-licenses.sh",
47+
"verify-dependency-licenses-extract": "yarn extract-dependency-licenses && ./scripts/verify-dependency-licenses.sh"
4648
},
4749
"bugs": {
4850
"url": "https://github.com/aws-amplify/amplify-codegen/issues"
@@ -58,7 +60,7 @@
5860
"hooks": {
5961
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
6062
"pre-push": "npm run lint && npm run test-changed",
61-
"pre-commit": "yarn split-e2e-tests"
63+
"pre-commit": "yarn split-e2e-tests && yarn extract-dependency-licenses"
6264
}
6365
},
6466
"author": "Amazon Web Services",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
yarn licenses generate-disclaimer \
4+
--ignore-platform \
5+
--ignore-engines \
6+
--ignore-optional \
7+
--silent \
8+
--no-progress \
9+
--frozen-lockfile > dependency_licenses_temp.txt
10+
11+
sed \
12+
-e '/WORKSPACE AGGREGATOR/d' \
13+
-e '/workspace-aggregator/d' \
14+
dependency_licenses_temp.txt > dependency_licenses.txt
15+
16+
rm dependency_licenses_temp.txt

scripts/verify-dependency-licenses.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
change_dependency_licenses=$(git status | grep dependency_licenses.txt | wc -l)
4+
5+
if [[ change_dependency_licenses -gt 0 ]]; then
6+
echo "Detected license change. Please run 'yarn extract-dependency-licenses' and add dependency_licenses.txt file changes to the change set."
7+
exit 1;
8+
fi

shared-scripts.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ function _verifyAPIExtract {
160160
yarn verify-api-extract
161161
}
162162

163+
function _verifyDependencyLicensesExtract {
164+
echo "Verify Dependency Licenses Extract"
165+
loadCacheFromLinuxBuildJob
166+
yarn verify-dependency-licenses-extract
167+
}
168+
163169
function _lint {
164170
echo "Lint"
165171
loadCacheFromLinuxBuildJob

0 commit comments

Comments
 (0)