From e07202b67f4f07c3a715b934d6087b74d3c33019 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Mon, 19 Dec 2022 16:40:34 +0100 Subject: [PATCH] Update workflows to use reusable-workflows --- .github/workflows/build-test.yml | 17 +++++++ .github/workflows/build_test.yml | 28 ----------- .github/workflows/check-dist.yml | 41 ++------------- .github/workflows/codeql-analysis.yml | 14 ++++++ .github/workflows/licensed.yml | 15 ++++++ .../workflows/update_and_check_licenses.yml | 50 ------------------- package.json | 1 + 7 files changed, 50 insertions(+), 116 deletions(-) create mode 100644 .github/workflows/build-test.yml delete mode 100644 .github/workflows/build_test.yml create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/licensed.yml delete mode 100644 .github/workflows/update_and_check_licenses.yml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 00000000..d69b6f26 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,17 @@ +name: Build & Test + +on: + pull_request: + paths-ignore: + - '**.md' + push: + branches: + - main + - releases/* + paths-ignore: + - '**.md' + +jobs: + call-basic-validation: # The reusable workflow can be found here: https://github.com/actions/reusable-workflows/blob/main/.github/workflows/basic-validation.yml + name: Basic validation + uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main \ No newline at end of file diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml deleted file mode 100644 index 27858e42..00000000 --- a/.github/workflows/build_test.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Build & Test - -on: - pull_request: - paths-ignore: - - '**.md' - push: - branches: - - main - - releases/* - paths-ignore: - - '**.md' - -jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v3 - - name: Setup node 16 - uses: actions/setup-node@v3 - with: - node-version: 16.x - - run: npm install - - run: npm run build - - run: npm test diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 1019cac1..d51766a9 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -1,8 +1,3 @@ -# `dist/index.js` is a special file in Actions. -# When you reference an action with `uses:` in a workflow, -# `index.js` is the code that will run. -# For our project, we generate this file through a build process from other source files. -# We need to make sure the checked-in `index.js` actually matches what we expect it to be. name: Check dist/ on: @@ -17,36 +12,6 @@ on: workflow_dispatch: jobs: - check-dist: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Set Node.js 16.x - uses: actions/setup-node@v3 - with: - node-version: 16.x - cache: npm - - - name: Install dependencies - run: npm ci - - - name: Rebuild the dist/ directory - run: npm run build - - - name: Compare the expected and actual dist/ directories - run: | - if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then - echo "Detected uncommitted changes after build. See status below:" - git diff - exit 1 - fi - id: diff - - # If index.js was different than expected, upload the expected version as an artifact - - uses: actions/upload-artifact@v3 - if: ${{ failure() && steps.diff.conclusion == 'failure' }} - with: - name: dist - path: dist/ + call-check-dist: # The reusable workflow can be found here: https://github.com/actions/reusable-workflows/blob/main/.github/workflows/check-dist.yml + name: Check dist/ + uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..fd4d859b --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,14 @@ +name: CodeQL analysis + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + schedule: + - cron: '0 3 * * 0' + +jobs: + call-codeQL-analysis: # The reusable workflow can be found here: https://github.com/actions/reusable-workflows/blob/main/.github/workflows/codeql-analysis.yml + name: CodeQL analysis + uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main \ No newline at end of file diff --git a/.github/workflows/licensed.yml b/.github/workflows/licensed.yml new file mode 100644 index 00000000..06eae1e4 --- /dev/null +++ b/.github/workflows/licensed.yml @@ -0,0 +1,15 @@ +name: Licensed + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + call-licensed: # The reusable workflow can be found here: https://github.com/actions/reusable-workflows/blob/main/.github/workflows/licensed.yml + name: Licensed + uses: actions/reusable-workflows/.github/workflows/licensed.yml@main \ No newline at end of file diff --git a/.github/workflows/update_and_check_licenses.yml b/.github/workflows/update_and_check_licenses.yml deleted file mode 100644 index 24d01315..00000000 --- a/.github/workflows/update_and_check_licenses.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Licenses - -on: - push: - branches: [main] - paths: [package.json, package-lock.json] - pull_request: - branches: [main] - paths: [package.json, package-lock.json] - workflow_dispatch: - -jobs: - # Updates our cache of license files in response to changes to our dependencies - # declared in package-lock.json. Automatically commits the changes and pushes - # them to your branch. NB `check_license_status` should always run *after* this - # - # see https://github.com/actions/labeler/pull/155 for more context - update_licenses: - runs-on: ubuntu-latest - name: Update Licenses - steps: - - uses: actions/checkout@v1 - - uses: jonabc/setup-licensed@v1 - with: - version: '3.x' - github_token: ${{ secrets.GITHUB_TOKEN }} - - run: npm install --production - - uses: jonabc/licensed-ci@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - # Fails if any of our dependencies have licenses that our incompatible with our - # requirements (see .licensed.yml) OR if any of our dependencies have been - # upgraded to a new version without us having updated their corresponding - # license metadata file in .licenses/ - # - # see https://github.com/actions/labeler/pull/91 for more context - check_licenses: - needs: update_licenses - if: always() # always run after we update the license cache. if it failed, we will probably just fail as well - runs-on: ubuntu-latest - name: Check Licenses - steps: - - uses: actions/checkout@v2 - - uses: jonabc/setup-licensed@v1.0.2 - with: - version: '3.x' - github_token: ${{ secrets.GITHUB_TOKEN }} - - run: npm install - - run: licensed status diff --git a/package.json b/package.json index 4f9b7114..9ffcb629 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "build": "tsc && ncc build lib/main.js", "format": "prettier --write \"**/*.ts\"", "format-check": "prettier --check \"**/*.ts\"", + "lint": "", "test": "jest" }, "repository": {