mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-10 22:16:28 +00:00
test: check git version (#11687)
Co-authored-by: Rhys Arkins <rhys@arkins.net> Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
parent
b9ae26b514
commit
1d528fc7a2
4 changed files with 34 additions and 1 deletions
1
.github/workflows/build-pr.yml
vendored
1
.github/workflows/build-pr.yml
vendored
|
@ -100,6 +100,7 @@ jobs:
|
|||
yarn eslint -f gha
|
||||
yarn prettier
|
||||
yarn markdown-lint
|
||||
yarn git-check
|
||||
|
||||
- name: Test schema
|
||||
run: yarn test-schema
|
||||
|
|
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
|
@ -134,6 +134,7 @@ jobs:
|
|||
yarn eslint -f gha
|
||||
yarn prettier
|
||||
yarn markdown-lint
|
||||
yarn git-check
|
||||
|
||||
- name: Test schema
|
||||
run: yarn test-schema
|
||||
|
|
|
@ -19,10 +19,11 @@
|
|||
"eslint-fix": "eslint --ext .js,.mjs,.ts --fix lib/ test/ tools/",
|
||||
"generate": "run-s generate:*",
|
||||
"generate:imports": "node tools/generate-imports.mjs",
|
||||
"git-check": "node tools/check-git-version.mjs",
|
||||
"jest": "cross-env NODE_ENV=test LOG_LEVEL=fatal node --expose-gc node_modules/jest/bin/jest.js --logHeapUsage",
|
||||
"jest-debug": "cross-env NODE_OPTIONS=--inspect-brk yarn jest",
|
||||
"jest-silent": "cross-env yarn jest --reporters jest-silent-reporter",
|
||||
"lint": "run-s ls-lint eslint prettier markdown-lint",
|
||||
"lint": "run-s ls-lint eslint prettier markdown-lint git-check",
|
||||
"lint-fix": "run-s eslint-fix prettier-fix markdown-lint-fix",
|
||||
"ls-lint": "ls-lint",
|
||||
"markdown-lint": "markdownlint-cli2",
|
||||
|
|
30
tools/check-git-version.mjs
Normal file
30
tools/check-git-version.mjs
Normal file
|
@ -0,0 +1,30 @@
|
|||
import semver from 'semver';
|
||||
import shell from 'shelljs';
|
||||
import simpleGit from 'simple-git';
|
||||
|
||||
const GIT_MINIMUM_VERSION = '2.33.0';
|
||||
const git = simpleGit();
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
(async () => {
|
||||
try {
|
||||
const regex = /\d+\.\d+\.\d+/;
|
||||
const stdout = await git.raw('--version');
|
||||
const [gitVersion] = regex.exec(stdout);
|
||||
if (semver.lt(gitVersion, GIT_MINIMUM_VERSION)) {
|
||||
if (process.env.CI) {
|
||||
shell.echo(
|
||||
`::error ::Minimum Git version ${GIT_MINIMUM_VERSION} is required`
|
||||
);
|
||||
} else {
|
||||
throw new Error(
|
||||
`Minimum Git version ${GIT_MINIMUM_VERSION} is required`
|
||||
);
|
||||
}
|
||||
}
|
||||
shell.echo('Found git version: ', gitVersion);
|
||||
process.exit(0);
|
||||
} catch (err) {
|
||||
shell.echo('ERROR:', err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
})();
|
Loading…
Reference in a new issue