From ea7e5ee6efcc124046f995451d8eedc5477cf8f8 Mon Sep 17 00:00:00 2001 From: Stefan Nagey Date: Wed, 3 Jun 2020 01:14:59 -0400 Subject: [PATCH 1/2] add amplify service definition --- index.js | 1 + services/amplify.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 services/amplify.js diff --git a/index.js b/index.js index f03bc451..bec2a116 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,7 @@ const process = require('process'); // eslint-disable-line node/prefer-global/pr const git = require('./services/git'); const services = { + amplify: require('./services/amplify'), appveyor: require('./services/appveyor'), bamboo: require('./services/bamboo'), bitbucket: require('./services/bitbucket'), diff --git a/services/amplify.js b/services/amplify.js new file mode 100644 index 00000000..bd650325 --- /dev/null +++ b/services/amplify.js @@ -0,0 +1,18 @@ +// https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html + +module.exports = { + detect({env}) { + return Boolean(env.AWS_APP_ID); + }, + configuration({env, cwd}) { + return { + name: 'AWS Amplify', + service: 'amplify', + commit: env.AWS_COMMIT_ID, + build: env.CODEBUILD_BUILD_ID, + branch: env.AWS_BRANCH, + buildUrl: env.CODEBUILD_BUILD_URL, + root: env.PWD, + }; + }, +}; From 64bba0be8dd80c19f16bbc0701a52970a6bde39c Mon Sep 17 00:00:00 2001 From: Stefan Nagey Date: Wed, 3 Jun 2020 10:01:13 -0400 Subject: [PATCH 2/2] add tests --- services/amplify.js | 2 +- test/index.test.js | 7 +++++++ test/services/amplify.test.js | 26 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 test/services/amplify.test.js diff --git a/services/amplify.js b/services/amplify.js index bd650325..97f46504 100644 --- a/services/amplify.js +++ b/services/amplify.js @@ -4,7 +4,7 @@ module.exports = { detect({env}) { return Boolean(env.AWS_APP_ID); }, - configuration({env, cwd}) { + configuration({env}) { return { name: 'AWS Amplify', service: 'amplify', diff --git a/test/index.test.js b/test/index.test.js index 5b0e6be9..7cc45d33 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -67,6 +67,13 @@ test('AWS CodeBuild', t => { t.is(service, 'codebuild'); }); +test('AWS Amplify', t => { + const {isCi, service} = m({env: {AWS_APP_ID: 'd44r7xst5a1wzk'}}); + + t.is(isCi, true); + t.is(service, 'amplify'); +}); + test('Codefresh', t => { const {isCi, service} = m({env: {CF_BUILD_ID: '91011'}}); diff --git a/test/services/amplify.test.js b/test/services/amplify.test.js new file mode 100644 index 00000000..efc174ad --- /dev/null +++ b/test/services/amplify.test.js @@ -0,0 +1,26 @@ +const test = require('ava'); +const amplify = require('../../services/amplify'); + +const env = { + AWS_APP_ID: 'd44r7xst5a1wzk', + AWS_COMMIT_ID: '9cb0bda49d77cd39682a7a17cfe204bd59ac375f', + CODEBUILD_BUILD_ID: 'env-ci:40cc72d2-acd5-46f4-a86b-6a3dcd2a39a0', + CODEBUILD_BUILD_URL: + 'https://console.aws.amazon.com/codebuild/home?region=us-east-1#/builds/env-ci:40cc72d2-acd5-46f4-a86b-6a3dcd2a39a0/view/new', + AWS_BRANCH: 'master', + AWS_REGION: 'us-east-1', + PWD: '/codebuild/output/src604025264/src/github.com/', +}; + +test('Push', t => { + t.deepEqual(amplify.configuration({env}), { + name: 'AWS Amplify', + service: 'amplify', + commit: '9cb0bda49d77cd39682a7a17cfe204bd59ac375f', + build: 'env-ci:40cc72d2-acd5-46f4-a86b-6a3dcd2a39a0', + branch: 'master', + buildUrl: + 'https://console.aws.amazon.com/codebuild/home?region=us-east-1#/builds/env-ci:40cc72d2-acd5-46f4-a86b-6a3dcd2a39a0/view/new', + root: '/codebuild/output/src604025264/src/github.com/', + }); +});