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

Add workaround for CircleCI's problems filtering from forks #4505

Merged
merged 2 commits into from Jun 10, 2019

Conversation

rmol
Copy link
Contributor

@rmol rmol commented Jun 4, 2019

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:

  • I have written a test plan and validated it for this PR

This was referenced Jun 4, 2019
@codecov-io
Copy link

codecov-io commented Jun 5, 2019

Codecov Report

Merging #4505 into develop will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ
securedrop/securedrop/source_app/__init__.py 92.63% <0%> (+0.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update df32628...16248c5. Read the comment docs.

@rmol rmol marked this pull request as ready for review June 5, 2019 21:41
.circleci/config.yml Outdated Show resolved Hide resolved
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
Copy link
Contributor

@redshiftzero redshiftzero left a 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

@@ -292,7 +320,13 @@ jobs:
- run: apt-get install -y make virtualenv python-pip enchant
Copy link
Contributor

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?

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

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

@rmol rmol mentioned this pull request Jun 8, 2019
@rmol rmol moved this from In Development to Ready for review in SecureDrop Team Board Jun 10, 2019
@rmol rmol moved this from Ready for review to Under Review in SecureDrop Team Board Jun 10, 2019
Copy link
Contributor

@redshiftzero redshiftzero left a 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 👍

@redshiftzero redshiftzero merged commit 6bee0cc into freedomofpress:develop Jun 10, 2019
SecureDrop Team Board automation moved this from Under Review to Done Jun 10, 2019
emkll added a commit that referenced this pull request Jun 18, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

CI branch filtering logic doesn't work from forks
3 participants