From 0bb537c715a16a78295efd1585f87eb62ffd3fa1 Mon Sep 17 00:00:00 2001 From: Emelia Smith Date: Wed, 16 Mar 2022 15:32:39 +0100 Subject: [PATCH] chore: run prettier on all files & fix lint errors --- .eslintrc.js | 20 +- .../cd-packaging-tests/node/commonjs.cjs | 4 +- .github/workflows/cd-teardown.yml | 36 +- .github/workflows/cd.yml | 354 +++++++++--------- .github/workflows/ci.yml | 62 +-- .github/workflows/codeql-analysis.yml | 74 ++-- .github/workflows/publish-website.yml | 80 ++-- .github/workflows/release.yml | 310 +++++++-------- .vscode/launch.json | 7 +- 9 files changed, 479 insertions(+), 468 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 5c099e9..9df3143 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,5 +1,23 @@ +// Copyright 2021 Inrupt Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. module.exports = { - extends: ["@inrupt/eslint-config-lib","plugin:import/typescript"], + extends: ["@inrupt/eslint-config-lib", "plugin:import/typescript"], rules: { "import/prefer-default-export": 0, "max-classes-per-file": 0, diff --git a/.github/workflows/cd-packaging-tests/node/commonjs.cjs b/.github/workflows/cd-packaging-tests/node/commonjs.cjs index a95f493..d73ab63 100644 --- a/.github/workflows/cd-packaging-tests/node/commonjs.cjs +++ b/.github/workflows/cd-packaging-tests/node/commonjs.cjs @@ -1,5 +1,3 @@ -const { - sampleModuleFn, -} = require("@inrupt/solid-client-errors-js"); +const { sampleModuleFn } = require("@inrupt/solid-client-errors-js"); console.log(sampleModuleFn()); diff --git a/.github/workflows/cd-teardown.yml b/.github/workflows/cd-teardown.yml index 9678686..4dba63a 100644 --- a/.github/workflows/cd-teardown.yml +++ b/.github/workflows/cd-teardown.yml @@ -9,21 +9,21 @@ jobs: runs-on: ubuntu-20.04 if: github.event.ref_type == 'branch' steps: - - name: Prepare for unpublication from npm - uses: actions/setup-node@v2.1.5 - with: - node-version: '16.x' - registry-url: 'https://registry.npmjs.org' - - name: Determine npm tag - # Remove non-alphanumeric characters - # See https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable - run: echo "TAG_SLUG=$(echo "${{ github.event.ref }}" | tr -cd '[:alnum:]-')" >> $GITHUB_ENV - - name: Remove npm tag for the deleted branch - run: | - # Unfortunately GitHub Actions does not currently let us do something like - # if: secrets.NPM_TOKEN != '' - # so simply skip the command if the env var is not set: - if [ -n $NODE_AUTH_TOKEN ]; then npm dist-tag rm @inrupt/solid-client-errors-js $TAG_SLUG; fi - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - run: echo "Package tag [$TAG_SLUG] unpublished." + - name: Prepare for unpublication from npm + uses: actions/setup-node@v2.1.5 + with: + node-version: "16.x" + registry-url: "https://registry.npmjs.org" + - name: Determine npm tag + # Remove non-alphanumeric characters + # See https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable + run: echo "TAG_SLUG=$(echo "${{ github.event.ref }}" | tr -cd '[:alnum:]-')" >> $GITHUB_ENV + - name: Remove npm tag for the deleted branch + run: | + # Unfortunately GitHub Actions does not currently let us do something like + # if: secrets.NPM_TOKEN != '' + # so simply skip the command if the env var is not set: + if [ -n $NODE_AUTH_TOKEN ]; then npm dist-tag rm @inrupt/solid-client-errors-js $TAG_SLUG; fi + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - run: echo "Package tag [$TAG_SLUG] unpublished." diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b1f0e0d..844aef7 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -3,11 +3,11 @@ name: CD on: push: branches: - - '**' + - "**" tags-ignore: - # Only create preview releases for branches - # (the `release` workflow creates actual releases for version tags): - - '**' + # Only create preview releases for branches + # (the `release` workflow creates actual releases for version tags): + - "**" env: CI: true @@ -18,28 +18,28 @@ jobs: tag-slug: ${{ steps.determine-npm-tag.outputs.tag-slug }} deployment-id: ${{ fromJson(steps.create-deployment.outputs.data).id }} steps: - - name: Create GitHub Deployment - id: create-deployment - if: github.actor != 'dependabot[bot]' - uses: octokit/request-action@v2.x - with: - route: POST /repos/:repository/deployments - repository: ${{ github.repository }} - ref: ${{ github.sha }} - environment: review - transient_environment: true - auto_merge: false - mediaType: '{"previews": ["flash", "ant-man"]}' - # The deployment runs in parallel with CI, so status checks will never have succeeded yet: - required_contexts: '[]' - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - name: Determine npm tag - id: determine-npm-tag - run: | - # Remove non-alphanumeric characters - # See https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable - echo "::set-output name=tag-slug::$(echo ${GITHUB_REF#refs/heads/} | tr -cd '[:alnum:]-')" + - name: Create GitHub Deployment + id: create-deployment + if: github.actor != 'dependabot[bot]' + uses: octokit/request-action@v2.x + with: + route: POST /repos/:repository/deployments + repository: ${{ github.repository }} + ref: ${{ github.sha }} + environment: review + transient_environment: true + auto_merge: false + mediaType: '{"previews": ["flash", "ant-man"]}' + # The deployment runs in parallel with CI, so status checks will never have succeeded yet: + required_contexts: "[]" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - name: Determine npm tag + id: determine-npm-tag + run: | + # Remove non-alphanumeric characters + # See https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable + echo "::set-output name=tag-slug::$(echo ${GITHUB_REF#refs/heads/} | tr -cd '[:alnum:]-')" publish-npm: runs-on: ubuntu-20.04 @@ -47,91 +47,91 @@ jobs: outputs: version-nr: ${{ steps.determine-npm-version.outputs.version-nr }} steps: - - uses: actions/checkout@v2.3.4 - - name: Mark GitHub Deployment as in progress - id: start-deployment - uses: octokit/request-action@v2.x - if: github.actor != 'dependabot[bot]' - with: - route: POST /repos/:repository/deployments/:deployment/statuses - repository: ${{ github.repository }} - deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} - environment: review - description: "Publishing to npm tag [${{ needs.prepare-deployment.outputs.tag-slug }}]…" - log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - state: in_progress - mediaType: '{"previews": ["flash", "ant-man"]}' - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - uses: actions/setup-node@v2.1.5 - with: - node-version: '16.x' - registry-url: 'https://registry.npmjs.org' - - name: Prepare prerelease version - id: determine-npm-version - if: github.actor != 'dependabot[bot]' - run: | - git config user.name $GITHUB_ACTOR - git config user.email gh-actions-${GITHUB_ACTOR}@github.com - # Unfortunately re-running a job does not change its run ID nor run number. - # To prevent re-releasing the same version when re-running the CD job, - # we incorporate a timestamp in the prerelease version: - TIMESTAMP=$(date --utc +%s) - # Make sure the prerelease is tagged with the branch name, and that they are sorted by build: - VERSION_NR=$(npm version prerelease --preid=$TAG_SLUG-$GITHUB_RUN_ID-$GITHUB_RUN_NUMBER-$TIMESTAMP) - echo "::set-output name=version-nr::$VERSION_NR" - env: - TAG_SLUG: ${{ needs.prepare-deployment.outputs.tag-slug }} - - run: npm ci - - name: Publish an npm tag for this branch - if: github.actor != 'dependabot[bot]' - run: | - # Unfortunately GitHub Actions does not currently let us do something like - # if: secrets.NPM_TOKEN != '' - # so simply skip the command if the env var is not set: - if [ -z $NODE_AUTH_TOKEN ]; then echo "No npm token defined; package not published."; fi - if [ -n $NODE_AUTH_TOKEN ]; then npm publish --access public --tag "$TAG_SLUG"; fi - if [ -n $NODE_AUTH_TOKEN ]; then echo "Package published. To install, run:"; fi - if [ -n $NODE_AUTH_TOKEN ]; then echo ""; fi - if [ -n $NODE_AUTH_TOKEN ]; then echo " npm install @inrupt/solid-client-errors-js@$TAG_SLUG"; fi - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - TAG_SLUG: ${{ needs.prepare-deployment.outputs.tag-slug }} - - name: Mark GitHub Deployment as successful - if: github.actor != 'dependabot[bot]' - uses: octokit/request-action@v2.x - with: - route: POST /repos/:repository/deployments/:deployment/statuses - repository: ${{ github.repository }} - deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} - environment: review - environment_url: 'https://www.npmjs.com/package/@inrupt/solid-client-errors-js/v/${{ needs.prepare-deployment.outputs.tag-slug }}' - description: "Published to npm. To install, run: npm install @inrupt/solid-client-errors-js@${{ needs.prepare-deployment.outputs.tag-slug }}" - log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - mediaType: '{"previews": ["flash", "ant-man"]}' - state: success - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - name: Mark GitHub Deployment as failed - uses: octokit/request-action@v2.x - if: failure() - with: - route: POST /repos/:repository/deployments/:deployment/statuses - repository: ${{ github.repository }} - deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} - environment: review - description: "Publication to npm failed. Review the GitHub Actions log for more information." - log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - mediaType: '{"previews": ["flash", "ant-man"]}' - state: failure - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - name: Waiting for npm CDNs to update... - if: github.actor != 'dependabot[bot]' - run: | - echo "Giving npm some time to make the newly-published package available…" - sleep 5m - echo "Done waiting — hopefully that was enough time for the follow-up jobs to install the just-published package, to verify that everything looks OK." + - uses: actions/checkout@v2.3.4 + - name: Mark GitHub Deployment as in progress + id: start-deployment + uses: octokit/request-action@v2.x + if: github.actor != 'dependabot[bot]' + with: + route: POST /repos/:repository/deployments/:deployment/statuses + repository: ${{ github.repository }} + deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} + environment: review + description: "Publishing to npm tag [${{ needs.prepare-deployment.outputs.tag-slug }}]…" + log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + state: in_progress + mediaType: '{"previews": ["flash", "ant-man"]}' + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - uses: actions/setup-node@v2.1.5 + with: + node-version: "16.x" + registry-url: "https://registry.npmjs.org" + - name: Prepare prerelease version + id: determine-npm-version + if: github.actor != 'dependabot[bot]' + run: | + git config user.name $GITHUB_ACTOR + git config user.email gh-actions-${GITHUB_ACTOR}@github.com + # Unfortunately re-running a job does not change its run ID nor run number. + # To prevent re-releasing the same version when re-running the CD job, + # we incorporate a timestamp in the prerelease version: + TIMESTAMP=$(date --utc +%s) + # Make sure the prerelease is tagged with the branch name, and that they are sorted by build: + VERSION_NR=$(npm version prerelease --preid=$TAG_SLUG-$GITHUB_RUN_ID-$GITHUB_RUN_NUMBER-$TIMESTAMP) + echo "::set-output name=version-nr::$VERSION_NR" + env: + TAG_SLUG: ${{ needs.prepare-deployment.outputs.tag-slug }} + - run: npm ci + - name: Publish an npm tag for this branch + if: github.actor != 'dependabot[bot]' + run: | + # Unfortunately GitHub Actions does not currently let us do something like + # if: secrets.NPM_TOKEN != '' + # so simply skip the command if the env var is not set: + if [ -z $NODE_AUTH_TOKEN ]; then echo "No npm token defined; package not published."; fi + if [ -n $NODE_AUTH_TOKEN ]; then npm publish --access public --tag "$TAG_SLUG"; fi + if [ -n $NODE_AUTH_TOKEN ]; then echo "Package published. To install, run:"; fi + if [ -n $NODE_AUTH_TOKEN ]; then echo ""; fi + if [ -n $NODE_AUTH_TOKEN ]; then echo " npm install @inrupt/solid-client-errors-js@$TAG_SLUG"; fi + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + TAG_SLUG: ${{ needs.prepare-deployment.outputs.tag-slug }} + - name: Mark GitHub Deployment as successful + if: github.actor != 'dependabot[bot]' + uses: octokit/request-action@v2.x + with: + route: POST /repos/:repository/deployments/:deployment/statuses + repository: ${{ github.repository }} + deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} + environment: review + environment_url: "https://www.npmjs.com/package/@inrupt/solid-client-errors-js/v/${{ needs.prepare-deployment.outputs.tag-slug }}" + description: "Published to npm. To install, run: npm install @inrupt/solid-client-errors-js@${{ needs.prepare-deployment.outputs.tag-slug }}" + log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + mediaType: '{"previews": ["flash", "ant-man"]}' + state: success + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - name: Mark GitHub Deployment as failed + uses: octokit/request-action@v2.x + if: failure() + with: + route: POST /repos/:repository/deployments/:deployment/statuses + repository: ${{ github.repository }} + deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} + environment: review + description: "Publication to npm failed. Review the GitHub Actions log for more information." + log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + mediaType: '{"previews": ["flash", "ant-man"]}' + state: failure + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - name: Waiting for npm CDNs to update... + if: github.actor != 'dependabot[bot]' + run: | + echo "Giving npm some time to make the newly-published package available…" + sleep 5m + echo "Done waiting — hopefully that was enough time for the follow-up jobs to install the just-published package, to verify that everything looks OK." verify-imports-node: runs-on: ubuntu-20.04 @@ -140,80 +140,78 @@ jobs: node-version: [16.x, 14.x, 12.x] needs: [prepare-deployment, publish-npm] steps: - - uses: actions/checkout@v2.3.4 - - uses: actions/setup-node@v2.1.5 - with: - node-version: ${{ matrix.node-version }} - registry-url: 'https://registry.npmjs.org' - - name: Install the preview release of solid-client-errors-js in the packaging test project - if: github.actor != 'dependabot[bot]' - run: | - cd .github/workflows/cd-packaging-tests/node - npm install @inrupt/solid-client-errors-js@$VERSION_NR - env: - VERSION_NR: ${{ needs.publish-npm.outputs.version-nr }} - - name: Verify that the package can be imported in Node from a CommonJS module - if: github.actor != 'dependabot[bot]' - run: | - cd .github/workflows/cd-packaging-tests/node - node --unhandled-rejections=strict commonjs.cjs - - name: Verify that the package can be imported in Node from an ES module - if: github.actor != 'dependabot[bot]' - run: | - cd .github/workflows/cd-packaging-tests/node - node --unhandled-rejections=strict esmodule.mjs - # Node 10 does not support ES modules: - if: matrix.node-version != '10.x' + - uses: actions/checkout@v2.3.4 + - uses: actions/setup-node@v2.1.5 + with: + node-version: ${{ matrix.node-version }} + registry-url: "https://registry.npmjs.org" + - name: Install the preview release of solid-client-errors-js in the packaging test project + if: github.actor != 'dependabot[bot]' + run: | + cd .github/workflows/cd-packaging-tests/node + npm install @inrupt/solid-client-errors-js@$VERSION_NR + env: + VERSION_NR: ${{ needs.publish-npm.outputs.version-nr }} + - name: Verify that the package can be imported in Node from a CommonJS module + if: github.actor != 'dependabot[bot]' + run: | + cd .github/workflows/cd-packaging-tests/node + node --unhandled-rejections=strict commonjs.cjs + - name: Verify that the package can be imported in Node from an ES module + if: github.actor != 'dependabot[bot]' + run: | + cd .github/workflows/cd-packaging-tests/node + node --unhandled-rejections=strict esmodule.mjs verify-imports-parcel: runs-on: ubuntu-20.04 needs: [prepare-deployment, publish-npm] steps: - - uses: actions/checkout@v2.3.4 - - uses: actions/setup-node@v2.1.5 - with: - node-version: '16.x' - registry-url: 'https://registry.npmjs.org' - - name: Verify that the package can be imported in a Parcel project - if: github.actor != 'dependabot[bot]' - run: | - cd .github/workflows/cd-packaging-tests/bundler-parcel - npm install - npm install @inrupt/solid-client-errors-js@$VERSION_NR - # pin the version: https://github.com/parcel-bundler/parcel/issues/5943 - npx parcel@1.12.3 build index.ts - env: - VERSION_NR: ${{ needs.publish-npm.outputs.version-nr }} - - name: Archive Parcel build artifacts - if: github.actor != 'dependabot[bot]' - uses: actions/upload-artifact@v2.2.3 - continue-on-error: true - with: - name: parcel-dist - path: .github/workflows/cd-packaging-tests/bundler-parcel/dist + - uses: actions/checkout@v2.3.4 + - uses: actions/setup-node@v2.1.5 + with: + node-version: "16.x" + registry-url: "https://registry.npmjs.org" + - name: Verify that the package can be imported in a Parcel project + if: github.actor != 'dependabot[bot]' + run: | + cd .github/workflows/cd-packaging-tests/bundler-parcel + npm install + npm install @inrupt/solid-client-errors-js@$VERSION_NR + # pin the version: https://github.com/parcel-bundler/parcel/issues/5943 + npx parcel@1.12.3 build index.ts + env: + VERSION_NR: ${{ needs.publish-npm.outputs.version-nr }} + - name: Archive Parcel build artifacts + if: github.actor != 'dependabot[bot]' + uses: actions/upload-artifact@v2.2.3 + continue-on-error: true + with: + name: parcel-dist + path: .github/workflows/cd-packaging-tests/bundler-parcel/dist verify-imports-webpack: runs-on: ubuntu-20.04 needs: [prepare-deployment, publish-npm] steps: - - uses: actions/checkout@v2.3.4 - - uses: actions/setup-node@v2.1.5 - with: - node-version: '16.x' - registry-url: 'https://registry.npmjs.org' - - name: Verify that the package can be imported in a Webpack project - if: github.actor != 'dependabot[bot]' - run: | - cd .github/workflows/cd-packaging-tests/bundler-webpack - npm install @inrupt/solid-client-errors-js@$VERSION_NR - npm install - npx webpack --devtool source-map - env: - VERSION_NR: ${{ needs.publish-npm.outputs.version-nr }} - - name: Archive Webpack build artifacts - uses: actions/upload-artifact@v2.2.3 - continue-on-error: true - if: github.actor != 'dependabot[bot]' - with: - name: webpack-dist - path: .github/workflows/cd-packaging-tests/bundler-webpack/dist + - uses: actions/checkout@v2.3.4 + - uses: actions/setup-node@v2.1.5 + with: + node-version: "16.x" + registry-url: "https://registry.npmjs.org" + - name: Verify that the package can be imported in a Webpack project + if: github.actor != 'dependabot[bot]' + run: | + cd .github/workflows/cd-packaging-tests/bundler-webpack + npm install @inrupt/solid-client-errors-js@$VERSION_NR + npm install + npx webpack --devtool source-map + env: + VERSION_NR: ${{ needs.publish-npm.outputs.version-nr }} + - name: Archive Webpack build artifacts + uses: actions/upload-artifact@v2.2.3 + continue-on-error: true + if: github.actor != 'dependabot[bot]' + with: + name: webpack-dist + path: .github/workflows/cd-packaging-tests/bundler-webpack/dist diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c8feaf..bddfc5b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,34 +13,34 @@ jobs: os: [ubuntu-20.04, windows-2019, macos-10.15] node-version: [16.x, 14.x, 12.x] steps: - - uses: actions/checkout@v2.3.4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2.1.5 - with: - node-version: ${{ matrix.node-version }} - - name: Cache node modules - uses: actions/cache@v2.1.5 - env: - cache-name: cache-node-modules - with: - path: node_modules - key: ${{ runner.os }}-node${{ runner.node-version }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - - run: npm ci - - run: npm run build - - run: npm run lint - - run: npm run check-licenses - - run: npm audit --audit-level=moderate - - run: npm test - - run: npx package-check - - name: Archive code coverage results - uses: actions/upload-artifact@v2.2.3 - continue-on-error: true - with: - name: code-coverage-report - path: coverage - - name: Archive production artifacts - uses: actions/upload-artifact@v2.2.3 - continue-on-error: true - with: - name: dist - path: dist + - uses: actions/checkout@v2.3.4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2.1.5 + with: + node-version: ${{ matrix.node-version }} + - name: Cache node modules + uses: actions/cache@v2.1.5 + env: + cache-name: cache-node-modules + with: + path: node_modules + key: ${{ runner.os }}-node${{ runner.node-version }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + - run: npm ci + - run: npm run build + - run: npm run lint + - run: npm run check-licenses + - run: npm audit --audit-level=moderate + - run: npm test + - run: npx package-check + - name: Archive code coverage results + uses: actions/upload-artifact@v2.2.3 + continue-on-error: true + with: + name: code-coverage-report + path: coverage + - name: Archive production artifacts + uses: actions/upload-artifact@v2.2.3 + continue-on-error: true + with: + name: dist + path: dist diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index de939a6..dc4b224 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -8,13 +8,13 @@ name: "Static Application security Testing (CodeQL)" on: push: branches: - - '*' + - "*" pull_request: # The branches below must be a subset of the branches above branches: - - main + - main schedule: - - cron: '0 12 * * 6' + - cron: "0 12 * * 6" jobs: analyze: @@ -26,48 +26,48 @@ jobs: matrix: # Override automatic language detection by changing the below list # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: ['javascript'] + language: ["javascript"] # Learn more... # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection steps: - - name: Checkout repository - uses: actions/checkout@v2.3.4 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 + - name: Checkout repository + uses: actions/checkout@v2.3.4 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - 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 + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + 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@v1 + # 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 - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl - # ✏️ 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 + # ✏️ 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 + #- run: | + # make bootstrap + # make release - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/publish-website.yml b/.github/workflows/publish-website.yml index 826f139..2691404 100644 --- a/.github/workflows/publish-website.yml +++ b/.github/workflows/publish-website.yml @@ -11,43 +11,43 @@ jobs: publish-website: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2.3.4 - - name: Prepare for publication to GitHub Packages - uses: actions/setup-node@v2.1.5 - with: - node-version: '16.x' - registry-url: 'https://registry.npmjs.org' - - name: Build API docs - run: | - npm ci - npm run build-api-docs - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Install Python dependencies - run: | - python -m pip install --upgrade pip - cd docs/api/ - pip install -r requirements.txt - - name: Build website - run: | - npm run build-docs-preview-site - touch docs/dist/.nojekyll - - name: Deploy to GitHub Pages - run: | - git config user.name $GITHUB_ACTOR - git config user.email $GITHUB_ACTOR@users.noreply.github.com - git remote add gh-pages-remote https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git - git fetch --no-recurse-submodules - cd docs - git worktree add ./gh-pages gh-pages - cd gh-pages - git rm -r . - cp -r ../dist/. . - git add . - git commit --message="Deploying to GitHub Pages from $GITHUB_SHA" - git push gh-pages-remote gh-pages:gh-pages - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_REPOSITORY: ${{ github.repository }} + - uses: actions/checkout@v2.3.4 + - name: Prepare for publication to GitHub Packages + uses: actions/setup-node@v2.1.5 + with: + node-version: "16.x" + registry-url: "https://registry.npmjs.org" + - name: Build API docs + run: | + npm ci + npm run build-api-docs + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + cd docs/api/ + pip install -r requirements.txt + - name: Build website + run: | + npm run build-docs-preview-site + touch docs/dist/.nojekyll + - name: Deploy to GitHub Pages + run: | + git config user.name $GITHUB_ACTOR + git config user.email $GITHUB_ACTOR@users.noreply.github.com + git remote add gh-pages-remote https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git + git fetch --no-recurse-submodules + cd docs + git worktree add ./gh-pages gh-pages + cd gh-pages + git rm -r . + cp -r ../dist/. . + git add . + git commit --message="Deploying to GitHub Pages from $GITHUB_SHA" + git push gh-pages-remote gh-pages:gh-pages + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: ${{ github.repository }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dfaf829..04bdc39 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,9 @@ name: Release -on: - push: - tags: - - v[0-9]+.[0-9]+.[0-9]+ +on: + push: + tags: + - v[0-9]+.[0-9]+.[0-9]+ env: CI: true @@ -13,88 +13,88 @@ jobs: outputs: deployment-id: ${{ fromJson(steps.create-deployment.outputs.data).id }} steps: - - name: Create GitHub Deployment - id: create-deployment - uses: octokit/request-action@v2.x - with: - route: POST /repos/:repository/deployments - repository: ${{ github.repository }} - ref: ${{ github.sha }} - environment: review - transient_environment: true - auto_merge: false - mediaType: '{"previews": ["flash", "ant-man"]}' - # The deployment runs in parallel with CI, so status checks will never have succeeded yet: - required_contexts: '[]' - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - name: Create GitHub Deployment + id: create-deployment + uses: octokit/request-action@v2.x + with: + route: POST /repos/:repository/deployments + repository: ${{ github.repository }} + ref: ${{ github.sha }} + environment: review + transient_environment: true + auto_merge: false + mediaType: '{"previews": ["flash", "ant-man"]}' + # The deployment runs in parallel with CI, so status checks will never have succeeded yet: + required_contexts: "[]" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" publish-npm: runs-on: ubuntu-20.04 needs: [prepare-deployment] steps: - - uses: actions/checkout@v2.3.4 - - name: Mark GitHub Deployment as in progress - id: start-deployment - uses: octokit/request-action@v2.x - with: - route: POST /repos/:repository/deployments/:deployment/statuses - repository: ${{ github.repository }} - deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} - environment: review - description: "Publishing to npm tag [${GITHUB_REF#refs/tags/v}]…" - log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - state: in_progress - mediaType: '{"previews": ["flash", "ant-man"]}' - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - name: Prepare for publication to npm - uses: actions/setup-node@v2.1.5 - with: - node-version: '16.x' - registry-url: 'https://registry.npmjs.org' - - run: npm ci - - name: Publish to npm - run: | - npm publish --access public - echo "Package published. To install, run:" - echo "" - echo " npm install @inrupt/solid-client-errors-js" - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Mark GitHub Deployment as successful - uses: octokit/request-action@v2.x - with: - route: POST /repos/:repository/deployments/:deployment/statuses - repository: ${{ github.repository }} - deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} - environment: review - environment_url: 'https://www.npmjs.com/package/@inrupt/solid-client-errors-js/v/${GITHUB_REF#refs/tags/v}' - description: "Published to npm. To install, run: npm install @inrupt/solid-client-errors-js@${GITHUB_REF#refs/tags/v}" - log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - mediaType: '{"previews": ["flash", "ant-man"]}' - state: success - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - name: Mark GitHub Deployment as failed - uses: octokit/request-action@v2.x - if: failure() - with: - route: POST /repos/:repository/deployments/:deployment/statuses - repository: ${{ github.repository }} - deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} - environment: review - description: "Publication to npm failed. Review the GitHub Actions log for more information." - log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - mediaType: '{"previews": ["flash", "ant-man"]}' - state: failure - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - name: Waiting for npm CDNs to update... - run: | - echo "Giving npm some time to make the newly-published package available…" - sleep 5m - echo "Done waiting — hopefully that was enough time for the follow-up jobs to install the just-published package, to verify that everything looks OK." + - uses: actions/checkout@v2.3.4 + - name: Mark GitHub Deployment as in progress + id: start-deployment + uses: octokit/request-action@v2.x + with: + route: POST /repos/:repository/deployments/:deployment/statuses + repository: ${{ github.repository }} + deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} + environment: review + description: "Publishing to npm tag [${GITHUB_REF#refs/tags/v}]…" + log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + state: in_progress + mediaType: '{"previews": ["flash", "ant-man"]}' + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - name: Prepare for publication to npm + uses: actions/setup-node@v2.1.5 + with: + node-version: "16.x" + registry-url: "https://registry.npmjs.org" + - run: npm ci + - name: Publish to npm + run: | + npm publish --access public + echo "Package published. To install, run:" + echo "" + echo " npm install @inrupt/solid-client-errors-js" + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Mark GitHub Deployment as successful + uses: octokit/request-action@v2.x + with: + route: POST /repos/:repository/deployments/:deployment/statuses + repository: ${{ github.repository }} + deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} + environment: review + environment_url: "https://www.npmjs.com/package/@inrupt/solid-client-errors-js/v/${GITHUB_REF#refs/tags/v}" + description: "Published to npm. To install, run: npm install @inrupt/solid-client-errors-js@${GITHUB_REF#refs/tags/v}" + log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + mediaType: '{"previews": ["flash", "ant-man"]}' + state: success + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - name: Mark GitHub Deployment as failed + uses: octokit/request-action@v2.x + if: failure() + with: + route: POST /repos/:repository/deployments/:deployment/statuses + repository: ${{ github.repository }} + deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} + environment: review + description: "Publication to npm failed. Review the GitHub Actions log for more information." + log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + mediaType: '{"previews": ["flash", "ant-man"]}' + state: failure + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - name: Waiting for npm CDNs to update... + run: | + echo "Giving npm some time to make the newly-published package available…" + sleep 5m + echo "Done waiting — hopefully that was enough time for the follow-up jobs to install the just-published package, to verify that everything looks OK." verify-imports-node: runs-on: ubuntu-20.04 @@ -103,64 +103,64 @@ jobs: node-version: [16.x, 14.x, 12.x] needs: [prepare-deployment, publish-npm] steps: - - uses: actions/checkout@v2.3.4 - - uses: actions/setup-node@v2.1.5 - with: - node-version: ${{ matrix.node-version }} - registry-url: 'https://registry.npmjs.org' - - name: Install the preview release of solid-client-errors-js in the packaging test project - run: | - cd .github/workflows/cd-packaging-tests/node - npm install @inrupt/solid-client-errors-js - - name: Verify that the package can be imported in Node from a CommonJS module - run: | - cd .github/workflows/cd-packaging-tests/node - node --unhandled-rejections=strict commonjs.cjs - - name: Verify that the package can be imported in Node from an ES module - run: | - cd .github/workflows/cd-packaging-tests/node - node --unhandled-rejections=strict esmodule.mjs + - uses: actions/checkout@v2.3.4 + - uses: actions/setup-node@v2.1.5 + with: + node-version: ${{ matrix.node-version }} + registry-url: "https://registry.npmjs.org" + - name: Install the preview release of solid-client-errors-js in the packaging test project + run: | + cd .github/workflows/cd-packaging-tests/node + npm install @inrupt/solid-client-errors-js + - name: Verify that the package can be imported in Node from a CommonJS module + run: | + cd .github/workflows/cd-packaging-tests/node + node --unhandled-rejections=strict commonjs.cjs + - name: Verify that the package can be imported in Node from an ES module + run: | + cd .github/workflows/cd-packaging-tests/node + node --unhandled-rejections=strict esmodule.mjs verify-imports-parcel: runs-on: ubuntu-20.04 needs: [prepare-deployment, publish-npm] steps: - - uses: actions/checkout@v2.3.4 - - uses: actions/setup-node@v2.1.5 - with: - node-version: '16.x' - registry-url: 'https://registry.npmjs.org' - - name: Verify that the package can be imported in a Parcel project - run: | - cd .github/workflows/cd-packaging-tests/bundler-parcel - npm install @inrupt/solid-client-errors-js - npx parcel build index.ts - - name: Archive Parcel build artifacts - uses: actions/upload-artifact@v2.2.3 - with: - name: parcel-dist - path: .github/workflows/cd-packaging-tests/bundler-parcel/dist + - uses: actions/checkout@v2.3.4 + - uses: actions/setup-node@v2.1.5 + with: + node-version: "16.x" + registry-url: "https://registry.npmjs.org" + - name: Verify that the package can be imported in a Parcel project + run: | + cd .github/workflows/cd-packaging-tests/bundler-parcel + npm install @inrupt/solid-client-errors-js + npx parcel build index.ts + - name: Archive Parcel build artifacts + uses: actions/upload-artifact@v2.2.3 + with: + name: parcel-dist + path: .github/workflows/cd-packaging-tests/bundler-parcel/dist verify-imports-webpack: runs-on: ubuntu-20.04 needs: [prepare-deployment, publish-npm] steps: - - uses: actions/checkout@v2.3.4 - - uses: actions/setup-node@v2.1.5 - with: - node-version: '16.x' - registry-url: 'https://registry.npmjs.org' - - name: Verify that the package can be imported in a Webpack project - run: | - cd .github/workflows/cd-packaging-tests/bundler-webpack - npm install @inrupt/solid-client-errors-js - npm install webpack@5 webpack-cli buffer - npx webpack --devtool source-map - - name: Archive Webpack build artifacts - uses: actions/upload-artifact@v2.2.3 - with: - name: webpack-dist - path: .github/workflows/cd-packaging-tests/bundler-webpack/dist + - uses: actions/checkout@v2.3.4 + - uses: actions/setup-node@v2.1.5 + with: + node-version: "16.x" + registry-url: "https://registry.npmjs.org" + - name: Verify that the package can be imported in a Webpack project + run: | + cd .github/workflows/cd-packaging-tests/bundler-webpack + npm install @inrupt/solid-client-errors-js + npm install webpack@5 webpack-cli buffer + npx webpack --devtool source-map + - name: Archive Webpack build artifacts + uses: actions/upload-artifact@v2.2.3 + with: + name: webpack-dist + path: .github/workflows/cd-packaging-tests/bundler-webpack/dist # Run our Node-based end-to-end tests against the published package at least once, # to detect issues introduced by the build process: @@ -171,29 +171,29 @@ jobs: node-version: [16.x] needs: [prepare-deployment, publish-npm] steps: - - uses: actions/checkout@v2.3.4 - - uses: actions/setup-node@v2.1.5 - with: - node-version: ${{ matrix.node-version }} - registry-url: 'https://registry.npmjs.org' - - run: npm ci - - name: Install the preview release of solid-client-errors-js - # The `--force` allows us to install it even though our own package has the same name. - # See https://docs.npmjs.com/cli/v6/commands/npm-install#limitations-of-npms-install-algorithm - run: | - npm install --force @inrupt/solid-client-errors-js - - name: Make sure that the end-to-end tests run against the just-published package - run: | - cd e2e/node - # For all files (`-type f`) in this directory, - # replace `../index` (i.e. in the import statement) with `@inrupt/solid-client-errors-js`: - find ./ -type f -exec sed --in-place --expression='s/\.\.\/index/@inrupt\/solid-client-errors-js/g' {} \; - - name: Run the Node-based end-to-end tests - run: npm run e2e-test-node - env: - E2E_TEST_ESS_NOTIFICATION_GATEWAY: ${{secrets.E2E_TEST_ESS_PROD_NOTIFICATION_GATEWAY}} - E2E_TEST_ESS_POD: ${{ secrets.E2E_TEST_ESS_PROD_POD }} - E2E_TEST_ESS_IDP_URL: ${{ secrets.E2E_TEST_ESS_PROD_IDP_URL }} - E2E_TEST_ESS_REFRESH_TOKEN: ${{ secrets.E2E_TEST_ESS_PROD_REFRESH_TOKEN }} - E2E_TEST_ESS_CLIENT_ID: ${{ secrets.E2E_TEST_ESS_PROD_CLIENT_ID }} - E2E_TEST_ESS_CLIENT_SECRET: ${{ secrets.E2E_TEST_ESS_PROD_CLIENT_SECRET }} + - uses: actions/checkout@v2.3.4 + - uses: actions/setup-node@v2.1.5 + with: + node-version: ${{ matrix.node-version }} + registry-url: "https://registry.npmjs.org" + - run: npm ci + - name: Install the preview release of solid-client-errors-js + # The `--force` allows us to install it even though our own package has the same name. + # See https://docs.npmjs.com/cli/v6/commands/npm-install#limitations-of-npms-install-algorithm + run: | + npm install --force @inrupt/solid-client-errors-js + - name: Make sure that the end-to-end tests run against the just-published package + run: | + cd e2e/node + # For all files (`-type f`) in this directory, + # replace `../index` (i.e. in the import statement) with `@inrupt/solid-client-errors-js`: + find ./ -type f -exec sed --in-place --expression='s/\.\.\/index/@inrupt\/solid-client-errors-js/g' {} \; + - name: Run the Node-based end-to-end tests + run: npm run e2e-test-node + env: + E2E_TEST_ESS_NOTIFICATION_GATEWAY: ${{secrets.E2E_TEST_ESS_PROD_NOTIFICATION_GATEWAY}} + E2E_TEST_ESS_POD: ${{ secrets.E2E_TEST_ESS_PROD_POD }} + E2E_TEST_ESS_IDP_URL: ${{ secrets.E2E_TEST_ESS_PROD_IDP_URL }} + E2E_TEST_ESS_REFRESH_TOKEN: ${{ secrets.E2E_TEST_ESS_PROD_REFRESH_TOKEN }} + E2E_TEST_ESS_CLIENT_ID: ${{ secrets.E2E_TEST_ESS_PROD_CLIENT_ID }} + E2E_TEST_ESS_CLIENT_SECRET: ${{ secrets.E2E_TEST_ESS_PROD_CLIENT_SECRET }} diff --git a/.vscode/launch.json b/.vscode/launch.json index 6ae4fc0..8229ab3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,10 +13,7 @@ "type": "node", "name": "vscode-jest-tests", "request": "launch", - "args": [ - "--runInBand", - "--coverage=false" - ], + "args": ["--runInBand", "--coverage=false"], "cwd": "${workspaceFolder}", "console": "integratedTerminal", "internalConsoleOptions": "neverOpen", @@ -24,4 +21,4 @@ "program": "${workspaceFolder}/node_modules/jest/bin/jest" } ] -} \ No newline at end of file +}