Skip to content

Commit

Permalink
Merge pull request #1132 from mikepenz/feature/pr_collector_as_lib
Browse files Browse the repository at this point in the history
Migrate GitHub PR Collector to npm lib
  • Loading branch information
mikepenz committed Jun 4, 2023
2 parents 4a9ea3c + 96a13c2 commit b691df6
Show file tree
Hide file tree
Showing 33 changed files with 28,883 additions and 13,116 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,26 @@ jobs:
with:
node-version: 16.x

- name: Install dependencies
run: npm ci
- name: Build PR-Collector
run: |
cd pr-collector
npm ci
npm run build
npm run package
- name: Rebuild the dist/ directory
- name: Build Action
run: |
cd pr-collector
npm ci
npm run build
npm run package
- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
git diff -a
exit 1
fi
id: diff
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@ jobs:

- name: Install NPM
run: |
cd pr-collector
npm install
cd ..
npm install
- name: Run NPM
run: |
cd pr-collector
npm run all
cd ..
npm run all
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -123,7 +131,6 @@ jobs:
fromTag: "v8.1.0"
toTag: "v8.1.6"
token: ${{ secrets.PERSONAL_TOKEN }}
exportCollected: true
exportOnly: true

- name: "External Repo Configuration"
Expand All @@ -133,6 +140,7 @@ jobs:
configuration: "configs/configuration_complex.json"
owner: "mikepenz"
repo: "MaterialDrawer"
cache: ${{ steps.external_changelog_collect.outputs.cache }}

- name: "External Repo Configuration Second"
id: external_changelog_second
Expand All @@ -151,6 +159,7 @@ jobs:
}
owner: "mikepenz"
repo: "MaterialDrawer"
cache: ${{ steps.external_changelog_collect.outputs.cache }}

- name: Echo External Repo Configuration Changelog
env:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,7 @@ Thumbs.db

# Ignore built ts files
__tests__/runner/*
lib/**/*
lib/**/*

lib
pr-collector/dist
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ A full set list of possible output values for this action.
| `outputs.changes` | Total count of changes in this release (lines). |
| `outputs.commits` | Count of commits which have been added in this release. |
| `outputs.categorized` | The categorized pull requests used to build the changelog as serialized JSON. |
| `outputs.cache` | The cache for the current fetched data. Can be provided to another action step. |

## Full Sample 🖥️

Expand Down Expand Up @@ -330,6 +331,7 @@ For advanced use cases additional settings can be provided to the action
| `fetchReleaseInformation` | Will enable fetching additional release information from tags. Default: false |
| `fetchReviews` | Will enable fetching the reviews on of the PR. Default: false |
| `commitMode` | Special configuration for projects which work without PRs. Uses commit messages as changelog. This mode looses access to information only available for PRs. Default: false |
| `cache` | Cached data from a previous run. Will skip fetching PR information |

