Skip to content
Permalink
Browse files
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>
  • Loading branch information
4 people committed Sep 15, 2021
1 parent b9ae26b commit 1d528fc7a24e4ac77f347b3ead7cd209a17f4738
Showing with 34 additions and 1 deletion.
  1. +1 −0 .github/workflows/build-pr.yml
  2. +1 −0 .github/workflows/build.yml
  3. +2 −1 package.json
  4. +30 −0 tools/check-git-version.mjs
@@ -100,6 +100,7 @@ jobs:
yarn eslint -f gha
yarn prettier
yarn markdown-lint
yarn git-check
- name: Test schema
run: yarn test-schema
@@ -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",
@@ -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);
}
})();

0 comments on commit 1d528fc

Please sign in to comment.