-
Notifications
You must be signed in to change notification settings - Fork 679
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 workaround for CircleCI's problems filtering from forks #4505
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #4505 +/- ##
===========================================
+ Coverage 82.62% 82.63% +<.01%
===========================================
Files 45 45
Lines 3114 3115 +1
Branches 337 337
===========================================
+ Hits 2573 2574 +1
Misses 456 456
Partials 85 85
Continue to review full report at Codecov.
|
CircleCI's branch filtering does not work properly with pull requests from forks. The CIRCLE_BRANCH variable contains something like freedomofpress/pull/3 in this case. This means that docs and i18n PRs from forks are not being tested as we wish; the translation tests are not run for i18n PRs, and the app tests are being run for docs PRs. A CircleCI feature request [1] to improve this was closed without explanation, so I'm incorporating a workaround suggested in the CircleCI forums: using the GitHub API to obtain the real branch name for PRs from forks, and skipping tests if it doesn't match. Not all steps of the relevant jobs are skipped, but the most expensive ones are. Also, stop skipping static-analysis-and-no-known-cves, as it doesn't take that long, and might prevent problems from sneaking in on branches with inaccurate names. [1] https://discuss.circleci.com/t/only-build-pull-requests-targetting-specific-branch/6082/6
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.
new script looks great, thanks! however i did notice two issues in the deb-tests
CI job that should be resolved prior to merge, see inline comments
.circleci/config.yml
Outdated
@@ -292,7 +320,13 @@ jobs: | |||
- run: apt-get install -y make virtualenv python-pip enchant |
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'll need to install jq here too no?
.circleci/config.yml
Outdated
command: | | ||
BRANCH_MATCH=$(devops/scripts/match-ci-branch.sh "^update-builder") | ||
echo "match-ci-branch.sh said: ${BRANCH_MATCH}" | ||
if [[ $BRANCH_MATCH =~ ^found ]]; then echo "Skipping: ${BRANCH_MATCH}"; exit 0; fi |
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.
if [[ $BRANCH_MATCH =~ ^found ]]
-> if ! [[ $BRANCH_MATCH =~ ^found ]]
here since we only want to skip the test when we don't find update-builder
in the branch name
(btw: the deb-tests
job isn't getting kicked off when testing from a fork since we're using circle ci's branch filtering on /update-builder-.*/
. I think this makes sense since in practice anyone who is doing builder updates has write access to the repo.)
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.
my comments were addressed, this should be good to go now 👍
Changes in develop were introduced in #4505, minimal fix to ensure the dependency is installed and CI passes only in the 0.13.1 release branch
Status
Ready for review
Description of Changes
CircleCI's branch filtering does not work properly with pull requests
from forks. The
CIRCLE_BRANCH
variable contains something like/pull/3
in this case. This means that docs and i18n PRs from forks are not
being tested as we wish; the translation tests are not run for i18n
PRs, and the app tests are being run for docs PRs.
A CircleCI feature request to improve this was closed without
explanation, so I'm incorporating a workaround suggested in the
CircleCI forums: using the GitHub API to obtain the real branch name
for PRs from forks, and skipping tests if it doesn't match. Not all
steps of the relevant jobs are skipped, but the most expensive ones
are.
Also, stop skipping static-analysis-and-no-known-cves, as it doesn't
take that long, and might prevent problems from sneaking in on
branches with inaccurate names.
Fixes #4479.
Testing
We're going to test this with two PRs, one for docs and one for i18n, to verify that the right tests run and pass.
Deployment
This will only affect CI.
Checklist
If you made non-trivial code changes: