Skip to content
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
| `commit-sha` | Full SHA of the signed commit. |
| `tag` | Tag of the signed commit. |

## Release

This project follows [Conventional Commits](https://www.conventionalcommits.org/) and uses a manual release workflow.

1. Ensure `dist/` is up-to-date by running `npm run bundle`
2. Trigger the **Release** workflow via `workflow_dispatch` with the desired [semver](https://semver.org/) version
- The workflow bumps `package.json`, creates a signed commit, and tags `v{version}`
3. The **Changelog** workflow automatically regenerates `CHANGELOG.md` from conventional commits using [git-cliff](https://git-cliff.org/)

[ci_badge]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml/badge.svg
[ci_workflows]: https://github.com/ryancyq/github-signed-commit/actions/workflows/ci.yml
[coverage_badge]: https://codecov.io/gh/ryancyq/github-signed-commit/graph/badge.svg?token=KZTD2F2MN2
Expand Down
17 changes: 17 additions & 0 deletions __tests__/blob.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ describe('Blob', () => {
})
})

it('binary file successfully', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0xff, 0xfe, 0x00, 0x80,
0xc0, 0xc1, 0xf5, 0xf6,
])
const binaryPath = join(__dirname, 'fixtures', 'blob.bin')
fs.writeFileSync(binaryPath, binaryContent)

try {
const blob = getBlob('fixtures/blob.bin')
const fileAddition = await blob.load()
expect(fileAddition.contents).toEqual(binaryContent.toString('base64'))
} finally {
fs.unlinkSync(binaryPath)
}
})

it('stream with error', async () => {
const blob = getBlob('fixtures/error.txt')
const mockStream = new PassThrough()
Expand Down
36 changes: 0 additions & 36 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,42 +205,6 @@ describe('action', () => {
})
})

describe('input repository is given', () => {
describe('valid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user/the-repo'
return ''
})
})

it('succeed', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Neither files nor tag input has been configured'
)
})
})

describe('invalid format', () => {
beforeEach(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
if (name == 'repository') return 'the-user-the-repo'
return ''
})
})

it('fails', async () => {
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'Input <repository> "the-user-the-repo" is invalid'
)
})
})
})

describe('input branch is given', () => {
beforeEach(() => {
jest.spyOn(core, 'getMultilineInput').mockReturnValue(['/test.txt'])
Expand Down
14 changes: 14 additions & 0 deletions __tests__/stream/base64-encoder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,18 @@ describe('Base64 Encoder', () => {
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(Buffer.from(content).toString('base64'))
})

it('binary buffer stream', async () => {
const binaryContent = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0xff, 0xfe, 0x00, 0x80, 0xc0, 0xc1,
])
const stream = Readable.from(binaryContent).pipe(new Base64Encoder())

const chunks: Buffer[] = []
for await (const chunk of stream) {
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk))
}
const streamedContent = Buffer.concat(chunks).toString('utf8')
expect(streamedContent).toEqual(binaryContent.toString('base64'))
})
})
Loading
Loading