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

gitlab CI support #10

Merged
merged 17 commits into from
Nov 24, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
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
9 changes: 9 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
stages:
- test

test:
stage: test
image: node:8
script:
- npm i --silent
- npm test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

 

Supports travisCI and circleCI.
Supports travisCI, circleCI and gitlabCI.

 

Expand Down
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
let drone = require('./utils/drone')
let repo, sha, event, commit_message, branch, ci
// platform denotes code hosting provider i.e github, gitlab, bitbucket etc.
// Had to introduce this variable as there are cases when CI is run on the same platform where code is hosted as those cases need to be handled differently.
// Default value is github
let platform = 'github';
Copy link
Owner

Choose a reason for hiding this comment

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

that's a risky default


if (process.env.TRAVIS) {
// Reference: https://docs.travis-ci.com/user/environment-variables
Expand Down Expand Up @@ -50,6 +54,9 @@ if (process.env.TRAVIS) {
commit_message = '' // drone does not expose commit message
branch = process.env.DRONE_BRANCH || process.env.CI_BRANCH
ci = 'drone'
} else if (process.env.GITLAB_CI){
platform = 'gitlab'
ci = 'gitlab'
} else if (process.env.CI) {
// Generic variables for docker images, custom CI builds, etc.

Expand All @@ -63,4 +70,4 @@ if (process.env.TRAVIS) {
ci = 'custom'
}

module.exports = { repo, sha, event, commit_message, branch, ci }
module.exports = { repo, sha, event, commit_message, branch, ci, platform }
8 changes: 6 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const test = require('ava')

const { repo, sha, event, commit_message, branch, ci } = require('./index')
const { repo, sha, event, commit_message, branch, ci, platform } = require('./index')

if (ci) {
if (ci && platform === 'github') {
console.log('values: ', repo, sha, event, branch, ci)

test('ci is correctly set', t => {
Expand Down Expand Up @@ -50,6 +50,10 @@ if (ci) {
t.is(branch, real_branch)
}
})
} else if (ci && platform === 'gitlab') {
Copy link
Owner

Choose a reason for hiding this comment

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

would you not want to test any of the other things 🤔

test('ci is correctly set', t => {
t.is(ci, 'gitlab')
})
} else {
console.log('These tests can only run in CI environments')
test(t => t.pass())
Expand Down