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

Commit

Permalink
fix: add set -e to cicd pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
arantespp committed Jan 4, 2022
1 parent bb43741 commit 95ba9a7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
3 changes: 0 additions & 3 deletions packages/cli/src/deploy/cicd/cicd.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ export const getRepositoryImageBuilder = () => ({

// Used in case of yarn.lock is modified.
'RUN git checkout -- yarn.lock',

// set -e stops the execution of a script if a command or pipeline has an error.
'RUN set -e',
].join('\n'),
},
},
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/deploy/cicd/lambdas/ecsTaskReport.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export const getEcsTaskLogsUrl = ({ ecsTaskArn }: { ecsTaskArn: string }) => {
return ecsTaskLogsUrl.href;
};

/**
* - MainTagFound: means that the main has a tag, so the main pipeline should
* be skipped because the push was only to update versions and changelogs.
*/
export type Status = 'Approved' | 'Rejected' | 'MainTagFound';

export type Event = {
Expand Down
22 changes: 22 additions & 0 deletions packages/cli/src/deploy/cicd/pipelines.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,25 @@ test('pipelines', () => {
expect.arrayContaining(['pr', 'main', 'tag']),
);
});

test('set +x', () => {
const branch = 'some-branch';

const tag = 'some-tag';

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

expect(pipelinesModule.getMainCommands()).toMatchObject(
expect.arrayContaining(['set -e']),
);

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

expect(pipelinesModule.getClosedPrCommands({ branch })).not.toMatchObject(
expect.arrayContaining(['set -e']),
);
});
3 changes: 3 additions & 0 deletions packages/cli/src/deploy/cicd/pipelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const executeCommandFile = (pipeline: Pipeline | 'closed-pr') =>
`chmod +x ./cicd/commands/${pipeline} && ./cicd/commands/${pipeline}`;

export const getPrCommands = ({ branch }: { branch: string }) => [
'set -e',
'git status',
'git fetch',
/**
Expand Down Expand Up @@ -35,6 +36,7 @@ export const getClosedPrCommands = ({ branch }: { branch: string }) => [
];

export const getMainCommands = () => [
'set -e',
`export CARLIN_ENVIRONMENT=Staging`,
'git status',
'git fetch',
Expand All @@ -49,6 +51,7 @@ export const getMainCommands = () => [
];

export const getTagCommands = ({ tag }: { tag: string }) => [
'set -e',
`export CARLIN_ENVIRONMENT=Production`,
'git status',
'git fetch --tags',
Expand Down

0 comments on commit 95ba9a7

Please sign in to comment.