Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add JUnit summaries to CircleCI as well as merged runs #3704

Merged
merged 19 commits into from
Sep 12, 2018
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
- store_artifacts:
path: ~/project/logs
destination: logs
- store_test_results:
path: logs
sytestpy2postgres:
machine: true
steps:
Expand All @@ -18,6 +20,33 @@ jobs:
- store_artifacts:
path: ~/project/logs
destination: logs
- store_test_results:
path: logs
sytestpy2merged:
machine: true
steps:
- checkout
- run: bash .circleci/merge_base_branch.sh
- run: docker pull matrixdotorg/sytest-synapsepy2
- run: docker run --rm -it -v $(pwd)\:/src -v $(pwd)/logs\:/logs matrixdotorg/sytest-synapsepy2
- store_artifacts:
path: ~/project/logs
destination: logs
- store_test_results:
path: logs
sytestpy2postgresmerged:
machine: true
steps:
- checkout
- run: bash .circleci/merge_base_branch.sh
- run: docker pull matrixdotorg/sytest-synapsepy2
- run: docker run --rm -it -v $(pwd)\:/src -v $(pwd)/logs\:/logs -e POSTGRES=1 matrixdotorg/sytest-synapsepy2
- store_artifacts:
path: ~/project/logs
destination: logs
- store_test_results:
path: logs

sytestpy3:
machine: true
steps:
Expand All @@ -27,6 +56,8 @@ jobs:
- store_artifacts:
path: ~/project/logs
destination: logs
- store_test_results:
path: logs
sytestpy3postgres:
machine: true
steps:
Expand All @@ -36,13 +67,41 @@ jobs:
- store_artifacts:
path: ~/project/logs
destination: logs
- store_test_results:
path: logs
sytestpy3merged:
machine: true
steps:
- checkout
- run: bash .circleci/merge_base_branch.sh
- run: docker pull matrixdotorg/sytest-synapsepy3
- run: docker run --rm -it -v $(pwd)\:/src -v $(pwd)/logs\:/logs hawkowl/sytestpy3
- store_artifacts:
path: ~/project/logs
destination: logs
- store_test_results:
path: logs
sytestpy3postgresmerged:
machine: true
steps:
- checkout
- run: bash .circleci/merge_base_branch.sh
- run: docker pull matrixdotorg/sytest-synapsepy3
- run: docker run --rm -it -v $(pwd)\:/src -v $(pwd)/logs\:/logs -e POSTGRES=1 matrixdotorg/sytest-synapsepy3
- store_artifacts:
path: ~/project/logs
destination: logs
- store_test_results:
path: logs

workflows:
version: 2
build:
jobs:
- sytestpy2
- sytestpy2postgres
- sytestpy2merged
- sytestpy2postgresmerged
# Currently broken while the Python 3 port is incomplete
# - sytestpy3
# - sytestpy3postgres
22 changes: 22 additions & 0 deletions .circleci/merge_base_branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
echo 'export CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}"' >> $BASH_ENV
Copy link
Member

Choose a reason for hiding this comment

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

shebang / comment / set -e, please

Copy link
Member

Choose a reason for hiding this comment

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

also chmod +x ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

source $BASH_ENV

if [[ -n "${CIRCLE_PR_NUMBER}" ]]
then
# Update PR refs for testing.
FETCH_REFS="${FETCH_REFS} +refs/pull/${CIRCLE_PR_NUMBER}/head:pr/${CIRCLE_PR_NUMBER}/head"
FETCH_REFS="${FETCH_REFS} +refs/pull/${CIRCLE_PR_NUMBER}/merge:pr/${CIRCLE_PR_NUMBER}/merge"

# Retrieve the refs
git fetch -u origin ${FETCH_REFS}

# Checkout PR merge ref.
git checkout -qf "pr/${CIRCLE_PR_NUMBER}/merge"
Copy link
Member

Choose a reason for hiding this comment

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

I think that conflicting PRs don't get a /merge ref, so this will fail, and the next command is a bit strange. what is your thinking here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no idea -- to be honest, this is just cargo culting. I haven't had any luck finding ANY documentation on the /merge ref, or the pr/ refset at all on GitHub -- my google-fu has failed me unfortunately. This is just the method that was recommended on the CircleCI forums (because Circle doesn't have a "merge before run" functionality like Travis).


# Test for merge conflicts.
git branch --merged | grep "pr/${CIRCLE_PR_NUMBER}/head" > /dev/null
Copy link
Member

Choose a reason for hiding this comment

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

So a comment to explain how this works is going to be necessary. I think this works by:

  • The git checkout above will fail if there is no merge branch, and so we'll bail out due to set -e
  • If it does exist, git branch --merged will list all branches that are merged into it. The grep will succeed if pr/.../head branch is merged into it, and fail if it isn't (and therefore bail out).
  • If pr/../head is merged in then that means pr/../merge must be an up to date merge commit, and so we're done.


fi
Copy link
Member

Choose a reason for hiding this comment

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

If we can't find a CIRCLE_PR_NUMBER then we should probably bail out, rather than pretending we succeeded doing a merge build

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we'll bail out upwards (we check if CIRCLE_PR_NUMBER is defined)

Copy link
Member

Choose a reason for hiding this comment

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

Then why do we have an if guard?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because it also runs on master/develop

Copy link
Member

Choose a reason for hiding this comment

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

oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooh

Copy link
Member

Choose a reason for hiding this comment

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

Comment maybe for us slow people at the back? 0:-)


# Log what we are
git show -s
1 change: 1 addition & 0 deletions changelog.d/3704.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CircleCI tests now run on the potential merge of a PR.