Skip to content
This repository was archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
fix: pipelines commands
Browse files Browse the repository at this point in the history
  • Loading branch information
arantespp committed Jan 24, 2022
1 parent c87cf8c commit 1c01d40
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
21 changes: 18 additions & 3 deletions packages/cli/src/deploy/cicd/pipelines.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,33 @@ test('set +x', () => {
const tag = 'some-tag';

expect(pipelinesModule.getPrCommands({ branch })).toMatchObject(
expect.arrayContaining(['set -e']),
expect.arrayContaining([
'set -e',
`sh -e ${pipelinesModule.getCommandFileDir('pr')}`,
]),
);

expect(pipelinesModule.getMainCommands()).toMatchObject(
expect.arrayContaining(['set -e']),
expect.arrayContaining([
'set -e',
`sh -e ${pipelinesModule.getCommandFileDir('main')}`,
]),
);

expect(pipelinesModule.getTagCommands({ tag })).toMatchObject(
expect.arrayContaining(['set -e']),
expect.arrayContaining([
'set -e',
`sh -e ${pipelinesModule.getCommandFileDir('tag')}`,
]),
);

expect(pipelinesModule.getClosedPrCommands({ branch })).not.toMatchObject(
expect.arrayContaining(['set -e']),
);

expect(pipelinesModule.getClosedPrCommands({ branch })).toMatchObject(
expect.arrayContaining([
`sh ${pipelinesModule.getCommandFileDir('closed-pr')} || true`,
]),
);
});
12 changes: 6 additions & 6 deletions packages/cli/src/deploy/cicd/pipelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export type Pipelines = typeof pipelines;

export type Pipeline = Pipelines[number];

const executeCommandFile = (pipeline: Pipeline | 'closed-pr') =>
`chmod +x ./cicd/commands/${pipeline} && ./cicd/commands/${pipeline}`;
export const getCommandFileDir = (pipeline: Pipeline | 'closed-pr') =>
`./cicd/commands/${pipeline}`;

export const getPrCommands = ({ branch }: { branch: string }) => [
'set -e',
Expand All @@ -20,7 +20,7 @@ export const getPrCommands = ({ branch }: { branch: string }) => [
'git rev-parse HEAD',
'git status',
'yarn',
executeCommandFile('pr'),
`sh -e ${getCommandFileDir('pr')}`,
];

export const getClosedPrCommands = ({ branch }: { branch: string }) => [
Expand All @@ -32,7 +32,7 @@ export const getClosedPrCommands = ({ branch }: { branch: string }) => [
'git pull origin main',
'git rev-parse HEAD',
`export CARLIN_BRANCH=${branch}`,
executeCommandFile('closed-pr'),
`sh ${getCommandFileDir('closed-pr')} || true`,
];

export const getMainCommands = () => [
Expand All @@ -47,7 +47,7 @@ export const getMainCommands = () => [
*/
'if git describe --exact-match; then echo "Tag found" && carlin cicd-ecs-task-report --status=MainTagFound && exit 0; fi',
'yarn',
executeCommandFile('main'),
`sh -e ${getCommandFileDir('main')}`,
];

export const getTagCommands = ({ tag }: { tag: string }) => [
Expand All @@ -58,5 +58,5 @@ export const getTagCommands = ({ tag }: { tag: string }) => [
`git checkout tags/${tag} -b ${tag}-branch`,
'git rev-parse HEAD',
'yarn',
executeCommandFile('tag'),
`sh -e ${getCommandFileDir('tag')}`,
];

0 comments on commit 1c01d40

Please sign in to comment.