CI #123
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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
name: "CI" | |
on: | |
push: | |
branches: ["master"] | |
pull_request: | |
branches: ["master"] | |
schedule: | |
- cron: "15 21 * * 0" | |
jobs: | |
analyze: | |
name: Analyze | |
runs-on: "ubuntu-latest" | |
timeout-minutes: 360 | |
permissions: | |
security-events: write | |
actions: read | |
contents: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v3 | |
with: | |
languages: "javascript-typescript" | |
- name: Autobuild | |
uses: github/codeql-action/autobuild@v3 | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v3 | |
with: | |
category: "/language:javascript-typescript" | |
eslint: | |
name: lint:eslint | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
security-events: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: "npm" | |
- run: npm ci | |
- name: Run ESLint | |
run: npm run lint:eslint -- --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif | |
continue-on-error: true | |
- name: Upload analysis results to GitHub | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: eslint-results.sarif | |
wait-for-processing: true | |
prettier: | |
name: lint:prettier | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: "npm" | |
- run: npm ci | |
- name: Run Prettier | |
uses: creyD/prettier_action@v4.3 | |
with: | |
dry: true | |
prettier_version: "npm:@btmills/prettier@3.1.0" | |
prettier_options: --check src/**/*.ts --config ./.prettierrc | |
vitest: | |
name: test:coverage | |
runs-on: ubuntu-latest | |
permissions: | |
checks: write | |
contents: read | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: "npm" | |
- run: npm ci | |
- name: Run Vitest | |
run: npm run test:coverage | |
continue-on-error: true | |
- name: Code Coverage Summary Report | |
uses: irongut/CodeCoverageSummary@v1.3.0 | |
if: always() | |
with: | |
filename: coverage/**/cobertura-coverage.xml | |
badge: true | |
format: markdown | |
output: both | |
- name: Publish Test Report | |
uses: mikepenz/action-junit-report@v4 | |
if: always() | |
- name: Add Coverage PR Comment | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: ${{ always() && github.event_name == 'pull_request' }} | |
with: | |
recreate: true | |
path: code-coverage-results.md | |
build: | |
needs: [eslint, prettier, vitest] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: "npm" | |
- run: npm ci | |
- run: npm run build --if-present | |
- name: Test ESModule build | |
run: cd test && ./test.sh js | |
- name: Test CommonJS build | |
run: cd test && ./test.sh cjs |