From 980337bb4348f7c6ab0fd0c0afbda9b6bf3a15bf Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Tue, 20 Jun 2023 18:26:47 -0400 Subject: [PATCH 1/3] fix(ci): yoshi-code-bot account in changelog generation --- .github/workflows/changelog_generation.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/changelog_generation.yaml b/.github/workflows/changelog_generation.yaml index 96025bf39d29..18751d952074 100644 --- a/.github/workflows/changelog_generation.yaml +++ b/.github/workflows/changelog_generation.yaml @@ -40,7 +40,7 @@ jobs: python3 .github/release-note-generation/split_release_note.py pr_body.txt . - name: Commit the change and push to the pull request branch run: | - git config user.email "yoshi-code-bot[bot]@users.noreply.github.com" + git config user.email "70984784+yoshi-code-bot@users.noreply.github.com" git config user.name "yoshi-code-bot" git remote set-url origin https://x-access-token:${{ secrets.YOSHI_CODE_BOT_TOKEN }}@github.com/${{ github.repository }} git add ./*/CHANGELOG.md From 9cd9909a0760dd666add51d4a99053ee64457e23 Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Tue, 20 Jun 2023 22:39:34 -0400 Subject: [PATCH 2/3] 'no change' if there's no change --- .../split_release_note.py | 6 ++++- .github/release-note-generation/unit_test.py | 26 ++++++++++++++++++- .github/workflows/changelog_generation.yaml | 2 +- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/.github/release-note-generation/split_release_note.py b/.github/release-note-generation/split_release_note.py index ac5c0a238614..6476c60f7bdf 100644 --- a/.github/release-note-generation/split_release_note.py +++ b/.github/release-note-generation/split_release_note.py @@ -94,10 +94,14 @@ def create_changelog_entry(current_date: str, module: LibraryModule, changelog_entry += '### Features\n\n' for line in changelog_lines: changelog_entry += f'* {line}\n' + changelog_entry += '\n' if dependency_changes: - changelog_entry += "\n### Dependencies\n\n" + changelog_entry += "### Dependencies\n\n" for line in dependency_changes: changelog_entry += f'* {line}\n' + + if len(changelog_lines) == 0 and len(dependency_changes) == 0: + changelog_entry += '* No change\n' return changelog_entry diff --git a/.github/release-note-generation/unit_test.py b/.github/release-note-generation/unit_test.py index 379041726041..f04fa8405e77 100644 --- a/.github/release-note-generation/unit_test.py +++ b/.github/release-note-generation/unit_test.py @@ -14,7 +14,6 @@ class TestCase(unittest.TestCase): def test_create_changelog_entry(self): - # do something entry = create_changelog_entry( '2023-06-10', dummy_module, @@ -34,6 +33,31 @@ def test_create_changelog_entry(self): * update google-cloud-shared-dependencies to 1.2.3 ''') + def test_create_changelog_entry_only_deps(self): + entry = create_changelog_entry( + '2023-06-10', + dummy_module, + [], + ['update google-cloud-shared-dependencies to 1.2.3'] + ) + self.assertEqual(entry, f'''## 1.2.3 (2023-06-10) + +### Dependencies + +* update google-cloud-shared-dependencies to 1.2.3 +''') + + def test_create_changelog_entry_empty(self): + entry = create_changelog_entry( + '2023-06-10', + dummy_module, + [], + [] + ) + self.assertEqual(entry, f'''## 1.2.3 (2023-06-10) + +* No change +''') def test_group_changes_by_api(self): main_changes = [ diff --git a/.github/workflows/changelog_generation.yaml b/.github/workflows/changelog_generation.yaml index 18751d952074..48e559437e1a 100644 --- a/.github/workflows/changelog_generation.yaml +++ b/.github/workflows/changelog_generation.yaml @@ -40,7 +40,7 @@ jobs: python3 .github/release-note-generation/split_release_note.py pr_body.txt . - name: Commit the change and push to the pull request branch run: | - git config user.email "70984784+yoshi-code-bot@users.noreply.github.com" + git config user.email "yoshi-code-bot@users.noreply.github.com" git config user.name "yoshi-code-bot" git remote set-url origin https://x-access-token:${{ secrets.YOSHI_CODE_BOT_TOKEN }}@github.com/${{ github.repository }} git add ./*/CHANGELOG.md From d3c75c1ff43c36f74fe794f5abfe6b7d544aa2f9 Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Wed, 21 Jun 2023 08:14:27 -0400 Subject: [PATCH 3/3] fetch depth default 1 is enough for a branch https://github.com/actions/checkout#checkout-a-different-branch --- .github/workflows/changelog_generation.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/changelog_generation.yaml b/.github/workflows/changelog_generation.yaml index 48e559437e1a..3828c869b88e 100644 --- a/.github/workflows/changelog_generation.yaml +++ b/.github/workflows/changelog_generation.yaml @@ -22,7 +22,6 @@ jobs: steps: - uses: actions/checkout@v3 with: - fetch-depth: 0 ref: ${{ github.head_ref }} - name: Show status of the branch checked out run: |