0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Added pre-push hook to run unit tests on changed packages

fixes https://github.com/TryGhost/Toolbox/issues/532

- we should protect against failures entering `main` which could be
  avoided by running a quick unit test beforehand
- this reintroduces Lerna as it supports parallelisation and `--since`,
  to run linting and unit tests on packages that have changed since
  upstream
This commit is contained in:
Daniel Lockyer 2023-03-22 16:30:40 +01:00
parent a287912cf2
commit 56b407f1f4
No known key found for this signature in database
4 changed files with 1830 additions and 131 deletions

10
.github/hooks/pre-push vendored Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
[ -n "$CI" ] && exit 0
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$GIT_BRANCH" = "main" ]; then
printf " Pushing to \033[0;42m$GIT_BRANCH\033[0m branch requires some checks in advance\n"
yarn lerna run --include-dependents --since ${GHOST_UPSTREAM:-origin}/$GIT_BRANCH test:unit
fi

View file

@ -157,7 +157,7 @@ jobs:
cache: yarn
- run: yarn
- run: yarn workspaces run test:unit
- run: yarn test:unit
- uses: actions/upload-artifact@v3
if: startsWith(matrix.node, '16')

View file

@ -26,9 +26,10 @@
"dev": "node .github/dev.js",
"fix": "yarn cache clean && rm -rf node_modules && yarn",
"knex-migrator": "yarn workspace ghost run knex-migrator",
"lint": "yarn workspaces run lint",
"setup": "yarn && yarn workspace ghost run setup && git submodule update --init",
"test": "yarn workspaces run test",
"lint": "lerna run lint",
"test": "lerna run test",
"test:unit": "lerna run test:unit",
"main": "yarn main:monorepo && yarn main:submodules",
"main:monorepo": "git checkout main && git pull ${GHOST_UPSTREAM:-origin} main && yarn",
"main:submodules": "git submodule sync && git submodule update && git submodule foreach \"git checkout main && git pull ${GHOST_UPSTREAM:-origin} main && yarn\"",
@ -114,10 +115,16 @@
"lint-staged": {
"*.js": "eslint"
},
"lerna": {
"version": "0.0.0",
"npmClient": "yarn",
"useWorkspaces": true
},
"devDependencies": {
"concurrently": "7.6.0",
"eslint-plugin-ghost": "2.16.0",
"husky": "8.0.3",
"lerna": "6.5.1",
"lint-staged": "13.1.2"
}
}

1938
yarn.lock

File diff suppressed because it is too large Load diff