Files
npm-audit-action/.github/workflows/test.yml
2025-05-13 21:10:54 +09:00

108 lines
3.1 KiB
YAML

name: 'build-test'
on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- main
jobs:
build: # make sure build/ci work properly
strategy:
matrix:
node: [20]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install dependencies and run tests
run: |
npm ci
npm run test:coverage
- name: Upload coverage to Coveralls
if: matrix.os == 'ubuntu-latest'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
build-on-windows:
strategy:
matrix:
node: [20]
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install dependencies and run tests
run: |
npm ci
npm run test
test: # make sure the action works on a clean machine without building
strategy:
matrix:
node: [20]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Run npm audit action
uses: ./
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
issue_title: npm audit run by test job
create_issues: false
production_flag: true
- name: Run npm audit action in testdata workdir
uses: ./
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
working_directory: __tests__/testdata/workdir
create_issues: false
production_flag: true
# test-on-windows:
# strategy:
# matrix:
# node: [20]
# runs-on: windows-latest
# steps:
# - name: Dump GitHub context
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: echo "$GITHUB_CONTEXT"
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with:
# node-version: ${{ matrix.node }}
# # Set PowerShell execution policy for this process
# - name: Set PowerShell execution policy
# shell: powershell
# run: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
# # Node.js 20 already includes a recent npm version, so npm upgrade is not needed
# - name: Run npm audit action
# uses: ./
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# issue_title: npm audit run by test job
# create_issues: false
# production_flag: true
# - name: Run npm audit action in testdata workdir
# uses: ./
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# working_directory: __tests__/testdata/workdir
# create_issues: false
# production_flag: true