Skip to content

Commit

Permalink
Merge branch 'master' into 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg authored Jun 28, 2019
2 parents 719118e + b1bb74e commit ea305db
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/success.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = async (pluginConfig, context) => {
}
} catch (error) {
if (error.status === 404) {
logger.error("Failed to add a comment to the issue #%d as it doesn't exists.", issue.number);
logger.error("Failed to add a comment to the issue #%d as it doesn't exist.", issue.number);
} else {
errors.push(error);
logger.error('Failed to add a comment to the issue #%d.', issue.number);
Expand Down
9 changes: 9 additions & 0 deletions lib/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const VALIDATORS = {

module.exports = async (pluginConfig, context) => {
const {
env,
options: {repositoryUrl},
logger,
} = context;
Expand All @@ -52,6 +53,14 @@ module.exports = async (pluginConfig, context) => {
} else if (githubToken && !errors.find(({code}) => code === 'EINVALIDPROXY')) {
const github = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy});

// https://github.com/semantic-release/github/issues/182
// Do not check for permissions in GitHub actions, as the provided token is an installation access token.
// github.repos.get({repo, owner}) does not return the "permissions" key in that case. But GitHub Actions
// have all permissions required for @semantic-release/github to work
if (env.GITHUB_ACTION) {
return;
}

try {
const {
data: {
Expand Down
37 changes: 25 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"description": "semantic-release plugin to publish a GitHub release and comment on released Pull Requests/Issues",
"version": "0.0.0-development",
"author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
"ava": {
"helpers": [
"test/helpers/**/*"
]
},
"bugs": {
"url": "https://github.com/semantic-release/github/issues"
},
Expand All @@ -16,32 +21,32 @@
"Gregor Martynus (https://twitter.com/gr2m)"
],
"dependencies": {
"@octokit/rest": "^16.13.1",
"@octokit/rest": "^16.27.0",
"@semantic-release/error": "^2.2.0",
"aggregate-error": "^3.0.0",
"bottleneck": "^2.0.1",
"bottleneck": "^2.18.1",
"debug": "^4.0.0",
"dir-glob": "^2.0.0",
"fs-extra": "^7.0.0",
"dir-glob": "^3.0.0",
"fs-extra": "^8.0.0",
"globby": "^9.0.0",
"http-proxy-agent": "^2.1.0",
"https-proxy-agent": "^2.2.1",
"issue-parser": "^3.0.0",
"issue-parser": "^4.0.0",
"lodash": "^4.17.4",
"mime": "^2.0.3",
"mime": "^2.4.3",
"p-filter": "^2.0.0",
"p-retry": "^4.0.0",
"parse-github-url": "^1.0.1",
"url-join": "^4.0.0"
},
"devDependencies": {
"ava": "^1.0.1",
"ava": "^2.0.0",
"clear-module": "^3.0.0",
"codecov": "^3.0.0",
"codecov": "^3.5.0",
"commitizen": "^3.0.0",
"cz-conventional-changelog": "^2.0.0",
"nock": "^10.0.0",
"nyc": "^14.0.0",
"nyc": "^14.1.1",
"proxy": "^0.2.4",
"proxyquire": "^2.0.0",
"semantic-release": "^16.0.0-beta",
Expand Down Expand Up @@ -109,9 +114,17 @@
"prettier": true,
"space": true,
"rules": {
"camelcase": ["error", {
"allow": ["issue_number", "pull_number", "tag_name", "release_id"]
}]
"camelcase": [
"error",
{
"allow": [
"issue_number",
"pull_number",
"tag_name",
"release_id"
]
}
]
}
}
}
2 changes: 1 addition & 1 deletion test/get-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ test.serial('Use a http proxy', async t => {
t.is(proxyHandler.args[0][0].headers.accept, 'application/vnd.github.v3+json');
t.is(serverHandler.args[0][0].headers.accept, 'application/vnd.github.v3+json');
t.regex(serverHandler.args[0][0].headers.via, /proxy/);
t.truthy(serverHandler.args[0][0].headers['x-forwarded-for'], /proxy/);
t.truthy(serverHandler.args[0][0].headers['x-forwarded-for']);

await promisify(proxy.destroy).bind(proxy)();
await promisify(server.destroy).bind(server)();
Expand Down
2 changes: 1 addition & 1 deletion test/success.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ test.serial('Ignore missing issues/PRs', async t => {
t.true(t.context.log.calledWith('Added labels %O to issue #%d', ['released'], 1));
t.true(t.context.log.calledWith('Added comment to issue #%d: %s', 3, 'https://github.com/successcomment-3'));
t.true(t.context.log.calledWith('Added labels %O to issue #%d', ['released'], 3));
t.true(t.context.error.calledWith("Failed to add a comment to the issue #%d as it doesn't exists.", 2));
t.true(t.context.error.calledWith("Failed to add a comment to the issue #%d as it doesn't exist.", 2));
t.true(github.isDone());
});

Expand Down
20 changes: 20 additions & 0 deletions test/verify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,26 @@ test.serial('Verify "assignees" is a String', async t => {
t.true(github.isDone());
});

// https://github.com/semantic-release/github/issues/182
test.serial('Verify if run in GitHub Action', async t => {
const owner = 'test_user';
const repo = 'test_repo';
const env = {GITHUB_TOKEN: 'v1.1234567890123456789012345678901234567890', GITHUB_ACTION: 'Release'};
const proxy = 'https://localhost';
const assets = [{path: 'lib/file.js'}, 'file.js'];
const successComment = 'Test comment';
const failTitle = 'Test title';
const failComment = 'Test comment';
const labels = ['semantic-release'];

await t.notThrowsAsync(
verify(
{proxy, assets, successComment, failTitle, failComment, labels},
{env, options: {repositoryUrl: `git+https://othertesturl.com/${owner}/${repo}.git`}, logger: t.context.logger}
)
);
});

test('Throw SemanticReleaseError for missing github token', async t => {
const [error] = await t.throwsAsync(
verify(
Expand Down

0 comments on commit ea305db

Please sign in to comment.