Skip to content
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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

chloeYue
Copy link
Contributor

@chloeYue chloeYue commented Jan 9, 2025

Description

This PR introduces conditional handling for the test-lint-changelog job based on the branch name in the pipeline.

Specifically:

  • For release branches starting with Version-v, failures in the test-lint-changelog job will:
    Be marked as failed for visibility.
    Not block the pipeline, allowing subsequent jobs to execute.

  • For all other branches, failures in test-lint-changelog will:
    Block the pipeline.
    Mark the workflow as failed, ensuring strict validation for non-RC branches.

The changes ensure that RC branches (starting with Version-v) have flexibility in pipeline execution while maintaining visibility of validation failures. In other words, failure for job test-lint-changelog on release branch will not block the generation of builds.

I have tested with the same change on a regular branch and a branch starts with Version-v, it works as expected.

Open in GitHub Codespaces

Related issues

Fixes: #29721

Manual testing steps

  1. Commit the change, push branches starting with Version-v and ensure:
    Failures in test-lint-changelog do not block the pipeline to generate builds but are still marked as failed in the UI.
  2. Commit the change, push branches not starting with Version-v and ensure:
    Failures in test-lint-changelog block the pipeline to generate builds.

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@chloeYue chloeYue self-assigned this Jan 9, 2025
@chloeYue chloeYue marked this pull request as draft January 9, 2025 17:38
Copy link
Contributor

github-actions bot commented Jan 9, 2025

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot
Copy link
Collaborator

Builds ready [b354520]
Page Load Metrics (1657 ± 50 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint15141971165610752
domContentLoaded15061943162510550
load15121960165710550
domInteractive25136513416
backgroundConnect790332412
firstReactRender1695482813
getState57715199
initialActions01000
loadScripts1103148712108842
setupStore684212713
uiStartup17432375199219795

@chloeYue chloeYue closed this Jan 14, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jan 14, 2025
@chloeYue chloeYue reopened this Jan 14, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [4d3d7c5]
Page Load Metrics (1630 ± 75 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint37018221539279134
domContentLoaded14522238159716278
load14632244163015775
domInteractive21168443517
backgroundConnect10102332713
firstReactRender16100493014
getState584172010
initialActions01000
loadScripts10591721119713364
setupStore685182411
uiStartup166325701972272131
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [e61eaf4]
Page Load Metrics (1737 ± 85 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint18221471508550264
domContentLoaded15242133171617283
load15422144173717785
domInteractive20118482713
backgroundConnect108024188
firstReactRender1686462512
getState57016199
initialActions01000
loadScripts11061596125614168
setupStore75415168
uiStartup174228191999276132
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -103.42 KiB (-1.78%)
  • ui: 1.06 KiB (0.01%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [af75307]
Page Load Metrics (1705 ± 64 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint15192017171413866
domContentLoaded15051977167712560
load15222014170513364
domInteractive2796502613
backgroundConnect126727199
firstReactRender1799482914
getState55111105
initialActions01000
loadScripts11031508126011153
setupStore687282613
uiStartup175924872001213102
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -103.42 KiB (-1.78%)
  • ui: 1.07 KiB (0.01%)
  • common: 0 Bytes (0.00%)

@chloeYue chloeYue changed the title test: test chore: handle test-lint-changelog failures differently for release branches Jan 14, 2025
@chloeYue chloeYue requested a review from danjm January 15, 2025 09:53
@chloeYue chloeYue requested a review from Gudahtt January 15, 2025 09:53
@chloeYue chloeYue marked this pull request as ready for review January 15, 2025 09:53
@metamaskbot
Copy link
Collaborator

Builds ready [95e1850]
Page Load Metrics (1665 ± 45 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1509183916669646
domContentLoaded1464178816359646
load1511181616659345
domInteractive216933147
backgroundConnect107234188
firstReactRender1681362412
getState55713136
initialActions01000
loadScripts1084137512238943
setupStore65212126
uiStartup16852084186911254
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -104.59 KiB (-1.80%)
  • ui: 2.88 KiB (0.04%)
  • common: -34.29 KiB (-0.41%)

- name: Evaluate branch for changelog lint handling
id: evaluate-branch
run: |
BRANCH_NAME="${{ github.ref_name }}"
Copy link
Contributor

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:

env:
  BRANCH_NAME=${{ ... }}
run: |
  ...

Copy link
Contributor

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 the push and merge group events. For PRs, the name of the target branch is github.head_ref. github.ref_name for PRs returns something weird like refs/pull/3/merge.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TLDR:

env:
  # For a `pull_request` event, the branch is `github.head_ref``.
  # For a `push` event, the branch is `github.ref_name`.
  BRANCH: ${{ github.head_ref || github.ref_name }}

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be more idiomatic to make IGNORE_CHANGELOG_FAILURE the output of the step.

It would look something like:

echo "IGNORE_CHANGELOG_FAILURE=true" >> "$GITHUB_OUTPUT"

then you can later use it like:

steps.evaluate-branch.outputs.IGNORE_CHANGELOG_FAILURE

- name: Validate test-lint-changelog outcome
id: validate-changelog-job
run: |
TEST_LINT_CHANGELOG_FAILED="${{ needs.test-lint-changelog.result }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, TEST_LINT_CHANGELOG_FAILED and IGNORE_CHANGELOG_FAILURE should be passed in env, instead of being inlined.

Copy link
Contributor

@itsyoboieltr itsyoboieltr Jan 15, 2025

Choose a reason for hiding this comment

The 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 test-lint-changelog to succeed to even start running (as it is included in needs), this variable can never be equal failure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idneeds

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.

id: validate-changelog-job
run: |
TEST_LINT_CHANGELOG_FAILED="${{ needs.test-lint-changelog.result }}"
if [[ "$TEST_LINT_CHANGELOG_FAILED" == "failure" && "$IGNORE_CHANGELOG_FAILURE" == "true" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Needs more work from the author
Development

Successfully merging this pull request may close these issues.

Improve changelog lint behavior for release branches
3 participants