From 8f369659d4d86f5e7fa48d35097fbe716213515f Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Fri, 11 Mar 2022 09:15:53 -0600 Subject: [PATCH 1/8] fix broken links, update GHA to not repost comment --- .changes/header.tpl.md | 2 +- .github/workflows/changelog-check.yml | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.changes/header.tpl.md b/.changes/header.tpl.md index 7baa5e9cab7..e48cb3069f6 100755 --- a/.changes/header.tpl.md +++ b/.changes/header.tpl.md @@ -3,4 +3,4 @@ - This file provides a full account of all changes to `dbt-core` and `dbt-postgres` - Changes are listed under the (pre)release in which they first appear. Subsequent releases include changes from previous releases. - "Breaking changes" listed under a version may require action from end users or external maintainers when upgrading to that version. -- Do not edit this file directly. This file is auto-generated using [changie](https://github.com/miniscruff/changie). For details on how to document a change, see [the contributing guide](CONTRIBUTING.md) +- Do not edit this file directly. This file is auto-generated using [changie](https://github.com/miniscruff/changie). For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry) diff --git a/.github/workflows/changelog-check.yml b/.github/workflows/changelog-check.yml index 8e0a332894b..47404e403ba 100644 --- a/.github/workflows/changelog-check.yml +++ b/.github/workflows/changelog-check.yml @@ -48,15 +48,31 @@ jobs: filters: | changelog: - added: '.changes/unreleased/**.yaml' - - name: Check a file has been added to .changes/unreleased if required + - name: Check if error comment has already posted + # https://github.com/marketplace/actions/find-comment + # Finds the exact comment string matching the body-includes. It will be empty strings + # if no matching comment was found. Empty strings evaluate to zero in GitHub Actions + # expressions. e.g. If comment-body is an empty string + # steps.changelog_comment.outputs.comment-body == 0 evaluates to true. + uses: peter-evans/find-comment@v1 + id: changelog_comment + with: + issue-number: ${{github.event.issue.number}} + body-includes: "Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry)." + - run: echo ${{ steps.fc.outputs.comment-body }} + - name: Post comment if a changelog file is required, hasn't been added, and no comment exists already uses: actions/github-script@v6 - if: steps.filter.outputs.changelog == 'false' && !contains( github.event.pull_request.labels.*.name, 'Skip Changelog') + if: steps.filter.outputs.changelog == 'false' && !contains( github.event.pull_request.labels.*.name, 'Skip Changelog') && steps.changelog_comment.outputs.comment-body != 0 with: script: | github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: "Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see [the contributing guide](CONTRIBUTING.md)." + body: "Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry)." }) - core.setFailed('Changelog entry required to merge.') + - name: Fail if no new changelog file exists + uses: actions/github-script@v6 + if: steps.filter.outputs.changelog == 'false' && !contains( github.event.pull_request.labels.*.name, 'Skip Changelog') + with: + script: core.setFailed('Changelog entry required to merge.') From a9ed476ae00e048aa29eeb317c832996147bbec7 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Fri, 11 Mar 2022 09:28:28 -0600 Subject: [PATCH 2/8] tweak GHA --- .github/workflows/changelog-check.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/changelog-check.yml b/.github/workflows/changelog-check.yml index 47404e403ba..1ec986f47de 100644 --- a/.github/workflows/changelog-check.yml +++ b/.github/workflows/changelog-check.yml @@ -53,16 +53,16 @@ jobs: # Finds the exact comment string matching the body-includes. It will be empty strings # if no matching comment was found. Empty strings evaluate to zero in GitHub Actions # expressions. e.g. If comment-body is an empty string - # steps.changelog_comment.outputs.comment-body == 0 evaluates to true. + # steps.clcomment.outputs.comment-body == 0 evaluates to true. uses: peter-evans/find-comment@v1 - id: changelog_comment + id: clcomment with: issue-number: ${{github.event.issue.number}} body-includes: "Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry)." - - run: echo ${{ steps.fc.outputs.comment-body }} + - run: echo ${{ steps.clcomment.outputs.comment-body }} - name: Post comment if a changelog file is required, hasn't been added, and no comment exists already uses: actions/github-script@v6 - if: steps.filter.outputs.changelog == 'false' && !contains( github.event.pull_request.labels.*.name, 'Skip Changelog') && steps.changelog_comment.outputs.comment-body != 0 + if: steps.filter.outputs.changelog == 'false' && !contains( github.event.pull_request.labels.*.name, 'Skip Changelog') && steps.clcomment.outputs.comment-body != 0 with: script: | github.rest.issues.createComment({ From d9bfc815886fda0e3a3cafbf1bd2af069a55187c Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Fri, 11 Mar 2022 09:36:04 -0600 Subject: [PATCH 3/8] convert GHA used --- .github/workflows/changelog-check.yml | 34 +++++++-------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/.github/workflows/changelog-check.yml b/.github/workflows/changelog-check.yml index 1ec986f47de..bdc3d1aaf04 100644 --- a/.github/workflows/changelog-check.yml +++ b/.github/workflows/changelog-check.yml @@ -48,31 +48,13 @@ jobs: filters: | changelog: - added: '.changes/unreleased/**.yaml' - - name: Check if error comment has already posted - # https://github.com/marketplace/actions/find-comment - # Finds the exact comment string matching the body-includes. It will be empty strings - # if no matching comment was found. Empty strings evaluate to zero in GitHub Actions - # expressions. e.g. If comment-body is an empty string - # steps.clcomment.outputs.comment-body == 0 evaluates to true. - uses: peter-evans/find-comment@v1 - id: clcomment - with: - issue-number: ${{github.event.issue.number}} - body-includes: "Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry)." - - run: echo ${{ steps.clcomment.outputs.comment-body }} - - name: Post comment if a changelog file is required, hasn't been added, and no comment exists already - uses: actions/github-script@v6 - if: steps.filter.outputs.changelog == 'false' && !contains( github.event.pull_request.labels.*.name, 'Skip Changelog') && steps.clcomment.outputs.comment-body != 0 - with: - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: "Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry)." - }) - - name: Fail if no new changelog file exists - uses: actions/github-script@v6 - if: steps.filter.outputs.changelog == 'false' && !contains( github.event.pull_request.labels.*.name, 'Skip Changelog') + + - name: Create/Update PR comment if changelog entry is missing and required + uses: peter-evans/create-or-update-comment@v1 + if: | + steps.filter.outputs.changelog == 'false' && + !contains( github.event.pull_request.labels.*.name, 'Skip Changelog') with: + issue-number: ${{ github.event.client_payload.pull_request.number }} + body: "Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry)." script: core.setFailed('Changelog entry required to merge.') From d9cb97da1415aac301234e6e94fd7db7f5c0a08d Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Fri, 11 Mar 2022 09:58:32 -0600 Subject: [PATCH 4/8] consolidate GHA --- .github/workflows/changelog-check.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/changelog-check.yml b/.github/workflows/changelog-check.yml index bdc3d1aaf04..b6a8985f7d2 100644 --- a/.github/workflows/changelog-check.yml +++ b/.github/workflows/changelog-check.yml @@ -48,13 +48,26 @@ jobs: filters: | changelog: - added: '.changes/unreleased/**.yaml' - - - name: Create/Update PR comment if changelog entry is missing and required + - name: Check if comment already exists + uses: peter-evans/find-comment@v1 + id: changelog_comment + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry). + - name: Create PR comment if changelog entry is missing, required, and does nto exist + if: | + steps.filter.outputs.changelog == 'false' && + !contains( github.event.pull_request.labels.*.name, 'Skip Changelog') && + steps.changelog_comment.outputs.comment-body == '' uses: peter-evans/create-or-update-comment@v1 + with: + issue-number: ${{ github.event.client_payload.pull_request.number }} + body: Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry). + - name: Create/Update PR comment if changelog entry is missing and required if: | steps.filter.outputs.changelog == 'false' && !contains( github.event.pull_request.labels.*.name, 'Skip Changelog') + uses: actions/github-script@v6 with: - issue-number: ${{ github.event.client_payload.pull_request.number }} - body: "Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry)." script: core.setFailed('Changelog entry required to merge.') From bc6c37d509d3f3742a173ef1ff0ff9d9c82f38ce Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Fri, 11 Mar 2022 10:06:25 -0600 Subject: [PATCH 5/8] fix PR numbers and pull comment as var --- .github/workflows/changelog-check.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/changelog-check.yml b/.github/workflows/changelog-check.yml index b6a8985f7d2..062126ecd4a 100644 --- a/.github/workflows/changelog-check.yml +++ b/.github/workflows/changelog-check.yml @@ -27,6 +27,9 @@ permissions: contents: read pull-requests: write +env: + changelog_comment: 'Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry).' + jobs: changelog: name: changelog @@ -54,7 +57,7 @@ jobs: with: issue-number: ${{ github.event.pull_request.number }} comment-author: 'github-actions[bot]' - body-includes: Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry). + body-includes: ${{ env.changelog_comment }} - name: Create PR comment if changelog entry is missing, required, and does nto exist if: | steps.filter.outputs.changelog == 'false' && @@ -62,8 +65,8 @@ jobs: steps.changelog_comment.outputs.comment-body == '' uses: peter-evans/create-or-update-comment@v1 with: - issue-number: ${{ github.event.client_payload.pull_request.number }} - body: Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry). + issue-number: ${{ github.event.pull_request.number }} + body: ${{ env.changelog_comment }} - name: Create/Update PR comment if changelog entry is missing and required if: | steps.filter.outputs.changelog == 'false' && From a7b1f9433c54f68a9a4f6a2404dd50090f91e817 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Fri, 11 Mar 2022 10:08:34 -0600 Subject: [PATCH 6/8] fix name of workflow step --- .github/workflows/changelog-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/changelog-check.yml b/.github/workflows/changelog-check.yml index 062126ecd4a..fad10a4a5ad 100644 --- a/.github/workflows/changelog-check.yml +++ b/.github/workflows/changelog-check.yml @@ -67,7 +67,7 @@ jobs: with: issue-number: ${{ github.event.pull_request.number }} body: ${{ env.changelog_comment }} - - name: Create/Update PR comment if changelog entry is missing and required + - name: Fail job if changelog entry is missing and required if: | steps.filter.outputs.changelog == 'false' && !contains( github.event.pull_request.labels.*.name, 'Skip Changelog') From 31b2167b4e828ea85c442ac378ac5c9ab405418b Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Fri, 11 Mar 2022 10:10:53 -0600 Subject: [PATCH 7/8] changie merge to fix link at top of changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5974fc1e155..b4a4ece6194 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,10 @@ - This file provides a full account of all changes to `dbt-core` and `dbt-postgres` - Changes are listed under the (pre)release in which they first appear. Subsequent releases include changes from previous releases. - "Breaking changes" listed under a version may require action from end users or external maintainers when upgrading to that version. -- Do not edit this file directly. This file is auto-generated using [changie](https://github.com/miniscruff/changie). For details on how to document a change, see [the contributing guide](CONTRIBUTING.md) +- Do not edit this file directly. This file is auto-generated using [changie](https://github.com/miniscruff/changie). For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry) -*** below changes will need to be manually merged with the changes generated by `changie batch` for 1.1.0. This is a one time manual step caused by changie being introduced mid-development. *** +*** below changes will need to be manually merged with the changes generated by `changie batch` for 1.1.0. Once the two are merged, this file should be deleted. This is a one time thing because changie was introduced mid-development. *** ## dbt-core 1.1.0 (TBD) From bec0329066bd18ab2c30c00fcfe4ff70392b5829 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Fri, 11 Mar 2022 10:19:11 -0600 Subject: [PATCH 8/8] add changelog yaml --- .changes/unreleased/Under the Hood-20220311-101851.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changes/unreleased/Under the Hood-20220311-101851.yaml diff --git a/.changes/unreleased/Under the Hood-20220311-101851.yaml b/.changes/unreleased/Under the Hood-20220311-101851.yaml new file mode 100644 index 00000000000..0c03e55efcc --- /dev/null +++ b/.changes/unreleased/Under the Hood-20220311-101851.yaml @@ -0,0 +1,8 @@ +kind: Under the Hood +body: Fix broken links for changelog generation and tweak GHA to only post a comment + once when changelog entry is missing. +time: 2022-03-11T10:18:51.404524-06:00 +custom: + Author: emmyoop + Issue: "4848" + PR: "4857"