Skip to content

Add CI workflow to check project's npm configuration #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/check-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Check npm

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/check-npm.yml"
- "**/package.json"
- "**/package-lock.json"
pull_request:
paths:
- ".github/workflows/check-npm.yml"
- "**/package.json"
- "**/package-lock.json"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
validate:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Download JSON schema for package.json
id: download-schema
uses: carlosperate/[email protected]
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
file-url: https://json.schemastore.org/package.json
location: ${{ runner.temp }}/package-json-schema
file-name: package-json-schema.json

- name: Install JSON schema validator
# package.json schema is draft-04, which is not supported by ajv-cli >=4.
run: sudo npm install --global [email protected]

- name: Validate GitHub Actions workflows
run: |
# See: https://github.com/ajv-validator/ajv-cli#readme
ajv validate \
-s "${{ steps.download-schema.outputs.file-path }}" \
-d "./**/package.json"

check-manifest:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install dependencies
run: npm install

- name: Check manifest
run: git diff --color --exit-code package-lock.json
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.