feat(utils
): add package.json
#957
This file contains hidden or 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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
# For more information see: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow | |
name: CI | |
on: | |
push: | |
branches: ["*"] | |
paths: | |
- "recipes/**" | |
- "package.json" | |
- "package-lock.json" | |
- ".github/workflows/*.yml" | |
pull_request: | |
branches: ["*"] | |
paths: | |
- "recipes/**" | |
- "package.json" | |
- "package-lock.json" | |
- ".github/workflows/*.yml" | |
types: | |
- opened | |
- ready_for_review | |
- reopened | |
- synchronize | |
permissions: | |
contents: read | |
jobs: | |
get-matrix: | |
name: Configure Node LTS environment matrix | |
runs-on: ubuntu-latest | |
outputs: | |
latest: ${{ steps.set-matrix.outputs.requireds }} | |
steps: | |
- name: Harden the runner (Audit all outbound calls) | |
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 | |
with: | |
egress-policy: audit | |
- uses: ljharb/actions/node/matrix@7f214d8efdbdcefc96ad9689663ef387a195deec # main | |
id: set-matrix | |
with: | |
versionsAsRoot: true | |
type: majors | |
preset: ">= 22" # glob is not backported below 22.x | |
lint-and-types: | |
name: Lint & types | |
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Harden the runner (Audit all outbound calls) | |
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 | |
with: | |
egress-policy: audit | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
persist-credentials: false | |
show-progress: false | |
- name: Set up Node.js LTS | |
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
with: | |
cache: "npm" | |
check-latest: true | |
node-version-file: ".nvmrc" | |
- run: npm ci | |
- run: node --run lint | |
- run: node --run type-check | |
validate-yaml: | |
name: Validate YAML files | |
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Harden the runner (Audit all outbound calls) | |
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 | |
with: | |
egress-policy: audit | |
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0 | |
- name: Validate YAML files | |
run: yamllint -c .yamllint.yaml -f github ./ | |
tests: | |
name: Unit, e2e, coverage | |
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }} | |
needs: [get-matrix] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
node-version: ${{ fromJson(needs.get-matrix.outputs.latest) }} | |
os: | |
- macos-latest | |
- ubuntu-latest | |
- windows-latest | |
steps: | |
- name: Harden the runner (Audit all outbound calls) | |
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 | |
with: | |
egress-policy: audit | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
persist-credentials: false | |
show-progress: false | |
- name: Set up Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
with: | |
cache: "npm" | |
check-latest: true | |
node-version: ${{ matrix.node-version }} | |
- run: npm ci | |
- name: Run recipe tests | |
run: >- | |
node | |
--run test | |
--test-coverage-lines=0.8 | |
--test-reporter-destination=./coverage.lcov | |
--test-reporter=lcov |