From ca96efe4c6ad40ffe39874cdb107ae5dbfc86402 Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Fri, 8 Jul 2022 10:54:25 +0200 Subject: [PATCH] - upgrade CI pipelines - introduce dist check --- .github/workflows/check-dist.yml | 53 +++++++++++++++++++++++++++ .github/workflows/ci.yml | 10 +++-- .github/workflows/codeql-analysis.yml | 6 +-- 3 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/check-dist.yml diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml new file mode 100644 index 0000000..e92f736 --- /dev/null +++ b/.github/workflows/check-dist.yml @@ -0,0 +1,53 @@ +# `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: + - main + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' + 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 + + - name: Install dependencies + run: npm ci + + - name: Rebuild the dist/ directory + run: | + npm run build + npm run package + + - 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/ \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index edfaa29..f0bad4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,13 +11,17 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + uses: actions/checkout@v3 + + - name: Set Node.js 16.x + uses: actions/setup-node@v3 with: - node-version: '16' + node-version: 16.x + - name: Install NPM run: | npm install + - name: Run NPM run: | npm run all diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2312690..eb4b004 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + 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. @@ -54,7 +54,7 @@ jobs: # 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@v1 + uses: github/codeql-action/autobuild@v2 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -68,4 +68,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2