0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

ci: upload eslint annotations (#490)

* ci: upload eslint annotations

* ci: update `upload-annotations.yml`
This commit is contained in:
Gao Sun 2022-04-06 14:06:34 +08:00 committed by GitHub
parent 71465ca999
commit 4a904f2953
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 54 additions and 0 deletions

View file

@ -0,0 +1,34 @@
name: Upload Annotations
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
upload-annotations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node and pnpm
uses: logto-io/actions-node-pnpm-run-steps@v1.0.2
- name: Prepack
run: pnpm prepack
- name: Lint with Report
run: pnpm -- lerna run --parallel lint:report && node merge-eslint-reports.js
- name: Annotate Code Linting Results
uses: ataylorme/eslint-annotate-action@1.2.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload ESLint report
uses: actions/upload-artifact@v2
with:
name: eslint_report.json
path: eslint_report.json

4
.gitignore vendored
View file

@ -8,6 +8,10 @@ node_modules
# testing # testing
/packages/*/coverage /packages/*/coverage
# report
/report.json
/packages/*/report.json
# production # production
/packages/*/build /packages/*/build
/packages/*/lib /packages/*/lib

11
merge-eslint-reports.js Normal file
View file

@ -0,0 +1,11 @@
const fs = require('fs');
const directories = fs.readdirSync('./packages');
const reports = directories.map((dir) => fs.readFileSync(`./packages/${dir}/report.json`, { encoding: 'utf-8' }));
const merged = [];
for (const report of reports) {
merged.push(...JSON.parse(report));
}
fs.writeFileSync('./eslint_report.json', JSON.stringify(merged));

View file

@ -14,6 +14,7 @@
"check": "tsc --noEmit", "check": "tsc --noEmit",
"build": "pnpm check && rm -rf dist && pnpm copyfiles && parcel build src/index.html --no-autoinstall --public-url /console", "build": "pnpm check && rm -rf dist && pnpm copyfiles && parcel build src/index.html --no-autoinstall --public-url /console",
"lint": "eslint --ext .ts --ext .tsx src", "lint": "eslint --ext .ts --ext .tsx src",
"lint:report": "pnpm lint -- --format json --output-file report.json",
"stylelint": "stylelint \"src/**/*.scss\"" "stylelint": "stylelint \"src/**/*.scss\""
}, },
"dependencies": { "dependencies": {

View file

@ -12,6 +12,7 @@
"copyfiles": "copyfiles -u 1 src/**/*.md build", "copyfiles": "copyfiles -u 1 src/**/*.md build",
"build": "rm -rf build/ && tsc -p tsconfig.build.json && pnpm run copyfiles", "build": "rm -rf build/ && tsc -p tsconfig.build.json && pnpm run copyfiles",
"lint": "eslint --ext .ts src", "lint": "eslint --ext .ts src",
"lint:report": "pnpm lint -- --format json --output-file report.json",
"dev": "rm -rf build/ && pnpm run copyfiles && tsc-watch -p tsconfig.build.json --preserveWatchOutput --onSuccess \"node ./build/index.js\"", "dev": "rm -rf build/ && pnpm run copyfiles && tsc-watch -p tsconfig.build.json --preserveWatchOutput --onSuccess \"node ./build/index.js\"",
"start": "NODE_ENV=production node build/index.js", "start": "NODE_ENV=production node build/index.js",
"test": "jest", "test": "jest",

View file

@ -19,6 +19,7 @@
"precommit": "lint-staged", "precommit": "lint-staged",
"build": "rm -rf lib/ && tsc", "build": "rm -rf lib/ && tsc",
"lint": "eslint --ext .ts src", "lint": "eslint --ext .ts src",
"lint:report": "pnpm lint -- --format json --output-file report.json",
"prepack": "pnpm build" "prepack": "pnpm build"
}, },
"bugs": { "bugs": {

View file

@ -15,6 +15,7 @@
"generate": "rm -rf src/db-entries && ts-node src/gen/index.ts && eslint \"src/db-entries/**\" --fix", "generate": "rm -rf src/db-entries && ts-node src/gen/index.ts && eslint \"src/db-entries/**\" --fix",
"build": "pnpm generate && rm -rf lib/ && tsc --p tsconfig.build.json", "build": "pnpm generate && rm -rf lib/ && tsc --p tsconfig.build.json",
"lint": "eslint --ext .ts src", "lint": "eslint --ext .ts src",
"lint:report": "pnpm lint -- --format json --output-file report.json",
"prepack": "pnpm build" "prepack": "pnpm build"
}, },
"engines": { "engines": {

View file

@ -11,6 +11,7 @@
"check": "tsc --noEmit", "check": "tsc --noEmit",
"build": "pnpm check && rm -rf dist && parcel build src/index.html --no-autoinstall", "build": "pnpm check && rm -rf dist && parcel build src/index.html --no-autoinstall",
"lint": "eslint --ext .ts --ext .tsx src", "lint": "eslint --ext .ts --ext .tsx src",
"lint:report": "pnpm lint -- --format json --output-file report.json",
"stylelint": "stylelint \"src/**/*.scss\"", "stylelint": "stylelint \"src/**/*.scss\"",
"test": "jest" "test": "jest"
}, },