From 1842e2cf84a87052e40359b59194ae7ff5efa7ed Mon Sep 17 00:00:00 2001 From: Adil Rakhaliyev <67043367+Bayheck@users.noreply.github.com> Date: Tue, 11 Jun 2024 12:27:44 +0500 Subject: [PATCH] license check workflow added (#8206) ## Purpose Add a workflow to check production dependencies licenses. ## Approach Create a new workflow file and add it in artifacts deploy ## References Correct licenses run: https://github.com/Testing-and-Learning/testcafe/actions/runs/9413544636 Incorrect licenses run: https://github.com/Testing-and-Learning/testcafe/actions/runs/9413057523/job/25929056940 ## Pre-Merge TODO - [ ] Write tests for your proposed changes - [ ] Make sure that existing tests do not fail --------- Co-authored-by: Bayheck --- .github/workflows/deploy-to-artifacts.yml | 1 + .github/workflows/license-check.yml | 38 +++++++++++++++++++++++ test/dependency-licenses-checker.js | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/license-check.yml diff --git a/.github/workflows/deploy-to-artifacts.yml b/.github/workflows/deploy-to-artifacts.yml index e42f918c6e7..546259b2bc9 100644 --- a/.github/workflows/deploy-to-artifacts.yml +++ b/.github/workflows/deploy-to-artifacts.yml @@ -146,6 +146,7 @@ jobs: tasks.push('test-server-docker.yml'); tasks.push('test-server-minimal.yml'); tasks.push('test-server-latest.yml'); + tasks.push('license-check.yml'); await Promise.all(tasks.map(task => dispatchWorkflow(task))); diff --git a/.github/workflows/license-check.yml b/.github/workflows/license-check.yml new file mode 100644 index 00000000000..a33c9e9faee --- /dev/null +++ b/.github/workflows/license-check.yml @@ -0,0 +1,38 @@ +name: Check Licenses + +on: + workflow_dispatch: + inputs: + sha: + description: "The test commit SHA or ref" + required: true + default: "master" + merged_sha: + description: "The merge commit SHA" + deploy_run_id: + description: "The ID of a deployment workspace run with artifacts" + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: latest + + - name: Install dependencies + run: npm install + + - name: Run Gulp build + run: npx gulp build + + - name: Pack the application + run: npm pack + + - name: Install the application and check licenses + run: mkdir temp && cd temp && npm init -y && npm install ../*.tgz && npx gulp check-licenses diff --git a/test/dependency-licenses-checker.js b/test/dependency-licenses-checker.js index eb503c2198c..17dbafb0095 100644 --- a/test/dependency-licenses-checker.js +++ b/test/dependency-licenses-checker.js @@ -32,7 +32,7 @@ const INCOMPATIBLE_LICENSES_RE = /GPL/i; const hasIncompatibleLicenses = license => INCOMPATIBLE_LICENSES_RE.test(license); const hasUnknownLicenses = license => PERMISSIVE_LICENSES.indexOf(license) === -1; -const modulePath = path.join(__dirname, '../'); +const modulePath = path.join(__dirname, '../temp'); function checkLicense (license, module) { const unknownModuleAssertionMsg = `The module '${module}' contains an unknown license '${license}'. You can add this license to the list of known permissive licenses. But be cautious and do this only if you are sure that this license is compatible with TestCafe`;