Merge pull request #32 from lifeiscontent/patch-1 #108
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lint, Test & Release | |
on: | |
push: | |
branches-ignore: | |
- 'dependabot/**' | |
pull_request: | |
permissions: | |
contents: read | |
env: | |
CI: true | |
jobs: | |
commitlint: | |
name: Lint commits | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16.x | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm clean-install | |
- name: Lint commit | |
if: github.event_name == 'push' | |
run: npx commitlint --from HEAD~1 --to HEAD --verbose | |
- name: Lint commits | |
if: github.event_name == 'pull_request' | |
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose | |
codelint: | |
name: Lint code | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16.x | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm clean-install | |
- name: Lint code | |
run: npm run lint | |
test: | |
name: Run tests | |
runs-on: ubuntu-latest | |
needs: | |
- commitlint | |
- codelint | |
strategy: | |
matrix: | |
node-version: [14.x, 16.x, 18.x, 20.x] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- name: Setup Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm clean-install | |
- name: Run tests | |
run: npm run test:workflow | |
coverage: | |
name: Test coverage | |
runs-on: ubuntu-latest | |
needs: | |
- commitlint | |
- codelint | |
permissions: | |
contents: read | |
pull-requests: write # to be able to comment on released pull requests | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- name: Use Node.js 20.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20.x | |
cache: 'npm' | |
- name: Install deps | |
run: npm ci | |
- name: Test code | |
run: npm run test:coverage --silent -- npm run test:workflow | |
- name: Code Coverage Summary | |
uses: irongut/[email protected] | |
with: | |
filename: coverage/cobertura-coverage.xml | |
badge: true | |
format: markdown | |
output: both | |
- name: Add Coverage PR Comment | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: github.event_name == 'pull_request' | |
continue-on-error: true | |
with: | |
recreate: true | |
path: code-coverage-results.md | |
release: | |
name: Release | |
concurrency: release | |
if: ${{ github.event_name == 'push' && github.actor != 'dependabot[bot]' }} | |
runs-on: ubuntu-latest | |
needs: | |
- commitlint | |
- codelint | |
- test | |
permissions: | |
contents: write # to be able to publish a GitHub release | |
issues: write # to be able to comment on released issues | |
pull-requests: write # to be able to comment on released pull requests | |
id-token: write # to enable use of OIDC for npm provenance | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "lts/*" | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm clean-install | |
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies | |
run: npm audit signatures | |
- name: Release | |
env: | |
NPM_CONFIG_PROVENANCE: true | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: npx semantic-release |