Skip to content

release: v3.0.3 #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions __tests__/api-helper1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const createCommitResponse: GitCreateCommitResponseData = {
verified: true,
},
};
const escape = value => encodeURIComponent(value).replace(new RegExp('%2F', 'g'), '%252F');

describe('ApiHelper', () => {
disableNetConnect(nock);
Expand Down Expand Up @@ -213,7 +212,7 @@ describe('ApiHelper', () => {
const fn1 = jest.fn();
const fn2 = jest.fn();
nock('https://api.github.com')
.patch('/repos/hello/world/git/refs/' + escape('heads/test'), body => {
.patch(`/repos/hello/world/git/refs/${encodeURIComponent('heads/test')}`, body => {
fn1();
expect(body).toHaveProperty('sha');
return body;
Expand All @@ -223,7 +222,7 @@ describe('ApiHelper', () => {
return getApiFixture(rootDir, 'repos.git.refs.update');
});

await helper.updateRef(createCommitResponse, await helper.getRefForUpdate(true), false);
await helper.updateRef(createCommitResponse, await helper.getRefForUpdate(false), false);

expect(fn1).toBeCalledTimes(1);
expect(fn2).toBeCalledTimes(1);
Expand All @@ -234,7 +233,7 @@ describe('ApiHelper', () => {
const fn2 = jest.fn();
const fn3 = jest.fn();
nock('https://api.github.com')
.patch('/repos/hello/world/git/refs/' + escape('heads/new-topic'), body => {
.patch(`/repos/hello/world/git/refs/${encodeURIComponent('heads/new-topic')}`, body => {
fn1();
expect(body).toHaveProperty('sha');
return body;
Expand All @@ -253,7 +252,7 @@ describe('ApiHelper', () => {
ref: 'refs/pull/123/merge',
});
const helper = new ApiHelper(octokit, _context, logger);
await helper.updateRef(createCommitResponse, await helper.getRefForUpdate(true), false);
await helper.updateRef(createCommitResponse, await helper.getRefForUpdate(false), false);

expect(fn1).toBeCalledTimes(1);
expect(fn2).toBeCalledTimes(1);
Expand All @@ -263,7 +262,7 @@ describe('ApiHelper', () => {
it('should cache PR get api', async() => {
const fn = jest.fn();
nock('https://api.github.com')
.patch('/repos/hello/world/git/refs/' + escape('heads/new-topic'))
.patch(`/repos/hello/world/git/refs/${encodeURIComponent('heads/new-topic')}`)
.reply(200, () => {
return getApiFixture(rootDir, 'repos.git.refs.update');
})
Expand All @@ -279,22 +278,22 @@ describe('ApiHelper', () => {
const helper = new ApiHelper(octokit, _context, logger);
await helper.getRefForUpdate(true);
await helper.getRefForUpdate(true);
await helper.updateRef(createCommitResponse, await helper.getRefForUpdate(true), false);
await helper.updateRef(createCommitResponse, await helper.getRefForUpdate(false), false);

expect(fn).toBeCalledTimes(1);
});

it('should output warning', async() => {
nock('https://api.github.com')
.patch('/repos/hello/world/git/refs/' + escape('heads/test'), body => {
.patch(`/repos/hello/world/git/refs/${encodeURIComponent('heads/test')}`, body => {
expect(body).toHaveProperty('sha');
return body;
})
.reply(403, {
'message': 'Required status check "Test" is expected.',
});

await expect(helper.updateRef(createCommitResponse, await helper.getRefForUpdate(true), false)).rejects.toThrow('Required status check "Test" is expected.');
await expect(helper.updateRef(createCommitResponse, await helper.getRefForUpdate(false), false)).rejects.toThrow('Required status check "Test" is expected.');
});
});

Expand Down Expand Up @@ -579,7 +578,7 @@ describe('ApiHelper', () => {
.reply(201, () => getApiFixture(rootDir, 'repos.git.trees'))
.post('/repos/hello/world/git/commits')
.reply(201, () => getApiFixture(rootDir, 'repos.git.commits'))
.patch('/repos/hello/world/git/refs/' + escape('heads/test'))
.patch(`/repos/hello/world/git/refs/${encodeURIComponent('heads/test')}`)
.reply(200, () => getApiFixture(rootDir, 'repos.git.refs.update'));

expect(await helper.commit(rootDir, 'test commit message', ['build1.json', 'build2.json'])).toBe(true);
Expand All @@ -590,7 +589,7 @@ describe('ApiHelper', () => {
'::endgroup::',
'::group::Creating commit... [cd8274d15fa3ae2ab983129fb037999f264ba9a7]',
'::endgroup::',
'::group::Updating ref... [heads%252Ftest] [7638417db6d59f3c431d3e1f261cc637155684cd]',
'::group::Updating ref... [heads/test] [7638417db6d59f3c431d3e1f261cc637155684cd]',
'::set-env name=GITHUB_SHA::7638417db6d59f3c431d3e1f261cc637155684cd',
'::endgroup::',
]);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@technote-space/github-action-helper",
"version": "3.0.2",
"version": "3.0.3",
"description": "Helper to filter GitHub Action.",
"author": {
"name": "Technote",
Expand Down
2 changes: 1 addition & 1 deletion src/api-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ export default class ApiHelper {
}

const commit = await this.prepareCommit(rootDir, commitMessage, files);
const ref = await this.getRefForUpdate(true);
const ref = await this.getRefForUpdate(false);

this.callLogger(logger => logger.startProcess('Updating ref... [%s] [%s]', ref, commit.sha));
if (await this.updateRef(commit, ref, false)) {
Expand Down
13 changes: 3 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2545,11 +2545,9 @@ is-plain-object@^2.0.3, is-plain-object@^2.0.4:
isobject "^3.0.1"

is-plain-object@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-3.0.0.tgz#47bfc5da1b5d50d64110806c199359482e75a928"
integrity sha512-tZIpofR+P05k8Aocp7UI/2UTa9lTJSebCXpFFoR9aibpokDj/uXBsJ8luUu0tTVYKkMU6URDUuOfJZ7koewXvg==
dependencies:
isobject "^4.0.0"
version "3.0.1"
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-3.0.1.tgz#662d92d24c0aa4302407b0d45d21f2251c85f85b"
integrity sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g==

is-potential-custom-element-name@^1.0.0:
version "1.0.0"
Expand Down Expand Up @@ -2617,11 +2615,6 @@ isobject@^3.0.0, isobject@^3.0.1:
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=

isobject@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/isobject/-/isobject-4.0.0.tgz#3f1c9155e73b192022a80819bacd0343711697b0"
integrity sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA==

isstream@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
Expand Down