Skip to content

Commit

Permalink
feat: extract and set the LayerCI env variables (#16233)
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov authored Apr 27, 2021
1 parent b00bb82 commit 29b803f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 7 deletions.
3 changes: 3 additions & 0 deletions packages/server/__snapshots__/cypress_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ The ciBuildId is automatically detected if you are running Cypress in any of the
- teamfoundation
- travis
- netlify
- layerci
Because the ciBuildId could not be auto-detected you must pass the --ci-build-id flag manually.
Expand Down Expand Up @@ -117,6 +118,7 @@ The ciBuildId is automatically detected if you are running Cypress in any of the
- teamfoundation
- travis
- netlify
- layerci
Because the ciBuildId could not be auto-detected you must pass the --ci-build-id flag manually.
Expand Down Expand Up @@ -155,6 +157,7 @@ The ciBuildId is automatically detected if you are running Cypress in any of the
- teamfoundation
- travis
- netlify
- layerci
Because the ciBuildId could not be auto-detected you must pass the --ci-build-id flag manually.
Expand Down
19 changes: 18 additions & 1 deletion packages/server/lib/util/ci_provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const CI_PROVIDERS = {
'travis': 'TRAVIS',
'wercker': isWercker,
netlify: 'NETLIFY',
layerci: 'LAYERCI',
}

const _detectProviderName = () => {
Expand All @@ -128,7 +129,7 @@ const _detectProviderName = () => {
})
}

// TODO: dont forget about buildNumber!
// TODO: don't forget about buildNumber!
// look at the old commit that was removed to see how we did it
const _providerCiParams = () => {
return {
Expand Down Expand Up @@ -387,6 +388,17 @@ const _providerCiParams = () => {
'DEPLOY_PRIME_URL',
'DEPLOY_ID',
]),
// https://layerci.com/docs/layerfile-reference/build-env
layerci: extract([
'LAYERCI_JOB_ID',
'LAYERCI_RUNNER_ID',
'RETRY_INDEX',
'LAYERCI_PULL_REQUEST',
'LAYERCI_REPO_NAME',
'LAYERCI_REPO_OWNER',
'LAYERCI_BRANCH',
'GIT_TAG', // short hex for commits
]),
}
}

Expand Down Expand Up @@ -571,6 +583,11 @@ const _providerCommitParams = () => {
branch: env.BRANCH,
remoteOrigin: env.REPOSITORY_URL,
},
layerci: {
sha: env.GIT_COMMIT,
branch: env.LAYERCI_BRANCH,
message: env.GIT_COMMIT_TITLE,
},
}
}

Expand Down
37 changes: 37 additions & 0 deletions packages/server/test/unit/ci_provider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,43 @@ describe('lib/util/ci_provider', () => {
})
})

it('layerci', () => {
resetEnv = mockedEnv({
LAYERCI: 'true',

LAYERCI_JOB_ID: 'jobId',
LAYERCI_RUNNER_ID: 'runnerId',
RETRY_INDEX: 'retryIndex',

// git info
LAYERCI_PULL_REQUEST: 'pullRequest',
LAYERCI_REPO_NAME: 'repoName',
LAYERCI_REPO_OWNER: 'repoOwner',
LAYERCI_BRANCH: 'branch',
GIT_TAG: 'tag',
GIT_COMMIT: 'commit',
GIT_COMMIT_TITLE: 'commitTitle',
}, { clear: true })

expectsName('layerci')
expectsCiParams({
layerciJobId: 'jobId',
layerciRunnerId: 'runnerId',
retryIndex: 'retryIndex',
gitTag: 'tag',
layerciBranch: 'branch',
layerciPullRequest: 'pullRequest',
layerciRepoName: 'repoName',
layerciRepoOwner: 'repoOwner',
})

return expectsCommitParams({
sha: 'commit',
branch: 'branch',
message: 'commitTitle',
})
})

it('azure', () => {
resetEnv = mockedEnv({
// these two variables tell us it is Azure CI
Expand Down
7 changes: 1 addition & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38973,12 +38973,7 @@ ws@^6.0.0, ws@^6.1.2, ws@^6.2.1:
dependencies:
async-limiter "~1.0.0"

ws@^7.2.0, ws@^7.2.3, ws@~7.4.2:
version "7.4.3"
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.3.tgz#1f9643de34a543b8edb124bdcbc457ae55a6e5cd"
integrity sha512-hr6vCR76GsossIRsr8OLR9acVVm1jyfEWvhbNjtgPOrfvAlKzvyeg/P6r8RuDjRyrcQoPQT7K0DGEPc7Ae6jzA==

ws@^7.4.1:
ws@^7.2.0, ws@^7.2.3, ws@^7.4.1, ws@~7.4.2:
version "7.4.4"
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.4.tgz#383bc9742cb202292c9077ceab6f6047b17f2d59"
integrity sha512-Qm8k8ojNQIMx7S+Zp8u/uHOx7Qazv3Yv4q68MiWWWOJhiwG5W3x7iqmRtJo8xxrciZUY4vRxUTJCKuRnF28ZZw==
Expand Down

4 comments on commit 29b803f

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 29b803f Apr 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.3.0/circle-develop-29b803f54b9a8b5c3b336d3e696d4795276a763e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 29b803f Apr 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.3.0/appveyor-develop-29b803f54b9a8b5c3b336d3e696d4795276a763e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 29b803f Apr 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.3.0/appveyor-develop-29b803f54b9a8b5c3b336d3e696d4795276a763e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 29b803f Apr 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.3.0/circle-develop-29b803f54b9a8b5c3b336d3e696d4795276a763e/cypress.tgz

Please sign in to comment.