Skip to content

Commit

Permalink
fix: Link to events v2 url (#588)
Browse files Browse the repository at this point in the history
* Update events URL to use v2 version since v1 is deprecated
* Updated tests and documentation
  • Loading branch information
Fran-Rg authored Jul 29, 2024
1 parent bee9be6 commit 1a69dae
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 79 deletions.
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function updateEcsService(ecs, clusterName, service, taskDefArn, waitForSe
const region = await ecs.config.region();
const consoleHostname = region.startsWith('cn') ? 'console.amazonaws.cn' : 'console.aws.amazon.com';

core.info(`Deployment started. Watch this deployment's progress in the Amazon ECS console: https://${consoleHostname}/ecs/home?region=${region}#/clusters/${clusterName}/services/${service}/events`);
core.info(`Deployment started. Watch this deployment's progress in the Amazon ECS console: https://${region}.${consoleHostname}/ecs/v2/clusters/${clusterName}/services/${service}/events?region=${region}`);

// Wait for service stability
if (waitForService && waitForService.toLowerCase() === 'true') {
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function updateEcsService(ecs, clusterName, service, taskDefArn, waitForSe
const region = await ecs.config.region();
const consoleHostname = region.startsWith('cn') ? 'console.amazonaws.cn' : 'console.aws.amazon.com';

core.info(`Deployment started. Watch this deployment's progress in the Amazon ECS console: https://${consoleHostname}/ecs/home?region=${region}#/clusters/${clusterName}/services/${service}/events`);
core.info(`Deployment started. Watch this deployment's progress in the Amazon ECS console: https://${region}.${consoleHostname}/ecs/v2/clusters/${clusterName}/services/${service}/events?region=${region}`);

// Wait for service stability
if (waitForService && waitForService.toLowerCase() === 'true') {
Expand Down
152 changes: 76 additions & 76 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const mockEcsDescribeServices = jest.fn();
const mockCodeDeployCreateDeployment = jest.fn();
const mockCodeDeployGetDeploymentGroup = jest.fn();
const config = {
region: () => Promise.resolve('fake-region'),
region: () => Promise.resolve('fake-region'),
};

jest.mock('@aws-sdk/client-codedeploy');
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('Deploy to ECS', () => {
test('registers the task definition contents and updates the service', async () => {
await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
expect(mockEcsDescribeServices).toHaveBeenNthCalledWith(1, {
cluster: 'cluster-789',
Expand All @@ -134,7 +134,7 @@ describe('Deploy to ECS', () => {
forceNewDeployment: false
});
expect(waitUntilServicesStable).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");
expect(core.info).toBeCalledWith("Deployment started. Watch this deployment's progress in the Amazon ECS console: https://fake-region.console.aws.amazon.com/ecs/v2/clusters/cluster-789/services/service-456/events?region=fake-region");
});

test('registers the task definition contents and updates the service if deployment controller type is ECS', async () => {
Expand All @@ -152,7 +152,7 @@ describe('Deploy to ECS', () => {

await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
expect(mockEcsDescribeServices).toHaveBeenNthCalledWith(1, {
cluster: 'cluster-789',
Expand All @@ -165,15 +165,15 @@ describe('Deploy to ECS', () => {
forceNewDeployment: false
});
expect(waitUntilServicesStable).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");
expect(core.info).toBeCalledWith("Deployment started. Watch this deployment's progress in the Amazon ECS console: https://fake-region.console.aws.amazon.com/ecs/v2/clusters/cluster-789/services/service-456/events?region=fake-region");
});

test('prints Chinese console domain for cn regions', async () => {
const originalRegion = config.region;
config.region = () => Promise.resolve('cn-fake-region');
await run();

expect(core.info).toBeCalledWith("Deployment started. Watch this deployment's progress in the Amazon ECS console: https://console.amazonaws.cn/ecs/home?region=cn-fake-region#/clusters/cluster-789/services/service-456/events");
expect(core.info).toBeCalledWith("Deployment started. Watch this deployment's progress in the Amazon ECS console: https://cn-fake-region.console.amazonaws.cn/ecs/v2/clusters/cluster-789/services/service-456/events?region=cn-fake-region");

// reset
config.region = originalRegion;
Expand All @@ -190,7 +190,7 @@ describe('Deploy to ECS', () => {

await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
});

test('cleans empty arrays out of the task definition contents', async () => {
Expand All @@ -204,7 +204,7 @@ describe('Deploy to ECS', () => {

await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
});

test('cleans empty strings and objects out of the task definition contents', async () => {
Expand Down Expand Up @@ -269,7 +269,7 @@ describe('Deploy to ECS', () => {
}]
}
],
requiresCompatibilities: [ 'EC2' ]
requiresCompatibilities: ['EC2']
});
});

Expand Down Expand Up @@ -365,7 +365,7 @@ describe('Deploy to ECS', () => {
}]
}
],
requiresCompatibilities: [ 'EC2' ],
requiresCompatibilities: ['EC2'],
proxyConfiguration: {
type: "APPMESH",
containerName: "envoy",
Expand Down Expand Up @@ -418,7 +418,7 @@ describe('Deploy to ECS', () => {

await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
});

test('registers the task definition contents and creates a CodeDeploy deployment, waits for 30 minutes + deployment group wait time', async () => {
Expand All @@ -444,7 +444,7 @@ describe('Deploy to ECS', () => {
await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);

expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
expect(mockEcsDescribeServices).toHaveBeenNthCalledWith(1, {
cluster: 'cluster-789',
Expand All @@ -457,21 +457,21 @@ describe('Deploy to ECS', () => {
revision: {
revisionType: 'AppSpecContent',
appSpecContent: {
content: JSON.stringify({
Resources: [{
TargetService: {
Type: 'AWS::ECS::Service',
Properties: {
TaskDefinition: 'task:def:arn',
LoadBalancerInfo: {
ContainerName: "web",
ContainerPort: 80
content: JSON.stringify({
Resources: [{
TargetService: {
Type: 'AWS::ECS::Service',
Properties: {
TaskDefinition: 'task:def:arn',
LoadBalancerInfo: {
ContainerName: "web",
ContainerPort: 80
}
}
}
}
}]
}
}]
}),
sha256: '0911d1e99f48b492e238d1284d8ddb805382d33e1d1fc74ffadf37d8b7e6d096'
sha256: '0911d1e99f48b492e238d1284d8ddb805382d33e1d1fc74ffadf37d8b7e6d096'
}
}
});
Expand Down Expand Up @@ -522,7 +522,7 @@ describe('Deploy to ECS', () => {
await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);

expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
expect(mockEcsDescribeServices).toHaveBeenNthCalledWith(1, {
cluster: 'cluster-789',
Expand All @@ -535,21 +535,21 @@ describe('Deploy to ECS', () => {
revision: {
revisionType: 'AppSpecContent',
appSpecContent: {
content: JSON.stringify({
Resources: [{
TargetService: {
Type: 'AWS::ECS::Service',
Properties: {
TaskDefinition: 'task:def:arn',
LoadBalancerInfo: {
ContainerName: "web",
ContainerPort: 80
content: JSON.stringify({
Resources: [{
TargetService: {
Type: 'AWS::ECS::Service',
Properties: {
TaskDefinition: 'task:def:arn',
LoadBalancerInfo: {
ContainerName: "web",
ContainerPort: 80
}
}
}
}
}]
}
}]
}),
sha256: '0911d1e99f48b492e238d1284d8ddb805382d33e1d1fc74ffadf37d8b7e6d096'
sha256: '0911d1e99f48b492e238d1284d8ddb805382d33e1d1fc74ffadf37d8b7e6d096'
}
}
});
Expand Down Expand Up @@ -598,7 +598,7 @@ describe('Deploy to ECS', () => {
await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);

expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
expect(mockEcsDescribeServices).toHaveBeenNthCalledWith(1, {
cluster: 'cluster-789',
Expand All @@ -611,21 +611,21 @@ describe('Deploy to ECS', () => {
revision: {
revisionType: 'AppSpecContent',
appSpecContent: {
content: JSON.stringify({
Resources: [{
TargetService: {
Type: 'AWS::ECS::Service',
Properties: {
TaskDefinition: 'task:def:arn',
LoadBalancerInfo: {
ContainerName: "web",
ContainerPort: 80
content: JSON.stringify({
Resources: [{
TargetService: {
Type: 'AWS::ECS::Service',
Properties: {
TaskDefinition: 'task:def:arn',
LoadBalancerInfo: {
ContainerName: "web",
ContainerPort: 80
}
}
}
}
}]
}
}]
}),
sha256: '0911d1e99f48b492e238d1284d8ddb805382d33e1d1fc74ffadf37d8b7e6d096'
sha256: '0911d1e99f48b492e238d1284d8ddb805382d33e1d1fc74ffadf37d8b7e6d096'
}
}
});
Expand Down Expand Up @@ -726,7 +726,7 @@ describe('Deploy to ECS', () => {
await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);

expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
expect(mockEcsDescribeServices).toHaveBeenNthCalledWith(1, {
cluster: 'cluster-789',
Expand All @@ -739,21 +739,21 @@ describe('Deploy to ECS', () => {
revision: {
revisionType: 'AppSpecContent',
appSpecContent: {
content: JSON.stringify({
Resources: [{
TargetService: {
Type: 'AWS::ECS::Service',
Properties: {
TaskDefinition: 'task:def:arn',
LoadBalancerInfo: {
ContainerName: "web",
ContainerPort: 80
content: JSON.stringify({
Resources: [{
TargetService: {
Type: 'AWS::ECS::Service',
Properties: {
TaskDefinition: 'task:def:arn',
LoadBalancerInfo: {
ContainerName: "web",
ContainerPort: 80
}
}
}
}
}]
}
}]
}),
sha256: '0911d1e99f48b492e238d1284d8ddb805382d33e1d1fc74ffadf37d8b7e6d096'
sha256: '0911d1e99f48b492e238d1284d8ddb805382d33e1d1fc74ffadf37d8b7e6d096'
}
}
});
Expand Down Expand Up @@ -793,7 +793,7 @@ describe('Deploy to ECS', () => {
await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);

expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
expect(mockEcsDescribeServices).toHaveBeenNthCalledWith(1, {
cluster: 'cluster-789',
Expand Down Expand Up @@ -866,7 +866,7 @@ describe('Deploy to ECS', () => {
await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);

expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family-absolute-path'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family-absolute-path' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
});

Expand All @@ -882,7 +882,7 @@ describe('Deploy to ECS', () => {
await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);

expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
expect(mockEcsDescribeServices).toHaveBeenNthCalledWith(1, {
cluster: 'cluster-789',
Expand Down Expand Up @@ -921,7 +921,7 @@ describe('Deploy to ECS', () => {
await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);

expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
expect(mockEcsDescribeServices).toHaveBeenNthCalledWith(1, {
cluster: 'cluster-789',
Expand Down Expand Up @@ -960,7 +960,7 @@ describe('Deploy to ECS', () => {
await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);

expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
expect(mockEcsDescribeServices).toHaveBeenNthCalledWith(1, {
cluster: 'cluster-789',
Expand Down Expand Up @@ -1000,7 +1000,7 @@ describe('Deploy to ECS', () => {
await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);

expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
expect(mockEcsDescribeServices).toHaveBeenNthCalledWith(1, {
cluster: 'cluster-789',
Expand All @@ -1025,7 +1025,7 @@ describe('Deploy to ECS', () => {
await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);

expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
expect(mockEcsDescribeServices).toHaveBeenNthCalledWith(1, {
cluster: 'default',
Expand All @@ -1047,7 +1047,7 @@ describe('Deploy to ECS', () => {
await run();
expect(core.setFailed).toHaveBeenCalledTimes(0);

expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'});
expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family' });
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
expect(mockEcsDescribeServices).toHaveBeenCalledTimes(0);
expect(mockEcsUpdateService).toHaveBeenCalledTimes(0);
Expand Down Expand Up @@ -1132,4 +1132,4 @@ describe('Deploy to ECS', () => {
expect(core.setFailed).toHaveBeenNthCalledWith(1, 'Failed to register task definition in ECS: Could not parse');
expect(core.setFailed).toHaveBeenNthCalledWith(2, 'Could not parse');
});
});
});
Loading

0 comments on commit 1a69dae

Please sign in to comment.