fix: make v character in version tags optional (#423)
* fix: make v character in version tags optional * fix: cross platform regex * fix: test regex within grep. * fix: add semantic tags prepended with v
This commit is contained in:
@@ -2,6 +2,7 @@ import * as core from '@actions/core';
|
||||
import NotImplementedException from './error/not-implemented-exception';
|
||||
import System from './system';
|
||||
import Versioning from './versioning';
|
||||
import { validVersionTagInputs, invalidVersionTagInputs } from './__data__/versions';
|
||||
|
||||
afterEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
@@ -34,6 +35,26 @@ describe('Versioning', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('grepCompatibleInputVersionRegex', () => {
|
||||
// eslint-disable-next-line unicorn/consistent-function-scoping
|
||||
const matchInputUsingGrep = async (input) => {
|
||||
const output = await System.run('sh', undefined, {
|
||||
input: Buffer.from(`echo '${input}' | grep -E '${Versioning.grepCompatibleInputVersionRegex}'`),
|
||||
silent: true,
|
||||
});
|
||||
|
||||
return output.trim();
|
||||
};
|
||||
|
||||
it.concurrent.each(validVersionTagInputs)(`accepts valid tag input '%s'`, async (input) => {
|
||||
expect(await matchInputUsingGrep(input)).toStrictEqual(input);
|
||||
});
|
||||
|
||||
it.concurrent.each(invalidVersionTagInputs)(`rejects non-version tag input '%s'`, async (input) => {
|
||||
await expect(async () => matchInputUsingGrep(input)).rejects.toThrowError(/^Failed to run/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('branch', () => {
|
||||
it('returns headRef when set', () => {
|
||||
const headReference = jest.spyOn(Versioning, 'headRef', 'get').mockReturnValue('feature-branch-1');
|
||||
|
||||
Reference in New Issue
Block a user