From 0253e21cdc2b3ed96c31a7dada68a320a77ca843 Mon Sep 17 00:00:00 2001
From: Mike Penz
Date: Tue, 26 Jul 2022 14:37:20 +0200
Subject: [PATCH] - add note on local testing / debugging via Visual Code
---
README.md | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 60 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 2cfe6e0..1126993 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,7 @@
Sample ๐ฅ๏ธ •
Customization ๐๏ธ •
Contribute ๐งฌ •
+ Local Testing ๐งช •
License ๐
@@ -324,7 +325,6 @@ Table of supported placeholders allowed to be used in the `template` and `empty_
| `${{OPEN_COUNT}}` | The count of open PRs. Will only be fetched if `includeOpen` is configured. | |
| `${{IGNORED_COUNT}}` | The count of PRs and changes which were specifically ignored from the changelog. | |
-
### Configuration Specification
Table of descriptions for the `configuration.json` options to configure the resulting release notes / changelog.
@@ -387,6 +387,65 @@ It's suggested to export the token to your path before running the tests so that
export GITHUB_TOKEN=your_personal_github_pat
```
+## Local Testing ๐งช
+
+This GitHub action is fully developed in Typescript and can be run locally via npm. Doing so is a great way to test the action and/or your custom configurations locally, without the need to push and re-run GitHub actions over and over again.
+
+To run this action locally, first make sure you provide a `GITHUB_TOKEN` with enough permissions to access the repository.
+
+```
+# GitHub token for the action
+export GITHUB_TOKEN=your_read_only_github_token
+```
+
+Afterwards run the testcases with:
+
+```bash
+npm test -- custom.test.ts
+```
+
+custom.test.ts
+
+
+```typescript
+import {resolveConfiguration} from '../src/utils'
+import {ReleaseNotesBuilder} from '../src/releaseNotesBuilder'
+
+jest.setTimeout(180000)
+
+it('Test custom changelog builder', async () => {
+ const configuration = resolveConfiguration(
+ '',
+ 'configs_test/configuration_approvers.json'
+ )
+ const releaseNotesBuilder = new ReleaseNotesBuilder(
+ null, // baseUrl
+ null, // token
+ '.', // repoPath
+ 'mikepenz', // user
+ 'release-changelog-builder-action-playground', // repo
+ '1.5.0', // fromTag
+ '2.0.0', // toTag
+ true, // includeOpen
+ false, // failOnError
+ false, // ignorePrePrelease
+ true, // enable to fetch reviewers
+ false, // commitMode
+ configuration // configuration
+ )
+
+ const changeLog = await releaseNotesBuilder.build()
+ console.log(changeLog)
+ expect(changeLog).toStrictEqual(``)
+})
+```
+
+
+
+
+Additionally it is possible to do full debugging including the option of breakpoints via (for example) Visual Code.
+Open the project in Visual code -> open the terminal -> use the `+` and start a new `JavaScript Debug Terminal`. Afterwards run the tests as described above.
+
## Developed By
* Mike Penz