Skip to content

Commit

Permalink
Add support for gitHubEnterprise git provider (#29)
Browse files Browse the repository at this point in the history
* add support for gitHubEnterprise git provider

* npm run all + fix tests
  • Loading branch information
mohamad-arabi authored Nov 15, 2022
1 parent 45ef7ec commit e6748fd
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 12 deletions.
4 changes: 3 additions & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,14 @@ describe(`main's runner integration tests`, () => {
const dummyGitRepoName = 'dummyOwner/dummyRepo'
const dummyGitServerUrl = 'github.com'
const dummyGitCommit = 'sha1234'
const githubProvider = 'github'
const expectedRunName = 'My python-notebook run'
const dummyRunId = 123
const dummyTaskRunId = 456
const dummyRunUrl = 'databricks.com/url/to/job/run/'
const expectedGitSourceSpec = {
git_url: `${dummyGitServerUrl}/${dummyGitRepoName}`,
git_provider: 'github',
git_provider: githubProvider,
git_commit: dummyGitCommit
}
const expectedParamsSpec = {
Expand Down Expand Up @@ -307,6 +308,7 @@ describe(`main's runner integration tests`, () => {
process.env['INPUT_DATABRICKS-TOKEN'] = TOKEN
process.env['INPUT_LOCAL-NOTEBOOK-PATH'] = notebookPath
process.env['INPUT_GIT-COMMIT'] = dummyGitCommit
process.env['INPUT_GIT-PROVIDER'] = githubProvider

process.env['INPUT_DATABRICKS-HOST'] = DATABRICKS_HOST
process.env['INPUT_DATABRICKS-TOKEN'] = TOKEN
Expand Down
23 changes: 20 additions & 3 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,13 @@ describe(`input utils`, () => {
beforeEach(() => {
process.env['GITHUB_SERVER_URL'] = 'https://my-git.com'
process.env['GITHUB_REPOSITORY'] = 'dummyOwner/dummyRepo'
process.env['INPUT_GIT-PROVIDER'] = 'gitHub'
})
afterEach(() => {
delete process.env['INPUT_GIT-BRANCH']
delete process.env['INPUT_GIT-TAG']
delete process.env['INPUT_GIT-COMMIT']
delete process.env['INPUT_GIT-PROVIDER']
delete process.env['GITHUB_SERVER_URL']
delete process.env['GITHUB_REPOSITORY']
})
Expand All @@ -350,7 +352,7 @@ describe(`input utils`, () => {
git_source: {
git_tag: expectedTag,
git_url: 'https://my-git.com/dummyOwner/dummyRepo',
git_provider: 'github'
git_provider: 'gitHub'
}
})
})
Expand All @@ -362,7 +364,7 @@ describe(`input utils`, () => {
git_source: {
git_branch: expectedBranch,
git_url: 'https://my-git.com/dummyOwner/dummyRepo',
git_provider: 'github'
git_provider: 'gitHub'
}
})
})
Expand All @@ -374,7 +376,22 @@ describe(`input utils`, () => {
git_source: {
git_commit: expectedCommit,
git_url: 'https://my-git.com/dummyOwner/dummyRepo',
git_provider: 'github'
git_provider: 'gitHub'
}
})
})

test('git_provider is set in getGitSourceSpec correctly if non-default provider is passed as input', async () => {
var expectedCommit = 'my-commit'
var expectedProvider = 'gitHubEnterprise'
process.env['INPUT_GIT-COMMIT'] = expectedCommit
process.env['INPUT_GIT-PROVIDER'] = expectedProvider

expect(utils.getGitSourceSpec()).toEqual({
git_source: {
git_commit: expectedCommit,
git_url: 'https://my-git.com/dummyOwner/dummyRepo',
git_provider: expectedProvider
}
})
})
Expand Down
11 changes: 11 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@ inputs:
or REST API (https://docs.databricks.com/dev-tools/api/latest/workspace.html#export),
rather than an arbitrary Python/Scala/R file.
required: false
git-provider:
description: >
If specified, the notebook is run on Databricks within a temporary checkout of
the entire git repo using the specified git provider.
The local-notebook-path input as well as one of git-tag, git-commit, or git-branch must be specified when using this parameter,
and you must configure Git credentials (see https://docs.databricks.com/repos/index.html
#configure-your-git-integration-with-databricks).
The default value for this input is 'gitHub', but if the repository is hosted in Github enterprise
then one can specify 'gitHubEnterprise'.
required: false
default: 'gitHub'
outputs:
notebook-output:
description: >
Expand Down
5 changes: 3 additions & 2 deletions dist/main/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions dist/post/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/post/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-action",
"version": "0.0.0",
"version": "0.0.2",
"private": true,
"description": "TypeScript template action",
"main": "lib/main.js",
Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,12 @@ export const getGitSourceSpec = (): object => {
const gitBranch: string = core.getInput('git-branch')
const gitTag: string = core.getInput('git-tag')
const gitCommit: string = core.getInput('git-commit')
const gitProvider: string = core.getInput('git-provider')
const githubServerUrl: string = process.env['GITHUB_SERVER_URL'] || ''
const githubRepo: string = process.env['GITHUB_REPOSITORY'] || ''
const baseGitSourceSpec = {
git_url: `${githubServerUrl}/${githubRepo}`,
git_provider: 'github'
git_provider: gitProvider
}

if (!isGitRefSpecified()) {
Expand Down

0 comments on commit e6748fd

Please sign in to comment.