From de5501b21f7c09331ac1ae819e6890a5be2c9935 Mon Sep 17 00:00:00 2001 From: Yury Akudovich Date: Mon, 11 Sep 2023 12:55:10 +0200 Subject: [PATCH] Automatically runs license scan in all subdirectories with yarn.lock. Renames license.yaml -> nodejs-license.yaml. --- .github/workflows/license.yaml | 54 ----------------------- .github/workflows/nodejs-license.yaml | 63 +++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 54 deletions(-) delete mode 100644 .github/workflows/license.yaml create mode 100644 .github/workflows/nodejs-license.yaml diff --git a/.github/workflows/license.yaml b/.github/workflows/license.yaml deleted file mode 100644 index afc7d2200..000000000 --- a/.github/workflows/license.yaml +++ /dev/null @@ -1,54 +0,0 @@ -name: CI - -on: - pull_request - -env: - ALLOWED_LICENSES: > - MIT; - BSD; - ISC; - Apache-2.0; - MPL-2.0; - LGPL-3.0; - LGPL-3.0-or-later; - CC0-1.0; - CC-BY-3.0; - CC-BY-4.0; - Python-2.0; - PSF; - Public Domain; - WTFPL; - Unlicense; - # It has to be one line, there must be no space between packages. - EXCLUDE_PACKAGES: testrpc@0.0.1;uuid@2.0.1; - -jobs: - license-check: - runs-on: ubuntu-latest - steps: - - name: Checkout latest code - uses: actions/checkout@v3 - - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '16.15.1' - - - name: Install yarn - run: npm install -g yarn license-checker - - - name: Install dependencies in ethereum - run: cd ethereum && yarn install - - - name: Check licenses in ethereum - working-directory: ethereum - run: npx license-checker --json --onlyAllow="$ALLOWED_LICENSES" --excludePackages "$EXCLUDE_PACKAGES" - - - name: Install dependencies in zksync - run: cd zksync && yarn install - - - name: Check licenses in zksync - working-directory: zksync - run: npx license-checker --json --onlyAllow="$ALLOWED_LICENSES" --excludePackages "$EXCLUDE_PACKAGES" - diff --git a/.github/workflows/nodejs-license.yaml b/.github/workflows/nodejs-license.yaml new file mode 100644 index 000000000..5d4041998 --- /dev/null +++ b/.github/workflows/nodejs-license.yaml @@ -0,0 +1,63 @@ +name: CI + +on: + - pull_request + +env: + ALLOWED_LICENSES: > + MIT; + BSD; + ISC; + Apache-2.0; + MPL-2.0; + LGPL-3.0; + LGPL-3.0-or-later; + CC0-1.0; + CC-BY-3.0; + CC-BY-4.0; + Python-2.0; + PSF; + Public Domain; + WTFPL; + Unlicense; + # It has to be one line, there must be no space between packages. + EXCLUDE_PACKAGES: testrpc@0.0.1;uuid@2.0.1; + +jobs: + generate-matrix: + name: Lists modules + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v3 + - run: | + DIRS=$(find -not \( -path \*node_modules -prune \) -type f -name yarn.lock | xargs dirname | awk -v RS='' -v OFS='","' 'NF { $1 = $1; print "\"" $0 "\"" }') + echo "matrix=[${DIRS}]" >> $GITHUB_OUTPUT + id: set-matrix + + license-check: + needs: [generate-matrix] + runs-on: ubuntu-latest + strategy: + matrix: + dir: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} + steps: + - name: Checkout latest code + uses: actions/checkout@v3 + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '16.15.1' + + - name: Install yarn + run: npm install -g yarn license-checker + + - name: Install dependencies in ${{ matrix.dir }} + working-directory: ${{ matrix.dir }} + run: yarn install + + - name: Check licenses in ${{ matrix.dir }} + working-directory: ${{ matrix.dir }} + run: npx license-checker --json --onlyAllow="$ALLOWED_LICENSES" --excludePackages "$EXCLUDE_PACKAGES"