From 25d0ac5287c471bbb1ddcf5f91ad7573608ad1be Mon Sep 17 00:00:00 2001 From: Nick Alteen Date: Tue, 28 Nov 2023 00:03:31 -0500 Subject: [PATCH] Format and updates --- .github/workflows/check-dist.yml | 41 +++++++++++++++++--------------- .github/workflows/ci.yml | 6 +++-- .github/workflows/linter.yml | 22 ++++++++--------- .node-version | 1 + 4 files changed, 37 insertions(+), 33 deletions(-) create mode 100644 .node-version diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 41c01be..6d149b1 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -1,23 +1,22 @@ -# In JavaScript actions, `dist/index.js` is a special file. When you reference -# an action with `uses:`, `dist/index.js` is the code that will be run. For this -# project, the `dist/index.js` file is generated from other source files through -# the build process. We need to make sure that the checked-in `dist/index.js` -# file matches what is expected from the build. +# In JavaScript actions, `dist/` is a special directory. When you reference +# an action with the `uses:` property, `dist/index.js` is the code that will be +# run. For this project, the `dist/index.js` file is transpiled from other +# source files. This workflow ensures the `dist/` directory contains the +# expected transpiled code. # -# This workflow will fail if the checked-in `dist/index.js` file does not match -# what is expected from the build. -name: Check dist/ +# If this workflow is run from a feature branch, it will act as an additional CI +# check and fail if the checked-in `dist/` directory does not match what is +# expected from the build. +name: Check Transpiled JavaScript on: push: branches: - main - paths-ignore: - - '**.md' pull_request: - paths-ignore: - - '**.md' - workflow_dispatch: + +permissions: + contents: read jobs: check-dist: @@ -34,9 +33,10 @@ jobs: uses: actions/checkout@v4 - name: Setup Node.js + id: setup-node uses: actions/setup-node@v4 with: - node-version: 20 + node-version-file: .node-version cache: npm - name: Install Dependencies @@ -47,7 +47,8 @@ jobs: id: build run: npm run bundle - - name: Compare Expected and Actual Directories + # This will fail the workflow if the PR wasn't created by Dependabot. + - name: Compare Directories id: diff run: | if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then @@ -56,10 +57,12 @@ jobs: exit 1 fi - # If index.js was different than expected, upload the expected version as - # a workflow artifact. - - uses: actions/upload-artifact@v3 - if: ${{ failure() && steps.diff.conclusion == 'failure' }} + # If `dist/` was different than expected, and this was not a Dependabot + # PR, upload the expected version as a workflow artifact. + - if: ${{ failure() && steps.diff.outcome == 'failure' }} + name: Upload Artifact + id: upload + uses: actions/upload-artifact@v3 with: name: dist path: dist/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83d24f3..dca9ec6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,9 @@ on: push: branches: - main - - "releases/*" + +permissions: + contents: read jobs: test-javascript: @@ -21,7 +23,7 @@ jobs: id: setup-node uses: actions/setup-node@v4 with: - node-version: 20 + node-version-file: .node-version cache: npm - name: Install Dependencies diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 1eee6da..f3b1cb0 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -1,23 +1,19 @@ -name: Lint Code Base +name: Lint Codebase on: pull_request: + push: branches: - main - push: - branches-ignore: - - main + +permissions: + contents: read jobs: lint: - name: Lint Code Base + name: Lint Codebase runs-on: ubuntu-latest - permissions: - contents: read - packages: read - statuses: write - steps: - name: Checkout id: checkout @@ -27,18 +23,20 @@ jobs: id: setup-node uses: actions/setup-node@v4 with: - node-version: 20 + node-version-file: .node-version cache: npm - name: Install Dependencies id: install run: npm ci - - name: Lint Code Base + - name: Lint Codebase id: super-linter uses: super-linter/super-linter/slim@v5 env: DEFAULT_BRANCH: main + FILTER_REGEX_EXCLUDE: dist/**/* GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} JAVASCRIPT_DEFAULT_STYLE: prettier + VALIDATE_ALL_CODEBASE: true VALIDATE_JSCPD: false diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..1cc433a --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +20.6.0