Skip to content

Commit

Permalink
uppercase REPO_TOKEN (#489)
Browse files Browse the repository at this point in the history
* uppercase REPO_TOKEN

* document in one place

* Update snapshot tests

Co-authored-by: 0x2b3bfa0 <0x2b3bfa0+git@googlemail.com>
  • Loading branch information
casperdcl and 0x2b3bfa0 committed Apr 29, 2021
1 parent 79fbe80 commit 89d16b3
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion bin/cml-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const argv = yargs
.default('token')
.describe(
'token',
'Personal access token to be used. If not specified in extracted from ENV repo_token or GITLAB_TOKEN.'
'Personal access token to be used. If not specified, extracted from ENV REPO_TOKEN, GITLAB_TOKEN, GITHUB_TOKEN, or BITBUCKET_TOKEN.'
)
.default('driver')
.choices('driver', ['github', 'gitlab'])
Expand Down
5 changes: 3 additions & 2 deletions bin/cml-publish.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ describe('CML e2e', () => {
exist.
--repo Specifies the repo to be used. If not specified is extracted
from the CI ENV.
--token Personal access token to be used. If not specified in
extracted from ENV repo_token or GITLAB_TOKEN.
--token Personal access token to be used. If not specified,
extracted from ENV REPO_TOKEN, GITLAB_TOKEN, GITHUB_TOKEN,
or BITBUCKET_TOKEN.
--driver If not specify it infers it from the ENV.
[choices: \\"github\\", \\"gitlab\\"]
-h Show help [boolean]"
Expand Down
4 changes: 2 additions & 2 deletions bin/cml-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const {
RUNNER_REUSE = false,
RUNNER_DRIVER,
RUNNER_REPO,
repo_token
REPO_TOKEN
} = process.env;

let cml;
Expand Down Expand Up @@ -350,7 +350,7 @@ const opts = decamelize(
'repo',
'Repository to be used for registering the runner. If not specified, it will be inferred from the environment'
)
.default('token', repo_token)
.default('token', REPO_TOKEN)
.describe(
'token',
'Personal access token to register a self-hosted runner on the repository. If not specified, it will be inferred from the environment'
Expand Down
2 changes: 1 addition & 1 deletion bin/cml-send-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const argv = yargs
.default('token')
.describe(
'token',
'Personal access token to be used. If not specified in extracted from ENV repo_token.'
'Personal access token to be used. If not specified in extracted from ENV REPO_TOKEN.'
)
.default('driver')
.choices('driver', ['github', 'gitlab'])
Expand Down
2 changes: 1 addition & 1 deletion bin/cml-send-comment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('Comment integration tests', () => {
--repo Specifies the repo to be used. If not specified is extracted
from the CI ENV.
--token Personal access token to be used. If not specified in
extracted from ENV repo_token.
extracted from ENV REPO_TOKEN.
--driver If not specify it infers it from the ENV.
[choices: \\"github\\", \\"gitlab\\"]
-h Show help [boolean]"
Expand Down
2 changes: 1 addition & 1 deletion bin/cml-send-github-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const argv = yargs
.default('token')
.describe(
'token',
'Personal access token to be used. If not specified in extracted from ENV repo_token.'
'Personal access token to be used. If not specified in extracted from ENV REPO_TOKEN.'
)
.help('h')
.demand(1).argv;
Expand Down
2 changes: 1 addition & 1 deletion bin/cml-send-github-check.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('CML e2e', () => {
--repo Specifies the repo to be used. If not specified is extracted
from the CI ENV.
--token Personal access token to be used. If not specified in extracted
from ENV repo_token.
from ENV REPO_TOKEN.
-h Show help [boolean]
--conclusion[choices: \\"success\\", \\"failure\\", \\"neutral\\", \\"cancelled\\", \\"skipped\\",
\\"timed_out\\"] [default: Sets the conclusion status of the check.]"
Expand Down
7 changes: 5 additions & 2 deletions src/cml.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ const get_driver = (opts) => {

const infer_token = () => {
const {
REPO_TOKEN,
repo_token,
GITHUB_TOKEN,
GITLAB_TOKEN,
BITBUCKET_TOKEN
} = process.env;
return repo_token || GITHUB_TOKEN || GITLAB_TOKEN || BITBUCKET_TOKEN;
return (
REPO_TOKEN || repo_token || GITHUB_TOKEN || GITLAB_TOKEN || BITBUCKET_TOKEN
);
};

class CML {
Expand Down Expand Up @@ -231,7 +234,7 @@ class CML {
await this.runner_token();
} catch (err) {
throw new Error(
'repo_token does not have enough permissions to access workflow API'
'REPO_TOKEN does not have enough permissions to access workflow API'
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/cml.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Github tests', () => {
jest.resetModules();

process.env = {};
process.env.repo_token = TOKEN;
process.env.REPO_TOKEN = TOKEN;
});

afterAll(() => {
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('Gitlab tests', () => {
jest.resetModules();

process.env = {};
process.env.repo_token = TOKEN;
process.env.REPO_TOKEN = TOKEN;
});

afterAll(() => {
Expand Down

7 comments on commit 89d16b3

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Test Comment

CML watermark

Please sign in to comment.