mirror of
https://github.com/softprops/action-gh-release.git
synced 2025-11-23 11:50:51 +00:00
Merge remote-tracking branch 'upstream/master' into feat/previus_tag
This commit is contained in:
commit
84a2a597c6
12 changed files with 980 additions and 913 deletions
|
|
@ -1,4 +1,11 @@
|
|||
import { asset, findTagFromReleases, mimeOrDefault, Release, Releaser } from '../src/github';
|
||||
import {
|
||||
asset,
|
||||
findTagFromReleases,
|
||||
mimeOrDefault,
|
||||
release,
|
||||
Release,
|
||||
Releaser,
|
||||
} from '../src/github';
|
||||
|
||||
import { assert, describe, it } from 'vitest';
|
||||
|
||||
|
|
@ -227,4 +234,75 @@ describe('github', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('error handling', () => {
|
||||
it('handles 422 already_exists error gracefully', async () => {
|
||||
const mockReleaser: Releaser = {
|
||||
getReleaseByTag: () => Promise.reject('Not implemented'),
|
||||
createRelease: () =>
|
||||
Promise.reject({
|
||||
status: 422,
|
||||
response: { data: { errors: [{ code: 'already_exists' }] } },
|
||||
}),
|
||||
updateRelease: () =>
|
||||
Promise.resolve({
|
||||
data: {
|
||||
id: 1,
|
||||
upload_url: 'test',
|
||||
html_url: 'test',
|
||||
tag_name: 'v1.0.0',
|
||||
name: 'test',
|
||||
body: 'test',
|
||||
target_commitish: 'main',
|
||||
draft: false,
|
||||
prerelease: false,
|
||||
assets: [],
|
||||
},
|
||||
}),
|
||||
allReleases: async function* () {
|
||||
yield {
|
||||
data: [
|
||||
{
|
||||
id: 1,
|
||||
upload_url: 'test',
|
||||
html_url: 'test',
|
||||
tag_name: 'v1.0.0',
|
||||
name: 'test',
|
||||
body: 'test',
|
||||
target_commitish: 'main',
|
||||
draft: false,
|
||||
prerelease: false,
|
||||
assets: [],
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
} as const;
|
||||
|
||||
const config = {
|
||||
github_token: 'test-token',
|
||||
github_ref: 'refs/tags/v1.0.0',
|
||||
github_repository: 'owner/repo',
|
||||
input_tag_name: undefined,
|
||||
input_name: undefined,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
input_files: [],
|
||||
input_draft: undefined,
|
||||
input_prerelease: undefined,
|
||||
input_preserve_order: undefined,
|
||||
input_overwrite_files: undefined,
|
||||
input_fail_on_unmatched_files: false,
|
||||
input_target_commitish: undefined,
|
||||
input_discussion_category_name: undefined,
|
||||
input_generate_release_notes: false,
|
||||
input_append_body: false,
|
||||
input_make_latest: undefined,
|
||||
};
|
||||
|
||||
const result = await release(config, mockReleaser, 1);
|
||||
assert.ok(result);
|
||||
assert.equal(result.id, 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -39,6 +39,18 @@ describe('util', () => {
|
|||
'loom',
|
||||
]);
|
||||
});
|
||||
it('handles globs with brace groups containing commas', () => {
|
||||
assert.deepStrictEqual(parseInputFiles('./**/*.{exe,deb,tar.gz}\nfoo,bar'), [
|
||||
'./**/*.{exe,deb,tar.gz}',
|
||||
'foo',
|
||||
'bar',
|
||||
]);
|
||||
});
|
||||
it('handles single-line brace pattern correctly', () => {
|
||||
assert.deepStrictEqual(parseInputFiles('./**/*.{exe,deb,tar.gz}'), [
|
||||
'./**/*.{exe,deb,tar.gz}',
|
||||
]);
|
||||
});
|
||||
});
|
||||
describe('releaseBody', () => {
|
||||
it('uses input body', () => {
|
||||
|
|
@ -113,6 +125,52 @@ describe('util', () => {
|
|||
}),
|
||||
);
|
||||
});
|
||||
it('falls back to body when body_path is missing', () => {
|
||||
assert.equal(
|
||||
releaseBody({
|
||||
github_ref: '',
|
||||
github_repository: '',
|
||||
github_token: '',
|
||||
input_body: 'fallback-body',
|
||||
input_body_path: '__tests__/does-not-exist.txt',
|
||||
input_draft: false,
|
||||
input_prerelease: false,
|
||||
input_files: [],
|
||||
input_overwrite_files: undefined,
|
||||
input_preserve_order: undefined,
|
||||
input_name: undefined,
|
||||
input_tag_name: undefined,
|
||||
input_target_commitish: undefined,
|
||||
input_discussion_category_name: undefined,
|
||||
input_generate_release_notes: false,
|
||||
input_make_latest: undefined,
|
||||
}),
|
||||
'fallback-body',
|
||||
);
|
||||
});
|
||||
it('returns undefined when body_path is missing and body is not provided', () => {
|
||||
assert.equal(
|
||||
releaseBody({
|
||||
github_ref: '',
|
||||
github_repository: '',
|
||||
github_token: '',
|
||||
input_body: undefined,
|
||||
input_body_path: '__tests__/does-not-exist.txt',
|
||||
input_draft: false,
|
||||
input_prerelease: false,
|
||||
input_files: [],
|
||||
input_overwrite_files: undefined,
|
||||
input_preserve_order: undefined,
|
||||
input_name: undefined,
|
||||
input_tag_name: undefined,
|
||||
input_target_commitish: undefined,
|
||||
input_discussion_category_name: undefined,
|
||||
input_generate_release_notes: false,
|
||||
input_make_latest: undefined,
|
||||
}),
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
});
|
||||
describe('parseConfig', () => {
|
||||
it('parses basic config', () => {
|
||||
|
|
@ -131,6 +189,7 @@ describe('util', () => {
|
|||
github_ref: '',
|
||||
github_repository: '',
|
||||
github_token: '',
|
||||
input_working_directory: undefined,
|
||||
input_append_body: false,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
|
|
@ -160,6 +219,7 @@ describe('util', () => {
|
|||
github_ref: '',
|
||||
github_repository: '',
|
||||
github_token: '',
|
||||
input_working_directory: undefined,
|
||||
input_append_body: false,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
|
|
@ -188,6 +248,7 @@ describe('util', () => {
|
|||
github_ref: '',
|
||||
github_repository: '',
|
||||
github_token: '',
|
||||
input_working_directory: undefined,
|
||||
input_append_body: false,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
|
|
@ -217,6 +278,7 @@ describe('util', () => {
|
|||
github_ref: '',
|
||||
github_repository: '',
|
||||
github_token: '',
|
||||
input_working_directory: undefined,
|
||||
input_append_body: false,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
|
|
@ -250,6 +312,7 @@ describe('util', () => {
|
|||
github_ref: '',
|
||||
github_repository: '',
|
||||
github_token: 'env-token',
|
||||
input_working_directory: undefined,
|
||||
input_append_body: false,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
|
|
@ -280,6 +343,7 @@ describe('util', () => {
|
|||
github_ref: '',
|
||||
github_repository: '',
|
||||
github_token: 'input-token',
|
||||
input_working_directory: undefined,
|
||||
input_append_body: false,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
|
|
@ -309,6 +373,7 @@ describe('util', () => {
|
|||
github_ref: '',
|
||||
github_repository: '',
|
||||
github_token: '',
|
||||
input_working_directory: undefined,
|
||||
input_append_body: false,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
|
|
@ -337,6 +402,7 @@ describe('util', () => {
|
|||
github_ref: '',
|
||||
github_repository: '',
|
||||
github_token: '',
|
||||
input_working_directory: undefined,
|
||||
input_append_body: false,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
|
|
@ -365,6 +431,7 @@ describe('util', () => {
|
|||
github_ref: '',
|
||||
github_repository: '',
|
||||
github_token: '',
|
||||
input_working_directory: undefined,
|
||||
input_append_body: true,
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
|
|
@ -400,6 +467,10 @@ describe('util', () => {
|
|||
'tests/data/foo/bar.txt',
|
||||
]);
|
||||
});
|
||||
|
||||
it('resolves files relative to working_directory', async () => {
|
||||
assert.deepStrictEqual(paths(['data/**/*'], 'tests'), ['tests/data/foo/bar.txt']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('unmatchedPatterns', () => {
|
||||
|
|
@ -409,6 +480,12 @@ describe('util', () => {
|
|||
['tests/data/does/not/exist/*'],
|
||||
);
|
||||
});
|
||||
|
||||
it('resolves unmatched relative to working_directory', async () => {
|
||||
assert.deepStrictEqual(unmatchedPatterns(['data/does/not/exist/*'], 'tests'), [
|
||||
'data/does/not/exist/*',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('replaceSpacesWithDots', () => {
|
||||
|
|
@ -425,3 +502,36 @@ describe('util', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseInputFiles edge cases', () => {
|
||||
it('handles multiple brace groups on same line', () => {
|
||||
assert.deepStrictEqual(parseInputFiles('./**/*.{exe,deb},./dist/**/*.{zip,tar.gz}'), [
|
||||
'./**/*.{exe,deb}',
|
||||
'./dist/**/*.{zip,tar.gz}',
|
||||
]);
|
||||
});
|
||||
|
||||
it('handles nested braces', () => {
|
||||
assert.deepStrictEqual(parseInputFiles('path/{a,{b,c}}/file.txt'), ['path/{a,{b,c}}/file.txt']);
|
||||
});
|
||||
|
||||
it('handles empty comma-separated values', () => {
|
||||
assert.deepStrictEqual(parseInputFiles('foo,,bar'), ['foo', 'bar']);
|
||||
});
|
||||
|
||||
it('handles commas with spaces around braces', () => {
|
||||
assert.deepStrictEqual(parseInputFiles(' ./**/*.{exe,deb} , file.txt '), [
|
||||
'./**/*.{exe,deb}',
|
||||
'file.txt',
|
||||
]);
|
||||
});
|
||||
|
||||
it('handles mixed newlines and commas with braces', () => {
|
||||
assert.deepStrictEqual(parseInputFiles('file1.txt\n./**/*.{exe,deb},file2.txt\nfile3.txt'), [
|
||||
'file1.txt',
|
||||
'./**/*.{exe,deb}',
|
||||
'file2.txt',
|
||||
'file3.txt',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue