diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml index fd47f7a..ffb47fa 100644 --- a/.github/codeql/codeql-config.yml +++ b/.github/codeql/codeql-config.yml @@ -1,5 +1,5 @@ -name: "javascript-action CodeQL config" +name: JavaScript CodeQL Configuration -paths-ignore: +paths-ignore: - node_modules - dist diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 3693056..dbdfd98 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -1,8 +1,11 @@ -# `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. +# 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. +# +# This workflow will fail if the checked-in `dist/index.js` file does not match +# what is expected from the build. name: Check dist/ on: @@ -18,32 +21,43 @@ on: jobs: check-dist: + name: Check dist/ runs-on: ubuntu-latest + permissions: + contents: read + statuses: write + steps: - - uses: actions/checkout@v3 + - name: Checkout + id: checkout + uses: actions/checkout@v4 - - name: Set Node.js 16.x - uses: actions/setup-node@v3.6.0 + - name: Setup Node.js + uses: actions/setup-node@v3 with: - node-version: 16.x + node-version: 20 + cache: npm - - name: Install dependencies + - name: Install Dependencies + id: install run: npm ci - - name: Rebuild the dist/ directory - run: npm run prepare + - name: Build dist/ Directory + id: build + run: npm run bundle - - name: Compare the expected and actual dist/ directories + - name: Compare Expected and Actual Directories + id: diff 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 + if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then + echo "Detected uncommitted changes after build. See status below:" + git diff --ignore-space-at-eol --text dist/ exit 1 fi - id: diff - # If index.js was different than expected, upload the expected version as an artifact + # 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' }} with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1d24ad0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,60 @@ +name: Continuous Integration + +on: + pull_request: + push: + branches: + - main + - "releases/*" + +jobs: + test-javascript: + name: JavaScript Tests + runs-on: ubuntu-latest + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + id: setup-node + uses: actions/setup-node@v3 + with: + node-version: 20 + cache: npm + + - name: Install Dependencies + id: npm-ci + run: npm ci + + - name: Check Format + id: npm-format-check + run: npm run format:check + + - name: Lint + id: npm-lint + run: npm run lint + + - name: Test + id: npm-ci-test + run: npm run ci-test + + test-action: + name: GitHub Actions Test + runs-on: ubuntu-latest + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v4 + + - name: Test Local Action + id: test-action + uses: ./ + with: + milliseconds: 1000 + + - name: Print Output + id: output + run: echo "${{ steps.test-action.outputs.time }}" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 1e92521..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: "units-test" -on: - pull_request: - push: - branches: - - main - - 'releases/*' - -jobs: - # unit tests - units: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - run: npm ci - - run: npm test - - # test action works running from the graph - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./ - with: - milliseconds: 1000 diff --git a/badges/coverage.svg b/badges/coverage.svg new file mode 100644 index 0000000..5bb55be --- /dev/null +++ b/badges/coverage.svg @@ -0,0 +1 @@ +Coverage: 100%Coverage100% \ No newline at end of file