From ba8a1f9c023783dc6db4988197a0a7b3fc3407ed Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Wed, 14 Dec 2022 11:41:18 +0100 Subject: [PATCH] Update action to use reusable workflows --- .github/workflows/check-dist.yml | 42 ++--------------- .github/workflows/codeql-analysis.yml | 66 ++------------------------- .github/workflows/licensed.yml | 16 ++----- .github/workflows/workflow.yml | 24 ++-------- package.json | 1 + 5 files changed, 15 insertions(+), 134 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 91e3b88..d84c645 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -1,10 +1,4 @@ -# `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: push: branches: @@ -17,36 +11,6 @@ on: workflow_dispatch: jobs: - check-dist: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Set Node.js 16 - uses: actions/setup-node@v3 - with: - node-version: 16.x - cache: npm - - - name: Install dependencies - run: npm ci --ignore-scripts - - - 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: + name: Check dist/ + uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index d21db35..8fa22d9 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,70 +1,14 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - +name: CodeQL analysis on: push: branches: [ main ] pull_request: - # The branches below must be a subset of the branches above branches: [ main ] schedule: - cron: '23 19 * * 0' + workflow_dispatch: jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'javascript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + call-codeQL-analysis: + 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 index d8fb6ea..42084b2 100644 --- a/.github/workflows/licensed.yml +++ b/.github/workflows/licensed.yml @@ -10,16 +10,6 @@ on: workflow_dispatch: jobs: - test: - runs-on: ubuntu-latest - name: Check licenses - steps: - - uses: actions/checkout@v3 - - run: npm ci --ignore-scripts - - name: Install licensed - run: | - cd $RUNNER_TEMP - curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.4.4/licensed-3.4.4-linux-x64.tar.gz - sudo tar -xzf licensed.tar.gz - sudo mv licensed /usr/local/bin/licensed - - run: licensed status + call-licensed: + name: Licensed + uses: actions/reusable-workflows/.github/workflows/licensed.yml@main \ No newline at end of file diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 3116a6e..659eccf 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -12,27 +12,9 @@ on: - '**.md' jobs: - build: - runs-on: ${{ matrix.operating-system }} - strategy: - fail-fast: false - matrix: - operating-system: [ubuntu-latest, windows-latest, macOS-latest] - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set Node.js 16 - uses: actions/setup-node@v3 - with: - node-version: 16.x - cache: npm - - run: npm ci --ignore-scripts - - run: npm run build - - run: npm run format-check - - run: npm test - - name: Verify no unstaged changes - if: runner.os != 'windows' - run: __tests__/verify-no-unstaged-changes.sh + call-basic-validation: + name: Basic validation + uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main test-setup-multiple-versions: runs-on: ${{ matrix.operating-system }} diff --git a/package.json b/package.json index 6e80f1a..fde3dd6 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "build": "tsc && ncc build", "format": "prettier --write **/*.ts", "format-check": "prettier --check **/*.ts", + "lint": "", "prepare": "husky install", "test": "jest --coverage --config ./jest.config.js", "update-installers": "nwget https://dot.net/v1/dotnet-install.ps1 -O externals/install-dotnet.ps1 && nwget https://dot.net/v1/dotnet-install.sh -O externals/install-dotnet.sh"