-
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
feat(2675): exclude ci build for non-pr #25489
Conversation
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. |
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.
LGTM
.circleci/config.yml
Outdated
@@ -81,6 +81,9 @@ aliases: | |||
|
|||
workflows: | |||
test_and_release: | |||
when: | |||
not: | |||
is: pull_request # Exclude pull request events |
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 would break CI on develop
and master
(which would break releases)
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.
We may also want to allow runs from branches that are manually triggered (not especially important to me but @HowardBraham mentioned this idea in Slack, some people mind find this useful)
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.
Can we look into doing it this way as well?
https://discuss.circleci.com/t/product-launch-override-only-build-prs-setting/47807
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.
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.
We may also want to allow runs from branches that are manually triggered (not especially important to me but @HowardBraham mentioned this idea in Slack, some people mind find this useful)
Can we target in a different ticket, and use an agreed scheme like trigger-CI-feature-123-test
where we always have trigger-CI
as prefix for branches who needs to have a pipeline before creating a PR?
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.
@HowardBraham Thanks for the information, but I was a bit lost there. Can you elaborate more on this propsal?
my understanding is, in the thread an API is suggested to config the setting. But we can use a schema in yml file to target the branch segmentation. 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.
Yeah, I agree it's confusing and I definitely don't completely understand it either. Basically there exist options in the API that are not available in the YML.
I thought about that trigger-CI
thing, yeah can we do that for now?
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.
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'm not sure there's a way to configure the manual trigger thing in config.yml
, I think the only way to do it is with that CircleCI API.
But if you make the pattern /^(master|develop|trigger-CI-.*)$/
it should at least run automatically on those branches.
Also it's a little hard to test, but I don't think it's going to run on master
or develop
as written. I think it will only run on Pull Requests.
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.
Thanks Howard for suggestions, i configured to trigger it in each run and integrated the pattern you suggested~
c6f2990
5142f01
to
29c3e29
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #25489 +/- ##
===========================================
- Coverage 69.77% 69.77% -0.00%
===========================================
Files 1376 1378 +2
Lines 48403 48578 +175
Branches 13348 13394 +46
===========================================
+ Hits 33773 33895 +122
- Misses 14630 14683 +53 ☔ View full report in Codecov by Sentry. |
e578631
to
013018f
Compare
Builds ready [013018f]
Page Load Metrics (65 ± 8 ms)
Bundle size diffs
|
Quality Gate passedIssues Measures |
Builds ready [8abf362]
Page Load Metrics (161 ± 189 ms)
Bundle size diffs
|
The solution in this PR is a little cumbersome. I implemented it the other way, as discussed in this article: I turned on this switch in our CircleCI settings: For our future records, the API call I ran was:
This is the result of my tests on different branch names, notice the @DDDDDanica @Gudahtt please do try some independent tests on this, but I think it's fully working now without this PR. |
command: | | ||
#!/bin/bash | ||
# Validate if branch is master, develop or release branch | ||
if [[ "$CIRCLE_BRANCH" =~ ^(develop|master|Version-v[0-9]+\.[0-9]+\.[0-9]+|trigger-ci.*)$ || -n "$CIRCLE_PULL_REQUESTS" ]]; then |
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.
[nit] can you include a mention of trigger-ci.*
in the comment?
@@ -423,12 +451,6 @@ jobs: | |||
#!/bin/bash | |||
|
|||
GH_LABEL=team-mmi | |||
if [ -z "$CIRCLE_PULL_REQUESTS" ]; then | |||
echo "Skipping tag check; this is not a PR." | |||
echo "false" > ./RUN_MMI_OPTIONAL |
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.
doesn't the fact that we don't assign ./RUN_MMI_OPTIONAL
anymore substantially change the script?
Hey @HowardBraham thanks for providing this solution. Unfortunately i cannot access the settings page you shared with. But this solution seems neat ! And then i checked the CURL you sent and it seems like this CURL was doing the opposite of what we are looking for? As now it is not running for branch |
@DDDDDanica I believe the CURL call is saying: So run on branches |
@HowardBraham the script seems correct, my bad, the branch I was testing was not named properly, and i believe this approach is the easiest one. Tested it locally as well and all works well. |
It does seem like Howard's solution is working |
Close because this has been implemented by @HowardBraham with a cleaner solution |
Description
To reduce cost for circle ci and allocate more resources to PR, we remove the circle build for non-pr branches.
Sample test jobs:
When branch name is matching filter as
develop
,master
, release branch starting withVersion
, here's a test job with mocked branch filterfeat/test-circle-ci
, be aware that this is for pure testing purpose:- Condition A:
Result: (success)
https://app.circleci.com/pipelines/github/MetaMask/metamask-extension/91110/workflows/80415232-2145-4a5d-a994-c89287351fc4/jobs/3384490
- Condition B:
Branch does not have an associated pull request, and does not match the filter, hence running
feat/test-circle-ci
branch will result in a failed pipeline:Result: (failure)
https://app.circleci.com/pipelines/github/MetaMask/metamask-extension/91111/workflows/f084602e-1af6-497f-b192-639861c25e01
- Condition C:
We trigger the build of current branch
feature/2675
, which doesn't match any name filter but has this current PR associated with it. Hence the pipeline will be triggered.Result: (success)
https://app.circleci.com/pipelines/github/MetaMask/metamask-extension/91112/workflows/c21314e0-dcab-4813-9031-8e1698524f02/jobs/3384524
Related issues
Fixes: https://github.com/MetaMask/MetaMask-planning/issues/2675
Manual testing steps
Screenshots/Recordings
Before
After
Condition B
Condition C
Pre-merge author checklist
Pre-merge reviewer checklist