Skip to content

Commit

Permalink
build(ci): adds depcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Ephigenia committed Apr 10, 2022
1 parent f1c9d07 commit d4ead41
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 7 deletions.
9 changes: 9 additions & 0 deletions .depcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# depcheck configuration
# SEE https://www.npmjs.com/package/depcheck#api

# if you add ignores also annotate why the package is ignored
# keep list ordered at all times
ignores:
- "@commitlint/cli"
- "@commitlint/config-angular"
- "@istanbuljs/nyc-config-typescript"
24 changes: 24 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: setup
description: 'basic setup project with npm ci'

runs:
using: "composite"
steps:
- name: setup nodejs
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
check-latest: true
cache: npm
- name: cache dependencies
id: cache
uses: actions/cache@v3
with:
path: ./node_modules
key: node-modules-${{ runner.name }}-${{ runner.arch}}-${{ hashFiles('package-lock.json') }}
- name: install dependencies
run: npm ci --no-audit
# only run npm ci when restoring the cache didn’t work to save some time
# as npm ci would remove the node_modules again
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
30 changes: 30 additions & 0 deletions .github/workflows/depcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# SEE https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions

# Runs `npx depcheck`
#
# Depcheck is a tool for analyzing the dependencies in a project to see: how
# each dependency is used, which dependencies are useless, and which
# dependencies are missing from package.json.
#
# https://www.npmjs.com/package/depcheck

name: depcheck

on:
# allow manual trigger workflow
pull_request:
branches:
- main
paths:
# run only when one of the files matching the glob patterns changed
- 'package.json'
- 'package-lock.json'

jobs:

depcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
- run: npx depcheck
6 changes: 1 addition & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,5 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- run: npm ci --no-optional
- uses: ./.github/actions/setup
- run: npm test
4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fi
. "$(dirname "$0")/_/husky.sh"

printf "%b>>>%b lint...\n" "$GREEN" "$NO_COLOR"
npm run lint:fix -s
npm run -s lint:fix

printf "%b>>>%b prettier...\n" "$GREEN" "$NO_COLOR"
npm run format
npm run -s format

0 comments on commit d4ead41

Please sign in to comment.