-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add a check to make sure unit tests are considered when changing code #10337
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
|
||
# **what?** | ||
# Checks that a file has been committed under the /tests/unit directory | ||
# as modification/addition to unit test. | ||
# This workflow runs on pull_request_target because it requires | ||
# secrets to post comments. | ||
|
||
# **why?** | ||
# Gentle nudge to think about adding unit tests for new code. | ||
# It also makes sure that we can filter PRs by tag to find out what type of changes are hard to unittest. | ||
|
||
# **when?** | ||
# This will run for all PRs going into main. It will | ||
# run when they are opened, reopened, when any label is added or removed | ||
# and when new code is pushed to the branch. The action will then get | ||
# skipped if the 'Hard to Unit Test' label or the 'Unit Test Not Needed' Label is present. | ||
|
||
name: Check Changelog Entry | ||
|
||
on: | ||
pull_request_target: | ||
types: [opened, reopened, labeled, unlabeled, synchronize] | ||
branches: | ||
- main | ||
paths: ['core/dbt'] | ||
|
||
workflow_dispatch: | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
jobs: | ||
unittest: | ||
name: Check if Unit Test being added. | ||
if: ${{ !contains(github.event.pull_request.labels.*.name, 'Unit Test Not Needed') && !contains(github.event.pull_request.labels.*.name, 'Hard to Unit Test')}} | ||
|
||
uses: dbt-labs/actions/.github/workflows/check-change-and-comment.yml@main | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the new action things should look much easier. |
||
with: | ||
comment: "Thank you for your pull request! We could not find a unittest file for this change. Please consider adding some. If it is hard to unittest, please add the 'Hard to Unit Test' label. If unit tests are not needed, please add the 'Unit Test Not Needed' label." | ||
path_filter: 'tests/unit/**' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should refactor https://github.com/dbt-labs/actions/blob/main/.github/workflows/changelog-existence.yml#L2 a bit to make it more generalized and use it here.
@emmyoop WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dbt-labs/actions#210