> **Warning**: `${{ secrets.GITHUB_TOKEN }}` only grants rights to the current repository, for other repositories please use a PAT (Personal Access Token).
Expand Down
4 changes: 3 additions & 1 deletion __tests__/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ it('Configurations are merged correctly', async () => {
const mergedConfiguration = mergeConfiguration(configurationJson, configurationFile)

console.log(mergedConfiguration)
expect(JSON.stringify(mergedConfiguration)).toEqual(`{\"max_tags_to_fetch\":200,\"max_pull_requests\":1000,\"max_back_track_time_days\":1000,\"exclude_merge_branches\":[],\"sort\":\"DESC\",\"template\":\"$\{\{CHANGELOG}}\",\"pr_template\":\"- $\{\{TITLE}}\\n - PR: #$\{\{NUMBER}}\",\"empty_template\":\"- no magic changes\",\"categories\":[{\"title\":\"## 🚀 Features\",\"labels\":[\"feature\"]},{\"title\":\"## 🐛 Fixes\",\"labels\":[\"fix\"]},{\"title\":\"## 🧪 Tests\",\"labels\":[\"test\"]}],\"ignore_labels\":[\"ignore\"],\"label_extractor\":[],\"transformers\":[],\"tag_resolver\":{\"method\":\"semver\"},\"base_branches\":[],\"custom_placeholders\":[],\"trim_values\":true}`)
expect(JSON.stringify(mergedConfiguration)).toEqual(
`{\"max_tags_to_fetch\":200,\"max_pull_requests\":1000,\"max_back_track_time_days\":1000,\"exclude_merge_branches\":[],\"sort\":\"DESC\",\"template\":\"$\{\{CHANGELOG}}\",\"pr_template\":\"- $\{\{TITLE}}\\n - PR: #$\{\{NUMBER}}\",\"empty_template\":\"- no magic changes\",\"categories\":[{\"title\":\"## 🚀 Features\",\"labels\":[\"feature\"]},{\"title\":\"## 🐛 Fixes\",\"labels\":[\"fix\"]},{\"title\":\"## 🧪 Tests\",\"labels\":[\"test\"]}],\"ignore_labels\":[\"ignore\"],\"label_extractor\":[],\"transformers\":[],\"tag_resolver\":{\"method\":\"semver\"},\"base_branches\":[],\"custom_placeholders\":[],\"trim_values\":true}`
)
})
14 changes: 0 additions & 14 deletions __tests__/releaseNotesBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ it('Should match generated changelog (unspecified fromTag)', async () => {
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
false, // enable exportCollected
false, // enable exportOnly
configuration
)
Expand Down Expand Up @@ -52,7 +51,6 @@ it('Should match generated changelog (unspecified tags)', async () => {
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
false, // enable exportCollected
false, // enable exportOnly
configuration
)
Expand All @@ -79,7 +77,6 @@ it('Should use empty placeholder', async () => {
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
false, // enable exportCollected
false, // enable exportOnly
configuration
)
Expand All @@ -106,7 +103,6 @@ it('Should fill empty placeholders', async () => {
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
false, // enable exportCollected
false, // enable exportOnly
configuration
)
Expand Down Expand Up @@ -135,7 +131,6 @@ it('Should fill `template` placeholders', async () => {
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
false, // enable exportCollected
false, // enable exportOnly
configuration
)
Expand Down Expand Up @@ -164,7 +159,6 @@ it('Should fill `template` placeholders, ignore', async () => {
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
false, // enable exportCollected
false, // enable exportOnly
configuration
)
Expand Down Expand Up @@ -193,7 +187,6 @@ it('Uncategorized category', async () => {
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
false, // enable exportCollected
false, // enable exportOnly
configuration
)
Expand Down Expand Up @@ -222,7 +215,6 @@ it('Verify commit based changelog', async () => {
false, // enable to fetch tag release information
false, // enable to fetch reviews
true, // enable commitMode
false, // enable exportCollected
false, // enable exportOnly
configuration
)
Expand Down Expand Up @@ -251,7 +243,6 @@ it('Verify commit based changelog, with emoji categorisation', async () => {
false, // enable to fetch tag release information
false, // enable to fetch reviews
true, // enable commitMode
false, // enable exportCollected
false, // enable exportOnly
configuration
)
Expand Down Expand Up @@ -280,7 +271,6 @@ it('Verify default inclusion of open PRs', async () => {
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
false, // enable exportCollected
false, // enable exportOnly
configuration // configuration
)
Expand Down Expand Up @@ -309,7 +299,6 @@ it('Verify custom categorisation of open PRs', async () => {
false, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
false, // enable exportCollected
false, // enable exportOnly
configuration // configuration
)
Expand Down Expand Up @@ -338,7 +327,6 @@ it('Verify reviewers who approved are fetched and also release information', asy
true, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
false, // enable exportCollected
false, // enable exportOnly
configuration // configuration
)
Expand Down Expand Up @@ -368,7 +356,6 @@ it('Fetch release information', async () => {
true, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
false, // enable exportCollected
false, // enable exportOnly
configuration // configuration
)
Expand Down Expand Up @@ -396,7 +383,6 @@ it('Fetch release information for non existing tag / release', async () => {
true, // enable to fetch tag release information
false, // enable to fetch reviews
false, // enable commitMode
false, // enable exportCollected
false, // enable exportOnly
configuration // configuration
)
Expand Down

0 comments on commit b691df6

Please sign in to comment.