Example
@@ -169,15 +170,19 @@ jobs:
### Note
-> **Warning**: When running this action for non tags trigger the `toTag` will be automatically resolved using the latest tag as retrieved by the git API.
+> [!IMPORTANT]
+> When running this action for non tags trigger the `toTag` will be automatically resolved using the latest tag as retrieved by the git API.
-> **Note**: The first release tag is a special case since there is no previous release the action can reference to. For this case, there are 2 options:
+> [!NOTE]
+> The first release tag is a special case since there is no previous release the action can reference to. For this case, there are 2 options:
> 1. When checking out the source via `git` (E.g.: `actions/checkout`), the action will use the first commit.
> 2. Create a initial tag on the commit you want to begin a changelog from (for example `v0.0.1`).
-> **Note**: By default not specifying `fromTag` or `toTag` will resolve `toTag` from either the `ref` or alternatively fallback to the latest tag from the git API. `fromTag` is resolved by sorting tags using [semver](https://semver.org/). Check the [configuration](#configuration-specification) for alternatives.
+> [!NOTE]
+> By default not specifying `fromTag` or `toTag` will resolve `toTag` from either the `ref` or alternatively fallback to the latest tag from the git API. `fromTag` is resolved by sorting tags using [semver](https://semver.org/). Check the [configuration](#configuration-specification) for alternatives.
-> **Note**: If you are behind a corporate HTTP proxy, you can set the `https_proxy` environment variable to the proxy URL. For reference, please see the Octokit [documentation](https://github.com/octokit/octokit.js/#proxy-servers-nodejs-only).
+> [!NOTE]
+> If you are behind a corporate HTTP proxy, you can set the `https_proxy` environment variable to the proxy URL. For reference, please see the Octokit [documentation](https://github.com/octokit/octokit.js/#proxy-servers-nodejs-only).
### Configuration
@@ -192,11 +197,14 @@ The action supports flexible configuration options to modify vast areas of its b
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
-> **Note** Defaults for the configuration can be found in the [configuration.ts](https://github.com/mikepenz/release-changelog-builder-action/blob/develop/src/configuration.ts)
+> [!NOTE]
+> Defaults for the configuration can be found in the [configuration.ts](https://github.com/mikepenz/release-changelog-builder-action/blob/develop/src/configuration.ts)
-> **Warning** It is required to have a `checkout` step prior to the changelog step if `configuration` is used, to allow the action to discover the configuration file. Use `configurationJson` as alternative.
+> [!WARNING]
+> It is required to have a `checkout` step prior to the changelog step if `configuration` is used, to allow the action to discover the configuration file. Use `configurationJson` as alternative.
-> **Note** It is possible to provide the configuration as file and as json via the yml file. The order of config values used: `configurationJson` > `configuration` > `DefaultConfiguration`.
+> [!NOTE]
+> It is possible to provide the configuration as file and as json via the yml file. The order of config values used: `configurationJson` > `configuration` > `DefaultConfiguration`.
This configuration is a `JSON` in the following format. (The below showcases *example* configurations for all possible options. In most scenarios most of the settings will not be needed, and the defaults will be appropiate.)
@@ -293,7 +301,8 @@ This configuration is a `JSON` in the following format. (The below showcases *ex
Any section of the configuration can be omitted to have defaults apply.
-> **Warning**: `ignore_labels` take precedence over category labels, allowing to specifically exclude certain PRs.
+> [!WARNING]
+> `ignore_labels` take precedence over category labels, allowing to specifically exclude certain PRs.
Please see the [Configuration Specification](#configuration-specification) for detailed descriptions on the offered configuration options.
@@ -316,7 +325,8 @@ For advanced use cases additional settings can be provided to the action
token: ${{ secrets.PAT }}
```
-> **Note**: All input values are optional. It is only required to provide the `token` either via the input, or as `env` variable.
+> [!NOTE]
+> All input values are optional. It is only required to provide the `token` either via the input, or as `env` variable.
| **Input** | **Description** |
|---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
@@ -342,7 +352,8 @@ For advanced use cases additional settings can be provided to the action
| `exportOnly` | When enabled, will result in only exporting the cache, without genearting a changelog. Default: false (Requires `exportCache` to be enabled) |
| `cache` | The file path to write/read the cache to/from. |
-> **Warning**: `${{ secrets.GITHUB_TOKEN }}` only grants rights to the current repository, for other repositories please use a PAT (Personal Access Token).
+> [!WARNING]
+> `${{ secrets.GITHUB_TOKEN }}` only grants rights to the current repository, for other repositories please use a PAT (Personal Access Token).
### PR Template placeholders
@@ -365,7 +376,8 @@ Table of supported placeholders allowed to be used in the `pr_template` configur
| `#{{REVIEWERS}}` | GitHub Login names of specified reviewers, joined by `,`. Requires `fetchReviewers` to be enabled. |
| `#{{APPROVERS}}` | GitHub Login names of users who approved the PR, joined by `,`. |
-> **Note**: `v4` updates the default placeholders format to `#{{}}`. The old format `${{}}` will be supported until v5 for backwards compatiblity.
+> [!IMPORTANT]
+> `v4` updates the default placeholders format to `#{{}}`. The old format `${{}}` will be supported until v5 for backwards compatiblity.
Array Placeholders
@@ -406,7 +418,6 @@ Similar to `REVIEWS`, `REFERENCED` PRs also offer special placeholders.
-
### Template placeholders
Table of supported placeholders allowed to be used in the `template` and `empty_template` (only supports placeholder marked for empty) configuration, to give additional control on defining the contents of the release notes / changelog.
@@ -482,10 +493,10 @@ Table of descriptions for the `configuration.json` options to configure the resu
| tag_resolver.transformer | Defines a regex transformer used to optionally transform the tag after the filter was applied. Allows to adjust the format to e.g. semver. |
| base_branches | The target branches for the merged PR, ingnores PRs with different target branch. Values can be a `regex`. Default: allow all base branches |
| trim_values | Defines if all values inserted in templates are `trimmed`. Default: false |
+### Custom placeholders ๐งช
-## Experimental ๐งช
+Starting with v3.2.0 the action provides a feature of defining `CUSTOM_PLACEHOLDERS`.
-Starting with v3.2.0 the action provides an experimental feature of defining `CUSTOM_PLACEHOLDERS`.
Custom placeholders allow to extract values from any existing placeholder and insert them into the target template.
Example
@@ -530,6 +541,26 @@ Custom placeholders offer one new feature though. PR related placeholders can be
+### Gitea support ๐งช
+
+Starting with v4.1.0 the action is also compatible with [gitea](https://github.com/go-gitea/gitea).
+
+> [!WARNING]
+> The API from gitea does not allow to retrieve the `diff` via its API, requiring the repo to be checked out
+
+The API for gitea is equal to the one from GitHub, however it requires the `platform` to be specified.
+
+```yml
+- name: Build Changelog
+ uses: https://github.com/mikepenz/release-changelog-builder-action@v4.1.0
+ with:
+ platform: "gitea" # gitea or github, default is github
+ commitMode: true
+ configuration: "configuration.json"
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Do not change this
+```
+
## Contribute ๐งฌ
```bash
diff --git a/__tests__/gitea/releaseNotesBuilderGitea.test.ts b/__tests__/gitea/releaseNotesBuilderGitea.test.ts
new file mode 100644
index 00000000..12c7cc38
--- /dev/null
+++ b/__tests__/gitea/releaseNotesBuilderGitea.test.ts
@@ -0,0 +1,793 @@
+import {mergeConfiguration, resolveConfiguration} from '../../src/utils'
+import {ReleaseNotesBuilder} from '../../src/releaseNotesBuilder'
+import {GiteaRepository} from '../../src/repositories/GiteaRepository'
+
+jest.setTimeout(180000)
+
+/**
+ * Before starting testing, you should manually clone the repository
+ * cd /tmp && git clone https://gitea.com/mikepenz/sip
+ *
+ * (Forked from: https://gitea.com/jolheiser/sip)
+ */
+
+const token = process.env.GITEA_TOKEN || ''
+const workingDirectory = '/tmp/sip/'
+const owner = 'jolheiser'
+const repo = 'sip'
+const configurationFile = 'configs/configuration_gitea.json'
+
+it('[Gitea] Verify reviewers who approved are fetched and also release information', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_approvers.json'))
+
+ const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
+ const releaseNotesBuilder = new ReleaseNotesBuilder(
+ null, // baseUrl
+ giteaRepository, // token
+ workingDirectory, // repoPath
+ owner, // user
+ repo, // repo
+ 'v0.5.0', // fromTag
+ 'master', // toTag
+ true, // includeOpen
+ false, // failOnError
+ false, // ignorePrePrelease
+ false, // enable to fetch via commits
+ true, // enable to fetch reviewers
+ true, // enable to fetch tag release information
+ false, // enable to fetch reviews
+ false, // enable commitMode
+ false, // enable exportCache
+ false, // enable exportOnly
+ null, // path to the cache
+ configuration // configuration
+ )
+
+ const changeLog = await releaseNotesBuilder.build()
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(
+ `## ๐ฆ Uncategorized
+
+- Add attachment removal and change message -- (#36) [merged] ---
+- Change to vanity URL -- (#37) [merged] ---
+
+
+
+4`
+ )
+})
+
+it('[Gitea] Should match generated changelog (unspecified fromTag)', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
+
+ const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
+ const releaseNotesBuilder = new ReleaseNotesBuilder(
+ null,
+ giteaRepository,
+ workingDirectory,
+ owner,
+ repo,
+ null,
+ 'v0.1.1',
+ false,
+ false,
+ false,
+ true, // enable to fetch via commits
+ false, // enable to fetch reviewers
+ false, // enable to fetch tag release information
+ false, // enable to fetch reviews
+ false, // enable commitMode
+ false, // enable exportCache
+ false, // enable exportOnly
+ null, // path to the cache
+ configuration
+ )
+
+ const changeLog = await releaseNotesBuilder.build()
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(`## ๐งช Upgrade
+
+- Clean up and polish
+ - PR: #1
+
+`)
+})
+
+//
+it('[Gitea] Should match generated changelog (unspecified tags)', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
+
+ const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
+ const releaseNotesBuilder = new ReleaseNotesBuilder(
+ null,
+ giteaRepository,
+ workingDirectory,
+ owner,
+ repo,
+ null,
+ null,
+ false,
+ false,
+ false,
+ false, // enable to fetch via commits
+ false, // enable to fetch reviewers
+ false, // enable to fetch tag release information
+ false, // enable to fetch reviews
+ false, // enable commitMode
+ false, // enable exportCache
+ false, // enable exportOnly
+ null, // path to the cache
+ configuration
+ )
+
+ const changeLog = await releaseNotesBuilder.build()
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(`## ๐ Features
+
+- Add release attachments
+ - PR: #26
+
+`)
+})
+
+it('[Gitea] Should use empty placeholder', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
+
+ const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
+ const releaseNotesBuilder = new ReleaseNotesBuilder(
+ null,
+ giteaRepository,
+ workingDirectory,
+ owner,
+ repo,
+ 'v0.1.1',
+ 'v0.3.0',
+ false,
+ false,
+ false,
+ true, // enable to fetch via commits
+ false, // enable to fetch reviewers
+ false, // enable to fetch tag release information
+ false, // enable to fetch reviews
+ false, // enable commitMode
+ false, // enable exportCache
+ false, // enable exportOnly
+ null, // path to the cache
+ configuration
+ )
+
+ const changeLog = await releaseNotesBuilder.build()
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(`## ๐ Features
+
+- Add Drone and releases
+ - PR: #2
+- Add search filters
+ - PR: #8
+- Add qualifier module
+ - PR: #10
+- Add create repo command
+ - PR: #13
+- Add release support and CSV output
+ - PR: #16
+
+## ๐ Fixes
+
+- Fix PR head nil panic
+ - PR: #7
+- Fix Drone release
+ - PR: #14
+
+`)
+})
+
+it('[Gitea] Should fill empty placeholders', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json'))
+
+ const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
+ const releaseNotesBuilder = new ReleaseNotesBuilder(
+ null,
+ giteaRepository,
+ workingDirectory,
+ owner,
+ repo,
+ 'v0.1.0',
+ 'v0.4.0',
+ false,
+ false,
+ false,
+ true, // enable to fetch via commits
+ false, // enable to fetch reviewers
+ false, // enable to fetch tag release information
+ false, // enable to fetch reviews
+ false, // enable commitMode
+ false, // enable exportCache
+ false, // enable exportOnly
+ null, // path to the cache
+ configuration
+ )
+
+ const changeLog = await releaseNotesBuilder.build()
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(
+ `## ๐ Features
+
+- Add create repo command
+ - PR: #13
+- Add release support and CSV output
+ - PR: #16
+- Add open functionality
+ - PR: #21
+
+## ๐ฆ Uncategorized
+
+- Clean up and polish
+ - PR: #1
+- Add Drone and releases
+ - PR: #2
+- Update Beaver and fix bugs
+ - PR: #6
+- Fix PR head nil panic
+ - PR: #7
+- Add search filters
+ - PR: #8
+- Changelog 0.2.0
+ - PR: #9
+- Add qualifier module
+ - PR: #10
+- Fix Drone release
+ - PR: #14
+- Imp formatting
+ - PR: #17
+- Update Gitea SDK and other modules
+ - PR: #19
+- Update modules
+ - PR: #20
+- Add changelog for 0.3.0 and 0.4.0
+ - PR: #22
+
+
+- Clean up and polish
+ - PR: #1
+- Add Drone and releases
+ - PR: #2
+- Update Beaver and fix bugs
+ - PR: #6
+- Fix PR head nil panic
+ - PR: #7
+- Add search filters
+ - PR: #8
+- Changelog 0.2.0
+ - PR: #9
+- Add qualifier module
+ - PR: #10
+- Fix Drone release
+ - PR: #14
+- Imp formatting
+ - PR: #17
+- Update Gitea SDK and other modules
+ - PR: #19
+- Update modules
+ - PR: #20
+- Add changelog for 0.3.0 and 0.4.0
+ - PR: #22
+
+
+jolheiser
+sip
+v0.1.0
+v0.4.0
+https://gitea.com/jolheiser/sip/compare/v0.1.0...v0.4.0
+3
+12
+0
+36
+1322
+274
+0
+16`
+ )
+})
+
+it('[Gitea] Should fill `template` placeholders', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json'))
+
+ const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
+ const releaseNotesBuilder = new ReleaseNotesBuilder(
+ null,
+ giteaRepository,
+ workingDirectory,
+ owner,
+ repo,
+ 'v0.1.0',
+ 'v0.4.0',
+ false,
+ false,
+ false,
+ true, // enable to fetch via commits
+ false, // enable to fetch reviewers
+ false, // enable to fetch tag release information
+ false, // enable to fetch reviews
+ false, // enable commitMode
+ false, // enable exportCache
+ false, // enable exportOnly
+ null, // path to the cache
+ configuration
+ )
+
+ const changeLog = await releaseNotesBuilder.build()
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(
+ `## ๐ Features
+
+- Add create repo command
+ - PR: #13
+- Add release support and CSV output
+ - PR: #16
+- Add open functionality
+ - PR: #21
+
+## ๐ฆ Uncategorized
+
+- Clean up and polish
+ - PR: #1
+- Add Drone and releases
+ - PR: #2
+- Update Beaver and fix bugs
+ - PR: #6
+- Fix PR head nil panic
+ - PR: #7
+- Add search filters
+ - PR: #8
+- Changelog 0.2.0
+ - PR: #9
+- Add qualifier module
+ - PR: #10
+- Fix Drone release
+ - PR: #14
+- Imp formatting
+ - PR: #17
+- Update Gitea SDK and other modules
+ - PR: #19
+- Update modules
+ - PR: #20
+- Add changelog for 0.3.0 and 0.4.0
+ - PR: #22
+
+
+- Clean up and polish
+ - PR: #1
+- Add Drone and releases
+ - PR: #2
+- Update Beaver and fix bugs
+ - PR: #6
+- Fix PR head nil panic
+ - PR: #7
+- Add search filters
+ - PR: #8
+- Changelog 0.2.0
+ - PR: #9
+- Add qualifier module
+ - PR: #10
+- Fix Drone release
+ - PR: #14
+- Imp formatting
+ - PR: #17
+- Update Gitea SDK and other modules
+ - PR: #19
+- Update modules
+ - PR: #20
+- Add changelog for 0.3.0 and 0.4.0
+ - PR: #22
+
+
+jolheiser
+sip
+v0.1.0
+v0.4.0
+https://gitea.com/jolheiser/sip/compare/v0.1.0...v0.4.0
+3
+12
+0
+36
+1322
+274
+0
+16`
+ )
+})
+
+it('[Gitea] Should fill `template` placeholders, ignore', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json'))
+ configuration.categories.pop() // drop `uncategorized` category
+
+ const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
+ const releaseNotesBuilder = new ReleaseNotesBuilder(
+ null,
+ giteaRepository,
+ workingDirectory,
+ owner,
+ repo,
+ 'v0.3.0',
+ 'v0.5.0',
+ false,
+ false,
+ false,
+ false, // enable to fetch via commits
+ false, // enable to fetch reviewers
+ false, // enable to fetch tag release information
+ false, // enable to fetch reviews
+ false, // enable commitMode
+ false, // enable exportCache
+ false, // enable exportOnly
+ null, // path to the cache
+ configuration
+ )
+
+ const changeLog = await releaseNotesBuilder.build()
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(
+ `## ๐ Features
+
+- Add open functionality
+ - PR: #21
+
+
+- Update modules
+ - PR: #20
+- Add changelog for 0.3.0 and 0.4.0
+ - PR: #22
+- Update Gitea SDK
+ - PR: #23
+- Update repo info
+ - PR: #24
+- Add release attachments
+ - PR: #26
+- Refactor
+ - PR: #29
+
+
+jolheiser
+sip
+v0.3.0
+v0.5.0
+https://gitea.com/jolheiser/sip/compare/v0.3.0...v0.5.0
+1
+6
+0
+41
+748
+314
+0
+8`
+ )
+})
+
+it('[Gitea] Uncategorized category', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_uncategorized_category.json'))
+
+ const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
+ const releaseNotesBuilder = new ReleaseNotesBuilder(
+ null,
+ giteaRepository,
+ workingDirectory,
+ owner,
+ repo,
+ 'v0.3.0',
+ 'v0.5.0',
+ false,
+ false,
+ false,
+ false, // enable to fetch via commits
+ false, // enable to fetch reviewers
+ false, // enable to fetch tag release information
+ false, // enable to fetch reviews
+ false, // enable commitMode
+ false, // enable exportCache
+ false, // enable exportOnly
+ null, // path to the cache
+ configuration
+ )
+
+ const changeLog = await releaseNotesBuilder.build()
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(
+ `## ๐ Features
+
+- Add open functionality
+ - PR: #21
+
+## ๐ฆ Uncategorized
+
+- Update modules
+ - PR: #20
+- Add changelog for 0.3.0 and 0.4.0
+ - PR: #22
+- Update Gitea SDK
+ - PR: #23
+- Update repo info
+ - PR: #24
+- Add release attachments
+ - PR: #26
+- Refactor
+ - PR: #29
+
+
+
+Uncategorized:
+- Update modules
+ - PR: #20
+- Add changelog for 0.3.0 and 0.4.0
+ - PR: #22
+- Update Gitea SDK
+ - PR: #23
+- Update repo info
+ - PR: #24
+- Add release attachments
+ - PR: #26
+- Refactor
+ - PR: #29
+
+
+Ignored:
+
+
+6
+0`
+ )
+})
+
+it('[Gitea] Verify commit based changelog', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_commits.json'))
+
+ const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
+ const releaseNotesBuilder = new ReleaseNotesBuilder(
+ null,
+ giteaRepository,
+ workingDirectory,
+ owner,
+ repo,
+ 'v0.3.0',
+ 'v0.5.0',
+ false,
+ false,
+ false,
+ true, // enable to fetch via commits
+ false, // enable to fetch reviewers
+ false, // enable to fetch tag release information
+ false, // enable to fetch reviews
+ true, // enable commitMode
+ false, // enable exportCache
+ false, // enable exportOnly
+ null, // path to the cache
+ configuration
+ )
+
+ const changeLog = await releaseNotesBuilder.build()
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(
+ `## ๐ฆ Uncategorized
+
+- Update modules (#20)
+
+- Add open functionality (#21)
+
+- Add changelog for 0.3.0 and 0.4.0 (#22)
+
+- Update Gitea SDK (#23)
+
+- Update repo info (#24)
+
+- Add release attachments (#26)
+
+- Refactor (#29)
+
+- Changelog 0.5.0 (#30)
+
+
+
+
+Uncategorized:
+- Update modules (#20)
+
+- Add open functionality (#21)
+
+- Add changelog for 0.3.0 and 0.4.0 (#22)
+
+- Update Gitea SDK (#23)
+
+- Update repo info (#24)
+
+- Add release attachments (#26)
+
+- Refactor (#29)
+
+- Changelog 0.5.0 (#30)
+
+
+
+Ignored:
+
+
+8
+0`
+ )
+})
+
+it('[Gitea] Verify commit based changelog', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
+
+ const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
+ const releaseNotesBuilder = new ReleaseNotesBuilder(
+ null,
+ giteaRepository,
+ workingDirectory,
+ owner,
+ repo,
+ '3e49adf6047960a03f53346bbececb3ce7e0809b',
+ '894a641ef86c444dccfa55eca457186b5e10da95',
+ false,
+ false,
+ false,
+ false, // enable to fetch via commits
+ false, // enable to fetch reviewers
+ false, // enable to fetch tag release information
+ false, // enable to fetch reviews
+ true, // enable commitMode
+ false, // enable exportCache
+ false, // enable exportOnly
+ null, // path to the cache
+ configuration
+ )
+
+ const changeLog = await releaseNotesBuilder.build()
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(
+ `## ๐ Features
+
+- Add release attachments (#26)
+ - PR: #0
+
+`
+ )
+})
+// no open prs
+it('[Gitea] Verify default inclusion of open PRs', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_including_open.json'))
+
+ const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
+ const releaseNotesBuilder = new ReleaseNotesBuilder(
+ null, // baseUrl
+ giteaRepository, // token
+ workingDirectory, // repoPath
+ owner, // user
+ repo, // repo
+ 'v0.5.0', // fromTag
+ 'master', // toTag
+ true, // includeOpen
+ false, // failOnError
+ false, // ignorePrePrelease
+ false, // enable to fetch via commits
+ false, // enable to fetch reviewers
+ false, // enable to fetch tag release information
+ false, // enable to fetch reviews
+ false, // enable commitMode
+ false, // enable exportCache
+ false, // enable exportOnly
+ null, // path to the cache
+ configuration // configuration
+ )
+
+ const changeLog = await releaseNotesBuilder.build()
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(`
+
+
+Uncategorized
+- Add attachment removal and change message (#36) merged
+- Change to vanity URL (#37) merged
+
+
+
+Open
+`)
+})
+
+it('[Gitea] Verify custom categorisation of open PRs', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_excluding_open.json'))
+
+ const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
+ const releaseNotesBuilder = new ReleaseNotesBuilder(
+ null, // baseUrl
+ giteaRepository, // token
+ workingDirectory, // repoPath
+ owner, // user
+ repo, // repo
+ 'v0.5.0', // fromTag
+ 'master', // toTag
+ true, // includeOpen
+ false, // failOnError
+ false, // ignorePrePrelease
+ false, // enable to fetch via commits
+ false, // enable to fetch reviewers
+ false, // enable to fetch tag release information
+ false, // enable to fetch reviews
+ false, // enable commitMode
+ false, // enable exportCache
+ false, // enable exportOnly
+ null, // path to the cache
+ configuration // configuration
+ )
+
+ const changeLog = await releaseNotesBuilder.build()
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(``)
+})
+
+it('[Gitea] Fetch release information', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_approvers.json'))
+ configuration.template = '#{{FROM_TAG}}-#{{FROM_TAG_DATE}}\n#{{TO_TAG}}-#{{TO_TAG_DATE}}\n#{{DAYS_SINCE}}'
+
+ const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
+ const releaseNotesBuilder = new ReleaseNotesBuilder(
+ null, // baseUrl
+ giteaRepository, // token
+ workingDirectory, // repoPath
+ owner, // user
+ repo, // repo
+ 'v0.5.0', // fromTag
+ 'master', // toTag
+ true, // includeOpen
+ false, // failOnError
+ false, // ignorePrePrelease
+ false, // enable to fetch via commits
+ false, // enable to fetch reviewers
+ true, // enable to fetch tag release information
+ false, // enable to fetch reviews
+ false, // enable commitMode
+ false, // enable exportCache
+ false, // enable exportOnly
+ null, // path to the cache
+ configuration // configuration
+ )
+
+ const changeLog = await releaseNotesBuilder.build()
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(`v0.5.0-2020-09-17T16:34:40.000Z
+master-2020-09-21T19:30:21.000Z
+4`)
+})
+
+it('[Gitea] Fetch release information for non existing tag / release', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_approvers.json'))
+ configuration.template = '#{{FROM_TAG}}-#{{FROM_TAG_DATE}}\n#{{TO_TAG}}-#{{TO_TAG_DATE}}\n#{{DAYS_SINCE}}'
+
+ const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
+ const releaseNotesBuilder = new ReleaseNotesBuilder(
+ null, // baseUrl
+ giteaRepository, // token
+ workingDirectory, // repoPath
+ owner, // user
+ repo, // repo
+ 'v0.5.0', // fromTag
+ 'master', // toTag
+ true, // includeOpen
+ false, // failOnError
+ false, // ignorePrePrelease
+ false, // enable to fetch via commits
+ false, // enable to fetch reviewers
+ true, // enable to fetch tag release information
+ false, // enable to fetch reviews
+ false, // enable commitMode
+ false, // enable exportCache
+ false, // enable exportOnly
+ null, // path to the cache
+ configuration // configuration
+ )
+
+ const changeLog = await releaseNotesBuilder.build()
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(`v0.5.0-2020-09-17T16:34:40.000Z
+master-2020-09-21T19:30:21.000Z
+4`)
+})
diff --git a/__tests__/gitea/releaseNotesBuilderPullGitea.test.ts b/__tests__/gitea/releaseNotesBuilderPullGitea.test.ts
new file mode 100644
index 00000000..567558c9
--- /dev/null
+++ b/__tests__/gitea/releaseNotesBuilderPullGitea.test.ts
@@ -0,0 +1,349 @@
+import {checkExportedData, mergeConfiguration, resolveConfiguration} from '../../src/utils'
+import {buildChangelog} from '../../src/transform'
+import {pullData} from '../../src/pr-collector/prCollector'
+import {GiteaRepository} from '../../src/repositories/GiteaRepository'
+
+jest.setTimeout(180000)
+
+// load octokit instance
+const enablePullData = false
+/**
+ * if false -> use cache for data
+ * Use the below snippet to export the cache:
+ *
+ * writeCacheData({
+ * mergedPullRequests: data.mergedPullRequests,
+ * diffInfo: data.diffInfo,
+ * options
+ * }, 'caches/gitea_rcba_0.1.0-master_cache.json')
+ */
+
+/**
+ * Before starting testing, you should manually clone the repository
+ * cd /tmp && git clone https://gitea.com/mikepenz/sip
+ *
+ * (Forked from: https://gitea.com/jolheiser/sip)
+ */
+
+const token = process.env.GITEA_TOKEN || ''
+const workingDirectory = '/tmp/sip/'
+const owner = 'jolheiser'
+const repo = 'sip'
+const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
+const configurationFile = 'configs/configuration_gitea.json'
+it('[Gitea] Should have changelog (tags)', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
+
+ const options = {
+ owner: owner,
+ repo: repo,
+ fromTag: {name: 'v0.5.0'},
+ toTag: {name: 'master'},
+ includeOpen: false,
+ failOnError: false,
+ fetchViaCommits: true,
+ fetchReviewers: false,
+ fetchReleaseInformation: false,
+ fetchReviews: false,
+ commitMode: false,
+ configuration,
+ repositoryUtils: giteaRepository
+ }
+ let data: any
+ if (enablePullData) {
+ data = await pullData(giteaRepository, options)
+ } else {
+ data = checkExportedData(false, 'caches/gitea_rcba_0.5.0-master_cache.json')
+ }
+ const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(`## ๐ Features
+
+- Add attachment removal and change message
+ - PR: #36
+
+## ๐ Fixes
+
+- Fix drone-gitea-main
+ - PR: #38
+
+`)
+})
+
+it('[Gitea] Should match generated changelog (tags)', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
+ const options = {
+ owner: owner,
+ repo: repo,
+ fromTag: {name: 'v0.5.0'},
+ toTag: {name: 'master'},
+ includeOpen: false,
+ failOnError: false,
+ fetchViaCommits: true,
+ fetchReviewers: false,
+ fetchReleaseInformation: false,
+ fetchReviews: false,
+ commitMode: false,
+ configuration,
+ repositoryUtils: giteaRepository
+ }
+ let data: any
+ if (enablePullData) {
+ data = await pullData(giteaRepository, options)
+ } else {
+ data = checkExportedData(false, 'caches/gitea_rcba_0.5.0-master_cache.json')
+ }
+ const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(`## ๐ Features
+
+- Add attachment removal and change message
+ - PR: #36
+
+## ๐ Fixes
+
+- Fix drone-gitea-main
+ - PR: #38
+
+`)
+})
+
+it('[Gitea] Should match generated changelog (refs)', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_all_placeholders.json'))
+
+ const options = {
+ owner: owner,
+ repo: repo,
+ fromTag: {name: '3e49adf6047960a03f53346bbececb3ce7e0809b'},
+ toTag: {name: '894a641ef86c444dccfa55eca457186b5e10da95'},
+ includeOpen: false,
+ failOnError: false,
+ fetchViaCommits: true,
+ fetchReviewers: false,
+ fetchReleaseInformation: false,
+ fetchReviews: false,
+ commitMode: false,
+ configuration,
+ repositoryUtils: giteaRepository
+ }
+ let data: any
+ if (enablePullData) {
+ data = await pullData(giteaRepository, options)
+ } else {
+ data = checkExportedData(false, 'caches/gitea_rcba_3e49adf-894a64_cache.json')
+ }
+ const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(`## ๐ฆ Uncategorized
+
+Add release attachments
+26
+https://gitea.com/jolheiser/sip/pulls/26
+2020-09-16T18:07:32.000Z
+jolheiser
+enhancement
+0.5.0
+Resolves #25
+
+
+Refactor
+29
+https://gitea.com/jolheiser/sip/pulls/29
+2020-09-17T16:25:11.000Z
+jolheiser
+enhancement
+0.5.0
+Fixes #27
+
+Fixes #28
+
+This PR refactors and cleans up packages.
+
+It also scans CLI flags into variables for fewer footguns.
+
+
+
+`)
+})
+
+it('[Gitea] Should match generated changelog and replace all occurrences (refs)', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_replace_all_placeholders.json'))
+ const options = {
+ owner: owner,
+ repo: repo,
+ fromTag: {name: '3e49adf6047960a03f53346bbececb3ce7e0809b'},
+ toTag: {name: '894a641ef86c444dccfa55eca457186b5e10da95'},
+ includeOpen: false,
+ failOnError: false,
+ fetchViaCommits: true,
+ fetchReviewers: false,
+ fetchReleaseInformation: false,
+ fetchReviews: false,
+ commitMode: false,
+ configuration,
+ repositoryUtils: giteaRepository
+ }
+ let data: any
+ if (enablePullData) {
+ data = await pullData(giteaRepository, options)
+ } else {
+ data = checkExportedData(false, 'caches/gitea_rcba_3e49adf-894a64_cache.json')
+ }
+ const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(`## ๐ฆ Uncategorized
+
+Add release attachments
+Add release attachments
+26
+https://gitea.com/jolheiser/sip/pulls/26
+2020-09-16T18:07:32.000Z
+jolheiser
+jolheiser
+enhancement
+0.5.0
+Resolves #25
+
+
+Refactor
+Refactor
+29
+https://gitea.com/jolheiser/sip/pulls/29
+2020-09-17T16:25:11.000Z
+jolheiser
+jolheiser
+enhancement
+0.5.0
+Fixes #27
+
+Fixes #28
+
+This PR refactors and cleans up packages.
+
+It also scans CLI flags into variables for fewer footguns.
+
+
+
+`)
+})
+
+it('[Gitea] Should match ordered ASC', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
+ configuration.categories.pop() // drop `uncategorized` category
+ const options = {
+ owner: owner,
+ repo: repo,
+ fromTag: {name: 'v0.1.0'},
+ toTag: {name: 'master'},
+ includeOpen: false,
+ failOnError: false,
+ fetchViaCommits: false,
+ fetchReviewers: false,
+ fetchReleaseInformation: false,
+ fetchReviews: false,
+ commitMode: false,
+ configuration,
+ repositoryUtils: giteaRepository
+ }
+ let data: any
+ if (enablePullData) {
+ data = await pullData(giteaRepository, options)
+ } else {
+ data = checkExportedData(false, 'caches/gitea_rcba_0.1.0-master_cache.json')
+ }
+ const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(`## ๐ Features
+
+- Add Drone and releases
+ - PR: #2
+- Add search filters
+ - PR: #8
+- Add qualifier module
+ - PR: #10
+- Add create repo command
+ - PR: #13
+- Add release support and CSV output
+ - PR: #16
+- Add open functionality
+ - PR: #21
+- Add changelog for 0.3.0 and 0.4.0
+ - PR: #22
+- Add release attachments
+ - PR: #26
+- Add attachment removal and change message
+ - PR: #36
+
+## ๐ Fixes
+
+- Fix PR head nil panic
+ - PR: #7
+- Fix Drone release
+ - PR: #14
+
+`)
+})
+
+it('[Gitea] Should match ordered DESC', async () => {
+ const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_gitea_desc.json'))
+ configuration.categories.pop() // drop `uncategorized` category
+ const options = {
+ owner: owner,
+ repo: repo,
+ fromTag: {name: 'v0.1.0'},
+ toTag: {name: 'master'},
+ includeOpen: false,
+ failOnError: false,
+ fetchViaCommits: false,
+ fetchReviewers: false,
+ fetchReleaseInformation: false,
+ fetchReviews: false,
+ commitMode: false,
+ configuration,
+ repositoryUtils: giteaRepository
+ }
+ let data: any
+ if (enablePullData) {
+ data = await pullData(giteaRepository, options)
+ } else {
+ data = checkExportedData(false, 'caches/gitea_rcba_0.1.0-master_cache.json')
+ }
+ const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(`## ๐ Features
+
+- Add attachment removal and change message
+ - PR: #36
+- Add release attachments
+ - PR: #26
+- Add changelog for 0.3.0 and 0.4.0
+ - PR: #22
+- Add open functionality
+ - PR: #21
+- Add release support and CSV output
+ - PR: #16
+- Add create repo command
+ - PR: #13
+- Add qualifier module
+ - PR: #10
+- Add search filters
+ - PR: #8
+- Add Drone and releases
+ - PR: #2
+
+## ๐ Fixes
+
+- Fix Drone release
+ - PR: #14
+- Fix PR head nil panic
+ - PR: #7
+
+`)
+})
+
+/*
+ * I delete these test cases about gitea
+ * Should match ordered by title ASC
+ * Should match ordered by title DESC
+ * Should ignore PRs not merged into develop branch
+ */
diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts
index 9f3ce7f2..7604e11e 100644
--- a/__tests__/main.test.ts
+++ b/__tests__/main.test.ts
@@ -6,17 +6,19 @@ import * as fs from 'fs'
jest.setTimeout(180000)
test('missing values should result in failure', () => {
+ expect.assertions(1)
+
process.env['GITHUB_WORKSPACE'] = '.'
- process.env['INPUT_CONFIGURATION'] = 'configuration.json'
+ process.env['INPUT_OWNER'] = undefined
+ process.env['INPUT_CONFIGURATION'] = 'configs/configuration.json'
const ip = path.join(__dirname, '..', 'lib', 'main.js')
const options: cp.ExecSyncOptions = {
env: process.env
}
try {
cp.execSync(`node ${ip}`, options).toString()
- fail('Should not succeed, because values miss')
- } catch (error) {
- console.log(`correctly failed due to: ${error}`)
+ } catch (error: any) {
+ expect(true).toBe(true)
}
})
@@ -27,6 +29,7 @@ test('complete input should succeed', () => {
process.env['INPUT_REPO'] = 'release-changelog-builder-action'
process.env['INPUT_FROMTAG'] = 'v0.3.0'
process.env['INPUT_TOTAG'] = 'v0.5.0'
+ process.env['INPUT_CACHE'] = 'caches/rcba_0.3.0-0.5.0_cache.json'
const ip = path.join(__dirname, '..', 'lib', 'main.js')
const options: cp.ExecSyncOptions = {
@@ -45,6 +48,7 @@ test('should write result to file', () => {
process.env['INPUT_FROMTAG'] = 'v0.3.0'
process.env['INPUT_TOTAG'] = 'v0.5.0'
process.env['INPUT_OUTPUTFILE'] = 'test.md'
+ process.env['INPUT_CACHE'] = 'caches/rcba_0.3.0-0.5.0_cache.json'
const ip = path.join(__dirname, '..', 'lib', 'main.js')
const options: cp.ExecSyncOptions = {
diff --git a/__tests__/releaseNotesBuilder.test.ts b/__tests__/releaseNotesBuilder.test.ts
index d527c352..b3bd0d90 100644
--- a/__tests__/releaseNotesBuilder.test.ts
+++ b/__tests__/releaseNotesBuilder.test.ts
@@ -1,13 +1,16 @@
import {mergeConfiguration, resolveConfiguration} from '../src/utils'
import {ReleaseNotesBuilder} from '../src/releaseNotesBuilder'
+import {GithubRepository} from '../src/repositories/GithubRepository'
jest.setTimeout(180000)
-it('Should match generated changelog (unspecified fromTag)', async () => {
+const token = process.env.GITHUB_TOKEN || ''
+const githubRepository = new GithubRepository(token, undefined, '.')
+it('[Github] Should match generated changelog (unspecified fromTag)', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs/configuration.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
- null,
+ githubRepository,
'.',
'mikepenz',
'release-changelog-builder-action',
@@ -37,11 +40,11 @@ it('Should match generated changelog (unspecified fromTag)', async () => {
`)
})
-it('Should match generated changelog (unspecified tags)', async () => {
+it('[Github] Should match generated changelog (unspecified tags)', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs/configuration.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
- null,
+ githubRepository,
'.',
'mikepenz',
'action-junit-report-legacy',
@@ -66,11 +69,11 @@ it('Should match generated changelog (unspecified tags)', async () => {
expect(changeLog).toStrictEqual(`## ๐ Fixes\n\n- Stacktrace Data can be an array\n - PR: #39\n\n`)
})
-it('Should use empty placeholder', async () => {
+it('[Github] Should use empty placeholder', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs/configuration.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
- null,
+ githubRepository,
'.',
'mikepenz',
'release-changelog-builder-action',
@@ -95,11 +98,11 @@ it('Should use empty placeholder', async () => {
expect(changeLog).toStrictEqual(`- no changes`)
})
-it('Should fill empty placeholders', async () => {
+it('[Github] Should fill empty placeholders', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
- null,
+ githubRepository,
'.',
'mikepenz',
'release-changelog-builder-action',
@@ -126,11 +129,11 @@ it('Should fill empty placeholders', async () => {
)
})
-it('Should fill `template` placeholders', async () => {
+it('[Github] Should fill `template` placeholders', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
- null,
+ githubRepository,
'.',
'mikepenz',
'release-changelog-builder-action',
@@ -157,12 +160,12 @@ it('Should fill `template` placeholders', async () => {
)
})
-it('Should fill `template` placeholders, ignore', async () => {
+it('[Github] Should fill `template` placeholders, ignore', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json'))
configuration.categories.pop() // drop `uncategorized` category
const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
- null,
+ githubRepository,
'.',
'mikepenz',
'release-changelog-builder-action',
@@ -189,11 +192,11 @@ it('Should fill `template` placeholders, ignore', async () => {
)
})
-it('Uncategorized category', async () => {
+it('[Github] Uncategorized category', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_uncategorized_category.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
- null,
+ githubRepository,
'.',
'mikepenz',
'release-changelog-builder-action',
@@ -220,11 +223,11 @@ it('Uncategorized category', async () => {
)
})
-it('Verify commit based changelog', async () => {
+it('[Github] Verify commit based changelog', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_commits.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
- null,
+ githubRepository,
'.',
'mikepenz',
'release-changelog-builder-action',
@@ -251,11 +254,11 @@ it('Verify commit based changelog', async () => {
)
})
-it('Verify commit based changelog, with emoji categorisation', async () => {
+it('[Github] Verify commit based changelog, with emoji categorisation', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_commits_emoji.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder(
null,
- null,
+ githubRepository,
'.',
'theapache64',
'stackzy',
@@ -282,11 +285,11 @@ it('Verify commit based changelog, with emoji categorisation', async () => {
)
})
-it('Verify default inclusion of open PRs', async () => {
+it('[Github] Verify default inclusion of open PRs', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_including_open.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder(
null, // baseUrl
- null, // token
+ githubRepository, // token
'.', // repoPath
'mikepenz', // user
'release-changelog-builder-action-playground', // repo
@@ -313,11 +316,11 @@ it('Verify default inclusion of open PRs', async () => {
)
})
-it('Verify custom categorisation of open PRs', async () => {
+it('[Github] Verify custom categorisation of open PRs', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_excluding_open.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder(
null, // baseUrl
- null, // token
+ githubRepository, // token
'.', // repoPath
'mikepenz', // user
'release-changelog-builder-action-playground', // repo
@@ -344,11 +347,11 @@ it('Verify custom categorisation of open PRs', async () => {
)
})
-it('Verify reviewers who approved are fetched and also release information', async () => {
+it('[Github] Verify reviewers who approved are fetched and also release information', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_approvers.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder(
null, // baseUrl
- null, // token
+ githubRepository, // token
'.', // repoPath
'mikepenz', // user
'release-changelog-builder-action-playground', // repo
@@ -375,12 +378,12 @@ it('Verify reviewers who approved are fetched and also release information', asy
)
})
-it('Fetch release information', async () => {
+it('[Github] Fetch release information', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_approvers.json'))
configuration.template = '#{{FROM_TAG}}-#{{FROM_TAG_DATE}}\n#{{TO_TAG}}-#{{TO_TAG_DATE}}\n#{{DAYS_SINCE}}'
const releaseNotesBuilder = new ReleaseNotesBuilder(
null, // baseUrl
- null, // token
+ githubRepository, // token
'.', // repoPath
'mikepenz', // user
'release-changelog-builder-action-playground', // repo
@@ -405,12 +408,12 @@ it('Fetch release information', async () => {
expect(changeLog).toStrictEqual(`2.0.0-2022-04-08T07:52:40.000Z\n3.0.0-a01-2022-07-26T14:28:36.000Z\n109`)
})
-it('Fetch release information for non existing tag / release', async () => {
+it('[Github] Fetch release information for non existing tag / release', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_approvers.json'))
configuration.template = '#{{FROM_TAG}}-#{{FROM_TAG_DATE}}\n#{{TO_TAG}}-#{{TO_TAG_DATE}}\n#{{DAYS_SINCE}}'
const releaseNotesBuilder = new ReleaseNotesBuilder(
null, // baseUrl
- null, // token
+ githubRepository, // token
'.', // repoPath
'mikepenz', // user
'release-changelog-builder-action-playground', // repo
diff --git a/__tests__/releaseNotesBuilderPull.test.ts b/__tests__/releaseNotesBuilderPull.test.ts
index 44e263a4..06209872 100644
--- a/__tests__/releaseNotesBuilderPull.test.ts
+++ b/__tests__/releaseNotesBuilderPull.test.ts
@@ -1,17 +1,15 @@
import {checkExportedData, mergeConfiguration, resolveConfiguration} from '../src/utils'
-import {Octokit} from '@octokit/rest'
import {buildChangelog} from '../src/transform'
import {pullData} from '../src/pr-collector/prCollector'
-import {Data} from '../src/releaseNotesBuilder'
+import {GithubRepository} from '../src/repositories/GithubRepository'
jest.setTimeout(180000)
// load octokit instance
const enablePullData = false // if false -> use cache for data
-const octokit = new Octokit({
- auth: `token ${process.env.GITHUB_TOKEN}`
-})
+const token = process.env.GITHUB_TOKEN || ''
+const githubRepository = new GithubRepository(token, undefined, '.')
it('Should have empty changelog (tags)', async () => {
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs/configuration.json'))
@@ -27,11 +25,12 @@ it('Should have empty changelog (tags)', async () => {
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
- configuration
+ configuration,
+ repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
- data = await pullData(octokit, options)
+ data = await pullData(githubRepository, options)
} else {
data = checkExportedData(false, 'caches/rcba_0.0.2-0.0.3_cache.json')
}
@@ -54,11 +53,12 @@ it('Should match generated changelog (tags)', async () => {
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
- configuration
+ configuration,
+ repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
- data = await pullData(octokit, options)
+ data = await pullData(githubRepository, options)
} else {
data = checkExportedData(false, 'caches/rcba_0.0.1-0.0.3_cache.json')
}
@@ -87,11 +87,12 @@ it('Should match generated changelog (refs)', async () => {
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
- configuration
+ configuration,
+ repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
- data = await pullData(octokit, options)
+ data = await pullData(githubRepository, options)
} else {
data = checkExportedData(false, 'caches/rcba_5ec7a2-fa3788_cache.json')
}
@@ -127,11 +128,12 @@ it('Should match generated changelog and replace all occurrences (refs)', async
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
- configuration
+ configuration,
+ repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
- data = await pullData(octokit, options)
+ data = await pullData(githubRepository, options)
} else {
data = checkExportedData(false, 'caches/rcba_5ec7a2-fa3788_cache.json')
}
@@ -170,11 +172,12 @@ it('Should match ordered ASC', async () => {
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
- configuration
+ configuration,
+ repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
- data = await pullData(octokit, options)
+ data = await pullData(githubRepository, options)
} else {
data = checkExportedData(false, 'caches/rcba_0.3.0-0.5.0_cache.json')
}
@@ -198,11 +201,12 @@ it('Should match ordered DESC', async () => {
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
- configuration
+ configuration,
+ repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
- data = await pullData(octokit, options)
+ data = await pullData(githubRepository, options)
} else {
data = checkExportedData(false, 'caches/rcba_0.3.0-0.5.0_cache.json')
}
@@ -225,11 +229,12 @@ it('Should match ordered by title ASC', async () => {
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
- configuration
+ configuration,
+ repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
- data = await pullData(octokit, options)
+ data = await pullData(githubRepository, options)
} else {
data = checkExportedData(false, 'caches/rcba_0.3.0-0.5.0_cache.json')
}
@@ -254,11 +259,12 @@ it('Should match ordered by title DESC', async () => {
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
- configuration
+ configuration,
+ repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
- data = await pullData(octokit, options)
+ data = await pullData(githubRepository, options)
} else {
data = checkExportedData(false, 'caches/rcba_0.3.0-0.5.0_cache.json')
}
@@ -283,11 +289,12 @@ it('Should ignore PRs not merged into develop branch', async () => {
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
- configuration
+ configuration,
+ repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
- data = await pullData(octokit, options)
+ data = await pullData(githubRepository, options)
} else {
data = checkExportedData(false, 'caches/rcba_1.3.1-1.4.0_base_develop_cache.json')
}
@@ -310,11 +317,12 @@ it('Should ignore PRs not merged into main branch', async () => {
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
- configuration
+ configuration,
+ repositoryUtils: githubRepository
}
let data: any
if (enablePullData) {
- data = await pullData(octokit, options)
+ data = await pullData(githubRepository, options)
} else {
data = checkExportedData(false, 'caches/rcba_1.3.1-1.4.0_base_main_cache.json')
}
diff --git a/__tests__/tags.test.ts b/__tests__/tags.test.ts
index fbf7fa43..e38d7884 100644
--- a/__tests__/tags.test.ts
+++ b/__tests__/tags.test.ts
@@ -1,4 +1,4 @@
-import {TagInfo, filterTags, prepareAndSortTags} from '../src/pr-collector/tags'
+import {filterTags, prepareAndSortTags, TagInfo} from '../src/pr-collector/tags'
jest.setTimeout(180000)
diff --git a/__tests__/transform.test.ts b/__tests__/transform.test.ts
index 89ea392f..01bfcbcc 100644
--- a/__tests__/transform.test.ts
+++ b/__tests__/transform.test.ts
@@ -3,6 +3,7 @@ import moment from 'moment'
import {Configuration, DefaultConfiguration} from '../src/configuration'
import {PullRequestInfo} from '../src/pr-collector/pullRequests'
import {DefaultDiffInfo} from '../src/pr-collector/commits'
+import {GithubRepository} from '../src/repositories/GithubRepository'
jest.setTimeout(180000)
@@ -437,6 +438,7 @@ it('Use empty_content for empty category', async () => {
)
})
+const repositoryUtils = new GithubRepository(process.env.GITEA_TOKEN || '', undefined, '.')
it('Commit SHA-1 in commitMode', async () => {
const customConfig = Object.assign({}, DefaultConfiguration)
customConfig.sort = 'DESC'
@@ -453,7 +455,8 @@ it('Commit SHA-1 in commitMode', async () => {
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: true,
- configuration: customConfig
+ configuration: customConfig,
+ repositoryUtils: repositoryUtils
})
expect(resultChangelog).toStrictEqual(`## ๐ Features\n\nsha1-3\nsha1-1\n\n## ๐ Fixes\n\nsha1-3\nsha1-2\n\n`)
@@ -474,7 +477,8 @@ it('Release Diff', async () => {
fetchReleaseInformation: true,
fetchReviews: false,
commitMode: true,
- configuration: customConfig
+ configuration: customConfig,
+ repositoryUtils: repositoryUtils
})
expect(resultChangelog).toStrictEqual(`https://github.com/mikepenz/release-changelog-builder-action/compare/v2.8.0...v2.8.1\n`)
@@ -678,6 +682,7 @@ function buildChangelogTest(config: Configuration, prs: PullRequestInfo[]): stri
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
- configuration: config
+ configuration: config,
+ repositoryUtils: repositoryUtils
})
}
diff --git a/action.yml b/action.yml
index 9d81c70c..296f597a 100644
--- a/action.yml
+++ b/action.yml
@@ -58,6 +58,9 @@ inputs:
default: "false"
cache:
description: 'Provide the cache of a previous run. Allows to re-use collected information multiple times to generate different release notes. Requires `exportCache` to be enabled for the previous run.'
+ platform:
+ description: 'Defines the platform the action is run on. Available options: [`github`, `gitea`]. Defaults to `github`.'
+ default: "github"
outputs:
changelog:
description: The built release changelog built from the merged pull requests
diff --git a/caches/gitea_rcba_0.1.0-master_cache.json b/caches/gitea_rcba_0.1.0-master_cache.json
new file mode 100644
index 00000000..fe39091c
--- /dev/null
+++ b/caches/gitea_rcba_0.1.0-master_cache.json
@@ -0,0 +1,708 @@
+{
+ "mergedPullRequests": [
+ {
+ "number": 1,
+ "title": "Clean up and polish",
+ "htmlURL": "https://gitea.com/jolheiser/sip/pulls/1",
+ "baseBranch": "master",
+ "branch": "20df4b7f69f8dc609e98e3274739b49dc756884c",
+ "mergedAt": "2020-02-18T05:27:54.000Z",
+ "mergeCommitSha": "427ecdb7f1f4e289cb820ce2fbafe158b9b30012",
+ "author": "jolheiser",
+ "repoName": "jolheiser/sip",
+ "labels": [
+ "enhancement"
+ ],
+ "milestone": "0.1.1",
+ "body": "",
+ "approvedReviewers": [],
+ "createdAt": "2020-02-18T05:27:13.000Z",
+ "status": "merged"
+ },
+ {
+ "number": 2,
+ "title": "Add Drone and releases",
+ "htmlURL": "https://gitea.com/jolheiser/sip/pulls/2",
+ "baseBranch": "master",
+ "branch": "427ecdb7f1f4e289cb820ce2fbafe158b9b30012",
+ "mergedAt": "2020-02-18T15:51:14.000Z",
+ "mergeCommitSha": "5929bebe01e7b8c7c57b3c8fdfd41d4038bb85a1",
+ "author": "jolheiser",
+ "repoName": "jolheiser/sip",
+ "labels": [
+ "build"
+ ],
+ "milestone": "0.2.0",
+ "body": "",
+ "approvedReviewers": [],
+ "createdAt": "2020-02-18T15:41:58.000Z",
+ "status": "merged"
+ },
+ {
+ "number": 6,
+ "title": "Update Beaver and fix bugs",
+ "htmlURL": "https://gitea.com/jolheiser/sip/pulls/6",
+ "baseBranch": "master",
+ "branch": "5929bebe01e7b8c7c57b3c8fdfd41d4038bb85a1",
+ "mergedAt": "2020-02-27T02:53:14.000Z",
+ "mergeCommitSha": "bb773780df3488204df93228bdd72eb59418029b",
+ "author": "jolheiser",
+ "repoName": "jolheiser/sip",
+ "labels": [
+ "bug"
+ ],
+ "milestone": "0.2.0",
+ "body": "Fixes #3 \nFixes #4 \nFixes #5",
+ "approvedReviewers": [],
+ "createdAt": "2020-02-27T02:45:46.000Z",
+ "status": "merged"
+ },
+ {
+ "number": 7,
+ "title": "Fix PR head nil panic",
+ "htmlURL": "https://gitea.com/jolheiser/sip/pulls/7",
+ "baseBranch": "master",
+ "branch": "bb773780df3488204df93228bdd72eb59418029b",
+ "mergedAt": "2020-02-27T03:03:34.000Z",
+ "mergeCommitSha": "1956062791dae3e66c0c11d6fa86c59b031e51ee",
+ "author": "jolheiser",
+ "repoName": "jolheiser/sip",
+ "labels": [
+ "bug"
+ ],
+ "milestone": "0.2.0",
+ "body": "When checking PR status, retrieved PRs may have a nil head if the branch has been deleted.",
+ "approvedReviewers": [],
+ "createdAt": "2020-02-27T03:01:09.000Z",
+ "status": "merged"
+ },
+ {
+ "number": 8,
+ "title": "Add search filters",
+ "htmlURL": "https://gitea.com/jolheiser/sip/pulls/8",
+ "baseBranch": "master",
+ "branch": "1956062791dae3e66c0c11d6fa86c59b031e51ee",
+ "mergedAt": "2020-02-27T04:58:04.000Z",
+ "mergeCommitSha": "df58f223f25edd30ce8d15328d9d99fc9f98954b",
+ "author": "jolheiser",
+ "repoName": "jolheiser/sip",
+ "labels": [
+ "enhancement"
+ ],
+ "milestone": "0.2.0",
+ "body": "Adds search filters for state, author, labels, and milestone\n\nCheck the updated README for more details.",
+ "approvedReviewers": [],
+ "createdAt": "2020-02-27T04:39:37.000Z",
+ "status": "merged"
+ },
+ {
+ "number": 9,
+ "title": "Changelog 0.2.0",
+ "htmlURL": "https://gitea.com/jolheiser/sip/pulls/9",
+ "baseBranch": "master",
+ "branch": "df58f223f25edd30ce8d15328d9d99fc9f98954b",
+ "mergedAt": "2020-02-27T05:20:31.000Z",
+ "mergeCommitSha": "222dcf402b1cc0b57dbd4e2e9bc34196410c8a6b",
+ "author": "jolheiser",
+ "repoName": "jolheiser/sip",
+ "labels": [
+ "docs"
+ ],
+ "milestone": "0.2.0",
+ "body": "As title",
+ "approvedReviewers": [],
+ "createdAt": "2020-02-27T05:17:31.000Z",
+ "status": "merged"
+ },
+ {
+ "number": 10,
+ "title": "Add qualifier module",
+ "htmlURL": "https://gitea.com/jolheiser/sip/pulls/10",
+ "baseBranch": "master",
+ "branch": "222dcf402b1cc0b57dbd4e2e9bc34196410c8a6b",
+ "mergedAt": "2020-03-06T04:18:38.000Z",
+ "mergeCommitSha": "4490cc9888b4e39e14ce1c8fe9bdf64de348de71",
+ "author": "jolheiser",
+ "repoName": "jolheiser/sip",
+ "labels": [
+ "enhancement"
+ ],
+ "milestone": "0.2.1",
+ "body": "Better support for search query qualifiers",
+ "approvedReviewers": [],
+ "createdAt": "2020-02-28T03:33:43.000Z",
+ "status": "merged"
+ },
+ {
+ "number": 13,
+ "title": "Add create repo command",
+ "htmlURL": "https://gitea.com/jolheiser/sip/pulls/13",
+ "baseBranch": "master",
+ "branch": "4490cc9888b4e39e14ce1c8fe9bdf64de348de71",
+ "mergedAt": "2020-03-06T04:21:58.000Z",
+ "mergeCommitSha": "03fb319d3989c68a39c0652d8ff972e0957c5e6c",
+ "author": "jolheiser",
+ "repoName": "jolheiser/sip",
+ "labels": [
+ "feature"
+ ],
+ "milestone": "0.3.0",
+ "body": "Resolves #12",
+ "approvedReviewers": [],
+ "createdAt": "2020-03-06T04:17:46.000Z",
+ "status": "merged"
+ },
+ {
+ "number": 14,
+ "title": "Fix Drone release",
+ "htmlURL": "https://gitea.com/jolheiser/sip/pulls/14",
+ "baseBranch": "master",
+ "branch": "03fb319d3989c68a39c0652d8ff972e0957c5e6c",
+ "mergedAt": "2020-03-31T20:17:02.000Z",
+ "mergeCommitSha": "5ea204fb61cdb30501f8a6686b7132473f743b69",
+ "author": "jolheiser",
+ "repoName": "jolheiser/sip",
+ "labels": [
+ "build"
+ ],
+ "milestone": "0.2.1",
+ "body": "\r\nSigned-off-by: jolheiser