-
Notifications
You must be signed in to change notification settings - Fork 5k
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
chore: handle test-lint-changelog failures differently for release branches #29612
base: main
Are you sure you want to change the base?
Changes from all commits
b354520
8f6a121
fe7f3ca
6304fce
4aca5df
7e8c29c
4d3d7c5
f48ad9a
e61eaf4
b28f763
b77e846
e7cadff
733ca4a
ecc3db1
cbf230b
af75307
95e1850
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,29 @@ jobs: | |
outputs: | ||
PASSED: ${{ steps.set-output.outputs.PASSED }} | ||
steps: | ||
- name: Evaluate branch for changelog lint handling | ||
id: evaluate-branch | ||
run: | | ||
BRANCH_NAME="${{ github.ref_name }}" | ||
if [[ "$BRANCH_NAME" == Version-v* ]]; then | ||
echo "Branch starts with Version-v. Ignoring failure for test-lint-changelog." | ||
echo "IGNORE_CHANGELOG_FAILURE=true" >> "$GITHUB_ENV" | ||
else | ||
echo "IGNORE_CHANGELOG_FAILURE=false" >> "$GITHUB_ENV" | ||
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. it would be more idiomatic to make It would look something like:
then you can later use it like:
|
||
fi | ||
|
||
- name: Validate test-lint-changelog outcome | ||
id: validate-changelog-job | ||
run: | | ||
TEST_LINT_CHANGELOG_FAILED="${{ needs.test-lint-changelog.result }}" | ||
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. same as above, 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. BTW, did you check if this works? I think that this will not work. As this job needs 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. Use jobs.<job_id>.needs to identify any jobs that must complete successfully before this job will run. It can be a string or array of strings. If a job fails or is skipped, all jobs that need it are skipped. |
||
if [[ "$TEST_LINT_CHANGELOG_FAILED" == "failure" && "$IGNORE_CHANGELOG_FAILURE" == "true" ]]; then | ||
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. I do not understand why is the same condition repeated twice. Why don't we just if [[ "$TEST_LINT_CHANGELOG_FAILED" == "failure" ]]; then
if [[ "$IGNORE_CHANGELOG_FAILURE" == "true" ]]; then
echo "test-lint-changelog failed, but we're ignoring it for Version-v branches."
else
echo "test-lint-changelog failed and cannot be ignored."
exit 1
fi
fi I would even go as far as just doing: if [[ "$TEST_LINT_CHANGELOG_FAILED" == "failure" ]]; then
if [[ "$BRANCH_NAME" == Version-v* ]]; then
echo "test-lint-changelog failed, but we're ignoring it for Version-v branches."
else
echo "test-lint-changelog failed and cannot be ignored."
exit 1
fi
fi so that we can reduce complexity by only having a single step. Having multiple steps for this is unnecessary in my opinion. |
||
echo "test-lint-changelog failed, but we're ignoring it for Version-v branches." | ||
elif [[ "$TEST_LINT_CHANGELOG_FAILED" == "failure" ]]; then | ||
echo "test-lint-changelog failed and cannot be ignored." | ||
exit 1 | ||
fi | ||
echo "All jobs completed successfully." | ||
|
||
- name: Set PASSED output | ||
id: set-output | ||
run: echo "PASSED=true" >> "$GITHUB_OUTPUT" | ||
|
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.
This should be an environment variable to the step, like:
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.
In addition,
github.ref_name
is only the branch name for thepush
andmerge group events
. For PRs, the name of the target branch isgithub.head_ref
.github.ref_name
for PRs returns something weird likerefs/pull/3/merge
.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.
TLDR: