Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add more debugging, including link to the ECS or CodeDeploy console #56

Merged
merged 2 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async function updateEcsService(ecs, clusterName, service, taskDefArn, waitForSe
service: service,
taskDefinition: taskDefArn
}).promise();
core.info(`Deployment started. Watch this deployment's progress in the Amazon ECS console: https://console.aws.amazon.com/ecs/home?region=${aws.config.region}#/clusters/${clusterName}/services/${service}/events`);

// Wait for service stability
if (waitForService && waitForService.toLowerCase() === 'true') {
Expand Down Expand Up @@ -169,6 +170,7 @@ async function createCodeDeployDeployment(codedeploy, clusterName, service, task
}
}).promise();
core.setOutput('codedeploy-deployment-id', createDeployResponse.deploymentId);
core.info(`Deployment started. Watch this deployment's progress in the AWS CodeDeploy console: https://console.aws.amazon.com/codesuite/codedeploy/deployments/${createDeployResponse.deploymentId}?region=${aws.config.region}`);

// Wait for deployment to complete
if (waitForService && waitForService.toLowerCase() === 'true') {
Expand Down Expand Up @@ -220,7 +222,15 @@ async function run() {
path.join(process.env.GITHUB_WORKSPACE, taskDefinitionFile);
const fileContents = fs.readFileSync(taskDefPath, 'utf8');
const taskDefContents = removeIgnoredAttributes(cleanNullKeys(yaml.parse(fileContents)));
const registerResponse = await ecs.registerTaskDefinition(taskDefContents).promise();
let registerResponse;
try {
registerResponse = await ecs.registerTaskDefinition(taskDefContents).promise();
} catch (error) {
core.setFailed("Failed to register task definition in ECS: " + error.message);
clareliguori marked this conversation as resolved.
Show resolved Hide resolved
core.debug("Task definition contents:");
core.debug(JSON.stringify(taskDefContents, undefined, 4));
throw(error);
}
const taskDefArn = registerResponse.taskDefinition.taskDefinitionArn;
core.setOutput('task-definition-arn', taskDefArn);

Expand Down
6 changes: 6 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const mockCodeDeployGetDeploymentGroup = jest.fn();
const mockCodeDeployWaiter = jest.fn();
jest.mock('aws-sdk', () => {
return {
config: {
region: 'fake-region'
},
ECS: jest.fn(() => ({
registerTaskDefinition: mockEcsRegisterTaskDef,
updateService: mockEcsUpdateService,
Expand Down Expand Up @@ -158,6 +161,7 @@ describe('Deploy to ECS', () => {
taskDefinition: 'task:def:arn'
});
expect(mockEcsWaiter).toHaveBeenCalledTimes(0);
expect(core.info).toBeCalledWith("Deployment started. Watch this deployment's progress in the Amazon ECS console: https://console.aws.amazon.com/ecs/home?region=fake-region#/clusters/cluster-789/services/service-456/events");
});

test('cleans null keys out of the task definition contents', async () => {
Expand Down Expand Up @@ -299,6 +303,8 @@ describe('Deploy to ECS', () => {

expect(mockEcsUpdateService).toHaveBeenCalledTimes(0);
expect(mockEcsWaiter).toHaveBeenCalledTimes(0);

expect(core.info).toBeCalledWith("Deployment started. Watch this deployment's progress in the AWS CodeDeploy console: https://console.aws.amazon.com/codesuite/codedeploy/deployments/deployment-1?region=fake-region");
});

test('registers the task definition contents and creates a CodeDeploy deployment, waits for 1 hour + deployment group\'s wait time', async () => {
Expand Down