8000 Merge branch 'master' into merge-master-beta · coderbyheart/github@b1bb74e · GitHub
[go: up one dir, main page]

Skip to content

Commit b1bb74e

Browse files
committed
Merge branch 'master' into merge-master-beta
2 parents 719118e + 3a2da7a commit b1bb74e

File tree

6 files changed

+57
-15
lines changed

6 files changed

+57
-15
lines changed

lib/success.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ module.exports = async (pluginConfig, context) => {
9797
}
9898
} catch (error) {
9999
if (error.status === 404) {
100-
logger.error("Failed to add a comment to the issue #%d as it doesn't exists.", issue.number);
100+
logger.error("Failed to add a comment to the issue #%d as it doesn't exist.", issue.number);
101101
} else {
102102
errors.push(error);
103103
logger.error('Failed to add a comment to the issue #%d.', issue.number);

lib/verify.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const VALIDATORS = {
2727

2828
module.exports = async (pluginConfig, context) => {
2929
const {
30+
env,
3031
options: {repositoryUrl},
3132
logger,
3233
} = context;
@@ -52,6 +53,14 @@ module.exports = async (pluginConfig, context) => {
5253
} else if (githubToken && !errors.find(({code}) => code === 'EINVALIDPROXY')) {
5354
const github = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy});
5455

56+
// https://github.com/semantic-release/github/issues/182
57+
// Do not check for permissions in GitHub actions, as the provided token is an installation access token.
58+
// github.repos.get({repo, owner}) does not return the "permissions" key in that case. But GitHub Actions
59+
// have all permissions required for @semantic-release/github to work
60+
if (env.GITHUB_ACTION) {
61+
return;
62+
}
63+
5564
try {
5665
const {
5766
data: {

package.json

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
"description": "semantic-release plugin to publish a GitHub release and comment on released Pull Requests/Issues",
44
"version": "0.0.0-development",
55
"author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
6+
"ava": {
7+
"helpers": [
8+
"test/helpers/**/*"
9+
]
10+
},
611
"bugs": {
712
"url": "https://github.com/semantic-release/github/issues"
813
},
@@ -16,32 +21,32 @@
1621
"Gregor Martynus (https://twitter.com/gr2m)"
1722
],
1823
"dependencies": {
19-
"@octokit/rest": "^16.13.1",
24+
"@octokit/rest": "^16.27.0",
2025
"@semantic-release/error": "^2.2.0",
2126
"aggregate-error": "^3.0.0",
22-
"bottleneck": "^2.0 8000 .1",
27+
"bottleneck": "^2.18.1",
2328
"debug": "^4.0.0",
24-
"dir-glob": "^2.0.0",
25-
"fs-extra": "^7.0.0",
29+
"dir-glob": "^3.0.0",
30+
"fs-extra": "^8.0.0",
2631
"globby": "^9.0.0",
2732
"http-proxy-agent": "^2.1.0",
2833
"https-proxy-agent": "^2.2.1",
29-
"issue-parser": "^3.0.0",
34+
"issue-parser": "^4.0.0",
3035
"lodash": "^4.17.4",
31-
"mime": "^2.0.3",
36+
"mime": "^2.4.3",
3237
"p-filter": "^2.0.0",
3338
"p-retry": "^4.0.0",
3439
"parse-github-url": "^1.0.1",
3540
"url-join": "^4.0.0"
3641
},
3742
"devDependencies": {
38-
"ava": "^1.0.1",
43+
"ava": "^2.0.0",
3944
"clear-module": "^3.0.0",
40-
"codecov": "^3.0.0",
45+
"codecov": "^3.5.0",
4146
"commitizen": "^3.0.0",
4247
"cz-conventional-changelog": "^2.0.0",
4348
"nock": "^10.0.0",
44-
"nyc": "^14.0.0",
49+
"nyc": "^14.1.1",
4550
"proxy": "^0.2.4",
4651
"proxyquire": "^2.0.0",
4752
"semantic-release": "^16.0.0-beta",
@@ -109,9 +114,17 @@
109114
"prettier": true,
110115
"space": true,
111116
"rules": {
112-
"camelcase": ["error", {
113-
"allow": ["issue_number", "pull_number", "tag_name", "release_id"]
114-
}]
117+
"camelcase": [
118+
"error",
119+
{
120+
"allow": [
121+
"issue_number",
122+
"pull_number",
123+
"tag_name",
124+
"release_id"
125+
]
126+
}
127+
]
115128
}
116129
}
117130
}

test/get-client.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ test.serial('Use a http proxy', async t => {
4343
t.is(proxyHandler.args[0][0].headers.accept, 'application/vnd.github.v3+json');
4444
t.is(serverHandler.args[0][0].headers.accept, 'application/vnd.github.v3+json');
4545
t.regex(serverHandler.args[0][0].headers.via, /proxy/);
46-
t.truthy(serverHandler.args[0][0].headers['x-forwarded-for'], /proxy/);
46+
t.truthy(serverHandler.args[0][0].headers['x-forwarded-for']);
4747

4848
await promisify(proxy.destroy).bind(proxy)();
4949
await promisify(server.destroy).bind(server)();

test/success.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ test.serial('Ignore missing issues/PRs', async t => {
445445
t.true(t.context.log.calledWith('Added labels %O to issue #%d', ['released'], 1));
446446
t.true(t.context.log.calledWith('Added comment to issue #%d: %s', 3, 'https://github.com/successcomment-3'));
447447
t.true(t.context.log.calledWith('Added labels %O to issue #%d', ['released'], 3));
448-
t.true(t.context.error.calledWith("Failed to add a comment to the issue #%d as it doesn't exists.", 2));
448+
t.true(t.context.error.calledWith("Failed to add a comment to the issue #%d as it doesn't exist.", 2));
449449
t.true(github.isDone());
450450
});
451451

test/verify.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,26 @@ test.serial('Verify "assignees" is a String', async t => {
323323
t.true(github.isDone());
324324
});
325325

326+
// https://github.com/semantic-release/github/issues/182
327+
test.serial('Verify if run in GitHub Action', async t => {
328+
const owner = 'test_user';
329+
const repo = 'test_repo';
330+
const env = {GITHUB_TOKEN: 'v1.1234567890123456789012345678901234567890', GITHUB_ACTION: 'Release'};
331+
const proxy = 'https://localhost';
332+
const assets = [{path: 'lib/file.js'}, 'file.js'];
333+
const successComment = 'Test comment';
334+
const failTitle = 'Test title';
335+
const failComment = 'Test comment';
336+
const labels = ['semantic-release'];
337+
338+
await t.notThrowsAsync(
339+
verify(
340+
{proxy, assets, successComment, failTitle, failComment, labels},
341+
{env, options: {repositoryUrl: `git+https://othertesturl.com/${owner}/${repo}.git`}, logger: t.context.logger}
342+
)
343+
);
344+
});
345+
326346
test('Throw SemanticReleaseError for missing github token', async t => {
327347
const [error] = await t.throwsAsync(
328348
verify(

0 commit comments

Comments
 (0)
0