-
Notifications
You must be signed in to change notification settings - Fork 28
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
ci: move pre-commit checks to CI #893
Changes from 11 commits
b980629
ffe4ec2
14ab46b
24dcfe8
838efe1
c02189b
8287a4f
de37658
adae6bc
1394cbf
497942a
9326848
f8eb000
2f31efe
233c64b
77dc984
cbe5048
282ac52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,13 +32,11 @@ | |
"coverage": "vitest run --coverage", | ||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0", | ||
"format": "eslint src/ editor/ --fix && prettier 'editor/**/*.css' --write", | ||
"schema": "ts-json-schema-generator -p src/index.ts -f tsconfig.json -t GoslingSpec --no-type-check --no-ref-encode > schema/gosling.schema.json", | ||
"schema-higlass": "ts-json-schema-generator -p src/index.ts -f tsconfig.json -t HiGlassSpec --no-type-check --no-ref-encode > schema/higlass.schema.json", | ||
"schema-theme": "ts-json-schema-generator -p src/index.ts -f tsconfig.json -t Theme --no-type-check --no-ref-encode > schema/theme.schema.json", | ||
"schema-template": "ts-json-schema-generator -p src/index.ts -f tsconfig.json -t TemplateTrackDef --no-type-check --no-ref-encode > schema/template.schema.json", | ||
"schema": "node scripts/generate-schemas.mjs", | ||
"schema-versioning": "mkdir -p schema/history/$npm_package_version && cp schema/gosling.schema.json schema/history/$npm_package_version/gosling$npm_package_version.schema.json && cp src/core/gosling.schema.ts schema/history/$npm_package_version/gosling$npm_package_version.schema.ts", | ||
"predeploy": "yarn build-editor; echo \"gosling.js.org\" >> build/CNAME", | ||
"deploy": "gh-pages -d build" | ||
"deploy": "gh-pages -d build", | ||
"pre-commit": "run-p changelog schema format" | ||
}, | ||
"peerDependencies": { | ||
"pixi.js": "^6.3.0", | ||
|
@@ -155,7 +153,6 @@ | |
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "run-p changelog schema schema-higlass schema-theme schema-template format && git add .", | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, since our "git flow" is squash & merge PRs, idk if it makes sense to lint every commit for conventional commits. Instead, something like a GitHub action to lint the PR title would probably make more sense Not sure if either of you have thoughts on this: @etowahadams @sehilyi There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would make sense to use the We were using another semantic PR which is deprecated and does not work anymore. We were using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree! No need to have every conventional commit name be linted. |
||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// @ts-check | ||
import * as fs from "node:fs"; | ||
import * as path from "node:path"; | ||
import * as url from "node:url"; | ||
import * as tsj from "ts-json-schema-generator"; | ||
|
||
// Copied from `ts-json-schema-generator` to create | ||
// identical schemas to the one previously generated by CLI. | ||
// @ref: https://github.com/vega/ts-json-schema-generator/blob/aec8a25f366fa32ba9539adc5a91f4ff3b14d1e9/ts-json-schema-generator.ts#LL67C1-L68C1 | ||
import stableStringify from "safe-stable-stringify"; | ||
|
||
const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); | ||
|
||
const SCHEMAS = [ | ||
["GoslingSpec", "gosling.schema.json"], | ||
["HiGlassSpec", "higlass.schema.json"], | ||
["Theme", "theme.schema.json"], | ||
["TemplateTrackDef", "template.schema.json"], | ||
]; | ||
|
||
const generator = tsj.createGenerator({ | ||
path: path.resolve(__dirname, "../src/index.ts"), | ||
tsconfig: path.resolve(__dirname, "../tsconfig.json"), | ||
skipTypeCheck: true, | ||
encodeRefs: false, | ||
}); | ||
Comment on lines
+21
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Running |
||
|
||
for (const [type, filename] of SCHEMAS) { | ||
const schema = generator.createSchema(type); | ||
fs.promises.writeFile( | ||
path.resolve(__dirname, `../schema/${filename}`), | ||
stableStringify(schema, null, 2) + "\n", | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ideally this action can run very quickly, and fail early (to prevent other jobs from running).
Maybe we could use
npx
here (rather than yarn installing everything for the repo).