From 6998c3e275b09c522c44e80e19d2f7882742afc0 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Mon, 25 Jan 2021 18:40:27 +0000 Subject: [PATCH] Clean up the commands a bit by extracting to a common anchor --- synapse/pipeline.yml | 61 +++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/synapse/pipeline.yml b/synapse/pipeline.yml index 9fe7e16..0a5bb89 100644 --- a/synapse/pipeline.yml +++ b/synapse/pipeline.yml @@ -10,6 +10,25 @@ x-yaml-aliases: apt-get update && apt-get install -y xmlsec1 python -m pip install tox + # Note: We can't place the below steps in a Synapse repo script as this code is + # given access to the host docker socket. We don't want to allow untrusted code + # to be executed with those privileges. + - complement_commands_common: &complement_commands_common + # We use the complement:latest image to provide Complement's dependencies, but want + # to actually run against the master branch of Complement, so download it here. + - "wget https://github.com/matrix-org/complement/archive/master.tar.gz" + - "tar -xzf master.tar.gz" + + # Build a second docker image on top of the above image. This one sets up Synapse with a generated config file, + # signing and SSL keys so Synapse can run and federate. The value of the environment + # variable determines which Synapse-flavoured dockerfile to use from Complement repo. + - "docker build -t complement-synapse -f $SYNAPSE_COMPLEMENT_DOCKERFILE complement-master/dockerfiles" + + # Finally, compile and run the tests. + - "cd complement-master" + - "go test -v -tags synapse_blacklist ./tests" + + plugins: - docker#v3.7.0: &complement_docker_common # The dockerfile for this image is at @@ -564,50 +583,37 @@ steps: # given access to the host docker socket. We don't want to allow untrusted code # to be executed with those privileges. - # Build a docker image from the checked out Synapse source + # Build a base docker image from the checked out Synapse source - "docker build -t matrixdotorg/synapse:latest -f docker/Dockerfile ." - # We use the complement:latest image to provide Complement's dependencies, but want - # to actually run against the master branch of Complement, so download it here. - - "wget https://github.com/matrix-org/complement/archive/master.tar.gz" - - "tar -xzf master.tar.gz" - # Build a second docker image on top of the above image. This one sets up Synapse with a generated config file, - # signing and SSL keys so Synapse can run and federate - - "docker build -t complement-synapse -f complement-master/dockerfiles/Synapse.Dockerfile complement-master/dockerfiles" + # Build the final dockerfile and run the tests + *complement_commands_common - # Finally, compile and run the tests. - - "cd complement-master" - - "go test -v -tags synapse_blacklist ./tests" label: "\U0001F9EA Complement | Synapse Monolith" agents: queue: "medium" plugins: - docker#v3.7.0: <<: *complement_docker_common + # Override the default plugin settings + environment: + - *complement_docker_environment_common + # Use a Synapse Monolith Dockerfile from Complement. This dockerfile is located at: + # https://github.com/matrix-org/complement/blob/master/dockerfiles/Synapse.Dockerfile + - "SYNAPSE_COMPLEMENT_DOCKERFILE=complement-master/dockerfiles/Synapse.Dockerfile" - command: # Build the necessary docker images and start Complement. - # Note: We can't place the below steps in a Synapse repo script as this code is - # given access to the host docker socket. We don't want to allow untrusted code - # to be executed with those privileges. - # Build a docker image from the checked out Synapse source + # Build a base docker image from the checked out Synapse source - "docker build -t matrixdotorg/synapse:latest -f docker/Dockerfile ." + # Build a second docker image on top of the above image. This one sets up Synapse workers - # as well as everything else it needs to run a federating setup - "docker build -t matrixdotorg/synapse:workers -f docker/Dockerfile-workers ." - # We use the complement:latest image to provide Complement's dependencies, but want - # to actually run against the master branch of Complement, so download it here. - - "wget https://github.com/matrix-org/complement/archive/master.tar.gz" - - "tar -xzf master.tar.gz" - # Build an image for running the above worker setup in Complement. This involves - # disabling rate-limiting, using Complement's CA etc. - - "docker build -t complement-synapse -f complement-master/dockerfiles/SynapseWorkers.Dockerfile complement-master/dockerfiles" + # Build the final dockerfile and run the tests + *complement_commands_common - # Finally, compile and run the tests. - - "cd complement-master" - - "go test -v -tags synapse_blacklist ./tests" label: "\U0001F9EA Complement | Synapse Workers" agents: # Running every worker takes a beefy system @@ -618,6 +624,9 @@ steps: # Override the default plugin settings environment: - *complement_docker_environment_common + # Use the Synapse Worker Dockerfile from Complement. This dockerfile is located at: + # https://github.com/matrix-org/complement/blob/master/dockerfiles/SynapseWorkers.Dockerfile + - "SYNAPSE_COMPLEMENT_DOCKERFILE=complement-master/dockerfiles/SynapseWorkers.Dockerfile" # Enable Complement's certificate authority for authentication of federation # requests - "COMPLEMENT_CA=true"