Skip to content
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

Health report of package.json for CI use #1

Merged
merged 28 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
72c254e
feat(peers): add script and modules
mxdvl Jan 20, 2023
36641e7
refactor: single pass analysis of satisfied
mxdvl Jan 23, 2023
5eaf930
docs: update to-do list
mxdvl Jan 23, 2023
808aa78
feat: handle edge cases and quiet mode
mxdvl Jan 23, 2023
203301c
feat: add caching option
mxdvl Jan 24, 2023
2b84c6c
refactor: extract formatting
mxdvl Jan 24, 2023
2f2b82b
fix: clean up code
mxdvl Jan 24, 2023
ce37682
refactor: better tree shaping
mxdvl Jan 24, 2023
860fe75
fix: handle invalid ranges
mxdvl Jan 24, 2023
7490588
feat: breathe a little
mxdvl Jan 24, 2023
e4083dd
feat: indicate the reason for mismatch
mxdvl Jan 24, 2023
d5d7af3
refactor: extract benchmark
mxdvl Jan 24, 2023
9832ba9
feat: add lock file
mxdvl Jan 24, 2023
4e728f7
refactor: check package in a single pass
mxdvl Jan 25, 2023
25097a9
feat: check @types/* packages
mxdvl Jan 25, 2023
79c779e
chore: change colours and add deno config
mxdvl Jan 25, 2023
24e1563
chore: vscode config
mxdvl Jan 25, 2023
7952a8e
feat: add lock file
mxdvl Jan 25, 2023
c79fa64
feat: add CI workflow
mxdvl Jan 25, 2023
e3d3bfc
fix: use cache @ v3
mxdvl Jan 25, 2023
b2d9ebe
refactor: move files to src
mxdvl Jan 25, 2023
4c773af
feat: allow success if known number of errors
mxdvl Jan 25, 2023
3c00012
chore: remove unused final step
mxdvl Jan 25, 2023
dbef96c
feat: better error on duplicate
mxdvl Jan 25, 2023
d646727
refactor(cache): passe it around
mxdvl Jan 25, 2023
628d475
chore: remove unused import
mxdvl Jan 25, 2023
a26585a
feat: use unpkg.com for speed
mxdvl Jan 25, 2023
56db854
fix: remove caches from tests
mxdvl Jan 25, 2023
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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DENO_DIR=.cache
102 changes: 102 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: CI
on:
pull_request:
workflow_dispatch:


env:
DENO_DIR: ./cache

jobs:
health:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Cache Deno dependencies
uses: actions/cache@v3
with:
path: ${{ env.DENO_DIR }}
key: ${{ hashFiles('lock.json') }}

- name: Format
run: deno fmt src --check

- name: Lint
run: deno lint src

- name: Test
run: deno test src --allow-net=unpkg.com

working_package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Cache Deno dependencies
uses: actions/cache@v3
with:
path: ${{ env.DENO_DIR }}
key: ${{ hashFiles('lock.json') }}

- run: |
deno run \
--allow-net=unpkg.com \
--allow-read=. \
src/main.ts \
fixtures/package_valid.json \
--verbose --cache

failing_peer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Cache Deno dependencies
uses: actions/cache@v3
with:
path: ${{ env.DENO_DIR }}
key: ${{ hashFiles('lock.json') }}

- run: |
deno run \
--allow-net=unpkg.com \
--allow-read=. \
src/main.ts \
fixtures/package.json \
--verbose --cache --errors=7

failing_duplicates:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Cache Deno dependencies
uses: actions/cache@v3
with:
path: ${{ env.DENO_DIR }}
key: ${{ hashFiles('lock.json') }}

- run: |
deno run \
--allow-net=unpkg.com \
--allow-read=. \
src/main.ts \
fixtures/package_duplicate.json \
--verbose --cache --errors=3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.cache
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"deno.enable": true,
"deno.unstable": true,
"editor.defaultFormatter": "denoland.vscode-deno",
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"deno.suggest.completeFunctionCalls": true
}
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# actions-npm-dependencies

Validate your NPM dependencies without installing Node (WIP)

## Todo

- [x] Make it functional and composable
- [x] Handle peer dependencies
- [ ] Handle lock files? (probably not)
- [x] Great error messaging
- [ ] Investigate direct dependencies of dependencies, which may have peers
themselves
- [ ] Give insight into possible resolution steps, including intersects
6 changes: 6 additions & 0 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"noUncheckedIndexedAccess": true,
"lib": ["dom", "deno.ns"]
}
}
197 changes: 197 additions & 0 deletions deno.lock

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions fixtures/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "npm-dependencies",
"version": "0.0.1",
"dependencies": {
"@types/node": "~18.11",
"@guardian/source-foundations": "8.0.0",
"@guardian/core-web-vitals": "2.0.2"
},
"devDependencies": {
"@guardian/libs": "^12",
"@guardian/ab-react": "^2.0.1"
}
}
11 changes: 11 additions & 0 deletions fixtures/package_duplicate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "npm-dependencies-duplicate",
"version": "0.0.2",
"dependencies": {
"@guardian/source-foundations": "8.0.0",
"@guardian/libs": "^12"
},
"devDependencies": {
"@guardian/libs": "^12"
}
}
12 changes: 12 additions & 0 deletions fixtures/package_typescript.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "npm-dependencies-typescript",
"version": "0.0.1",
"dependencies": {
"@guardian/source-foundations": "8.0.0"
},
"devDependencies": {
"typescript": "^4.2.4",
"@guardian/libs": "^12",
"@guardian/ab-react": "^2.0.1"
}
}
17 changes: 17 additions & 0 deletions fixtures/package_valid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "npm-dependencies",
"version": "0.0.1",
"dependencies": {
"@guardian/ab-core": "2.0.0",
"@guardian/core-web-vitals": "2.0.2",
"@guardian/source-foundations": "8.0.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"tslib": "^2.4.1",
"web-vitals": "^2.0.1"
},
"devDependencies": {
"@guardian/libs": "^12",
"@guardian/ab-react": "^2.0.1"
}
}
Loading