This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from ibrahim0814/ib/add-ga
Add Github Actions support
- Loading branch information
Showing
4 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module.exports = { | ||
detect: function() { | ||
return !!process.env.GITHUB_ACTIONS | ||
}, | ||
|
||
configuration: function() { | ||
// https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables | ||
console.log(' GitHub Actions CI Detected') | ||
|
||
var params = { | ||
branch: | ||
process.env.GITHUB_HEAD_REF || | ||
process.env.GITHUB_REF.replace('refs/heads/', ''), | ||
build: process.env.GITHUB_RUN_ID, | ||
commit: process.env.GITHUB_SHA, | ||
service: 'github-actions', | ||
slug: process.env.GITHUB_REPOSITORY, | ||
} | ||
|
||
if (process.env.GITHUB_HEAD_REF) { | ||
// PR refs are in the format: refs/pull/7/merge for pull_request events | ||
params['pr'] = process.env.GITHUB_REF.split('/')[2] | ||
} | ||
|
||
return params | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var github_actions = require('../../lib/services/github_actions') | ||
|
||
describe('GitHub Actions CI Provider', function() { | ||
it('can detect GitHub Actions', function() { | ||
process.env.GITHUB_ACTIONS = '1' | ||
expect(github_actions.detect()).toBe(true) | ||
}) | ||
|
||
it('can get GitHub Actions env info on push event', function() { | ||
delete process.env.GITHUB_HEAD_REF | ||
process.env.GITHUB_REF = 'refs/heads/master' | ||
process.env.GITHUB_REPOSITORY = 'codecov/codecov-repo' | ||
process.env.GITHUB_RUN_ID = '257701960' | ||
process.env.GITHUB_SHA = '743b04806ea677403aa2ff26c6bdeb85005de658' | ||
|
||
expect(github_actions.configuration()).toEqual({ | ||
branch: 'master', | ||
build: '257701960', | ||
commit: '743b04806ea677403aa2ff26c6bdeb85005de658', | ||
service: 'github-actions', | ||
slug: 'codecov/codecov-repo', | ||
}) | ||
}) | ||
|
||
it('can get GitHub Actions env info on pull request', function() { | ||
process.env.GITHUB_HEAD_REF = 'develop' | ||
process.env.GITHUB_REF = 'refs/pull/7/merge' | ||
process.env.GITHUB_REPOSITORY = 'codecov/codecov-repo' | ||
process.env.GITHUB_RUN_ID = '257701960' | ||
process.env.GITHUB_SHA = '743b04806ea677403aa2ff26c6bdeb85005de658' | ||
|
||
expect(github_actions.configuration()).toEqual({ | ||
branch: 'develop', | ||
build: '257701960', | ||
commit: '743b04806ea677403aa2ff26c6bdeb85005de658', | ||
pr: '7', | ||
service: 'github-actions', | ||
slug: 'codecov/codecov-repo', | ||
}) | ||
}) | ||
}) |