Skip to content

fix: ignore "package.json" as config file when it's invalid JSON #770

fix: ignore "package.json" as config file when it's invalid JSON

fix: ignore "package.json" as config file when it's invalid JSON #770

Workflow file for this run

name: Test & Release
on:
push:
# Run on pushes to specific branches
branches:
- master
- beta
- alpha
# Do not run on tags
tags-ignore:
- "*"
pull_request:
# Run on to branches with an open PR
branches:
- "*"
permissions:
contents: read
jobs:
lint:
name: ESLint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
# Install node_modules
- uses: actions/cache@v3
id: cache-node_modules
with:
path: node_modules
key: ubuntu-latest-18-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
ubuntu-latest-18-${{ hashFiles('**/package-lock.json') }}
- if: steps.cache-node_modules.outputs.cache-hit != 'true'
run: npm ci
- run: npm run lint
test:
strategy:
matrix:
# Test with Node.js v14 (LTS), v16 (LTS), and 18 (Current)
node:
- 14
- 16
- 18
# Test with Ubuntu, macOS, and Windows
os:
- ubuntu-latest
- macos-latest
- windows-latest
name: Node.js v${{ matrix.node }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- if: matrix.os == 'windows-latest'
run: git config --global core.autocrlf true
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
# Node.js 14 ships with npm@6, which has trouble installing latest versions of itself
- if: matrix.node == 14
run: npm install -g npm@8
# Install latest npm for older Node.js versions
- run: npm install -g npm
# Install node_modules
- uses: actions/cache@v3
id: cache-node_modules
with:
path: node_modules
key: ${{ matrix.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
- if: steps.cache-node_modules.outputs.cache-hit != 'true'
run: npm ci
# Print current Node.js version
- run: node --version
# Print current npm version
- run: npm --version
# Print current Git version
- run: git --version
# Print lint-staged version
- run: node bin/lint-staged.js --version
# Print lint-staged help text
- run: node bin/lint-staged.js --help
# Run tests
- run: npm test
# Upload coverage artifact from Node.js LTS
- uses: actions/upload-artifact@v3
if: matrix.os == 'ubuntu-latest' && matrix.node == '16'
with:
name: coverage
path: coverage
codecov:
name: Codecov
runs-on: ubuntu-latest
needs:
- lint
- test
steps:
- uses: actions/checkout@v3
# Download coverage artifact
- uses: actions/download-artifact@v3
with:
name: coverage
# Run codecov.io
- uses: codecov/codecov-action@v3
release:
permissions:
contents: write # for publishing release
name: Release
runs-on: ubuntu-latest
needs:
- lint
- test
# Trigger release for only pushes to branches defined above
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18 # release using Node.js LTS
# Release using semantic-release.
# While this runs on all branches, it will only release latest from master
- uses: codfish/semantic-release-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}