From 06fde25c3b1b53be891b3845d8fd36a7d65c900f Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Mon, 9 Sep 2019 09:58:36 +0200 Subject: [PATCH] circleci: centralise git checkout --- .circleci/config.yml | 109 +++++++++++++++++++++++++++---------------- 1 file changed, 70 insertions(+), 39 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8ea8e4512..4e952465e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,19 +13,33 @@ commands: - run: name: Clone the repo command: | + mkdir -p /opt/project if [ -n "$CIRCLE_PR_NUMBER" ] then echo === Checking out PR "$CIRCLE_PR_NUMBER" from "$CIRCLE_REPOSITORY_URL" - git clone --depth 1 $CIRCLE_REPOSITORY_URL ~/project - cd ~/project + git clone --depth 1 $CIRCLE_REPOSITORY_URL /opt/project + cd /opt/project git fetch --depth 1 origin +refs/pull/${CIRCLE_PR_NUMBER}/merge git checkout -qf FETCH_HEAD else echo === Checking out branch "${CIRCLE_BRANCH}" from "$CIRCLE_REPOSITORY_URL" - git clone --depth 1 --branch $CIRCLE_BRANCH $CIRCLE_REPOSITORY_URL ~/project + git clone --depth 1 --branch $CIRCLE_BRANCH $CIRCLE_REPOSITORY_URL /opt/project fi + cd /opt/project git show -s + get-workspace: + description: "Attach workspace to /opt and symlink checkout into home" + steps: + - run: + name: ensure ca-certificates is installed + command: apt-get update && apt-get -qq -y install ca-certificates + - attach_workspace: + at: /opt + - run: + name: symlink checkout into home + command: rmdir ~/project && ln -s /opt/project ~/project + install-coverity-tools: description: Install the coverity tools to /usr/local steps: @@ -45,11 +59,7 @@ commands: auth-regress-setup: description: Prepare the environment for auth regression tests steps: - - run: - name: ensure ca-certificates is installed - command: apt-get update && apt-get -qq -y install ca-certificates - - attach_workspace: - at: /opt + - get-workspace - install-auth-deps - run: name: Install test dependencies @@ -71,7 +81,6 @@ commands: tar xfz jdnssec-tools-0.14.tar.gz --strip-components=1 -C / rm jdnssec-tools-0.14.tar.gz fi - - checkout-shallow - run: name: Allow missing tools in verify-dnssec-zone command: touch regression-tests/tests/verify-dnssec-zone/allow-missing @@ -203,6 +212,7 @@ commands: - run: command: | apt-get install -qq -y \ + git \ libboost-all-dev \ libsystemd0 \ libyaml-cpp0.5v5 \ @@ -456,12 +466,23 @@ commands: fi jobs: + checkout: + docker: + - image: debian:buster + + steps: + - checkout-shallow + - persist_to_workspace: + root: /opt + paths: + - project + build-auth: docker: - image: debian:stretch steps: - - checkout-shallow + - get-workspace - install-auth-dev-deps - restore-cache-ccache: product: auth @@ -810,7 +831,7 @@ jobs: ragel \ systemd \ virtualenv - - checkout-shallow + - get-workspace - run: name: autoconf command: BUILDER_VERSION=0.0.0-git1 autoreconf -vfi @@ -862,9 +883,7 @@ jobs: command: | touch /etc/authbind/byport/53 chmod 755 /etc/authbind/byport/53 - - checkout-shallow - - attach_workspace: - at: /opt + - get-workspace - run: name: Run regression tests workdir: ~/project @@ -880,9 +899,7 @@ jobs: - add-auth-repo - run: apt-get --no-install-recommends install -qq -y pdns-tools moreutils time - install-recursor-deps - - checkout-shallow - - attach_workspace: - at: /opt + - get-workspace - run: name: Get the majestic million list workdir: ~/project/regression-tests @@ -908,9 +925,7 @@ jobs: - add-auth-repo - run: apt-get --no-install-recommends install -qq -y virtualenv pdns-tools - install-recursor-deps - - checkout-shallow - - attach_workspace: - at: /opt + - get-workspace - run: name: Run API tests workdir: ~/project/regression-tests.api @@ -922,7 +937,7 @@ jobs: docker: - image: debian:stretch steps: - - checkout-shallow + - get-workspace - install-doc-deps - build-auth-docs @@ -930,7 +945,7 @@ jobs: docker: - image: debian:stretch steps: - - checkout-shallow + - get-workspace - install-doc-deps - build-auth-docs - add-docs-upload-ssh @@ -940,7 +955,7 @@ jobs: docker: - image: debian:stretch steps: - - checkout-shallow + - get-workspace - install-doc-deps - build-recursor-docs @@ -948,7 +963,7 @@ jobs: docker: - image: debian:stretch steps: - - checkout-shallow + - get-workspace - install-doc-deps - build-recursor-docs - add-docs-upload-ssh @@ -958,7 +973,7 @@ jobs: docker: - image: debian:stretch steps: - - checkout-shallow + - get-workspace - install-doc-deps - build-dnsdist-docs @@ -966,7 +981,7 @@ jobs: docker: - image: debian:stretch steps: - - checkout-shallow + - get-workspace - install-doc-deps - build-dnsdist-docs - add-docs-upload-ssh @@ -978,7 +993,7 @@ jobs: steps: - install-auth-dev-deps - install-coverity-tools - - checkout-shallow + - get-workspace - run: name: autoconf command: BUILDER_VERSION=0.0.0-git1 autoreconf -vfi @@ -1048,7 +1063,7 @@ jobs: ragel \ virtualenv - install-coverity-tools - - checkout-shallow + - get-workspace - run: name: autoconf command: BUILDER_VERSION=0.0.0-git1 autoreconf -vfi @@ -1120,7 +1135,7 @@ jobs: ragel \ virtualenv - install-coverity-tools - - checkout-shallow + - get-workspace - run: name: autoconf command: BUILDER_VERSION=0.0.0-git1 autoreconf -vfi @@ -1195,7 +1210,7 @@ jobs: ragel \ systemd \ virtualenv - - checkout-shallow + - get-workspace - run: name: autoconf command: BUILDER_VERSION=0.0.0-git1 autoreconf -vfi @@ -1247,15 +1262,13 @@ jobs: UBSAN_OPTIONS: 'print_stacktrace=1:halt_on_error=1' steps: - install-dnsdist-deps - - checkout-shallow + - get-workspace - run: name: setup snmp command: | apt-get -qq --no-install-recommends install snmpd sed "s/agentxperms 0700 0755 dnsdist/agentxperms 0700 0755/g" regression-tests.dnsdist/snmpd.conf > /etc/snmp/snmpd.conf /etc/init.d/snmpd start - - attach_workspace: - at: /opt - run: name: Run dnsdist tests workdir: ~/project/regression-tests.dnsdist @@ -1270,9 +1283,7 @@ jobs: UBSAN_OPTIONS: 'print_stacktrace=1:halt_on_error=1' steps: - install-ixfrdist-deps - - checkout-shallow - - attach_workspace: - at: /opt + - get-workspace - run: name: Run ixfrdist tests workdir: ~/project/regression-tests.ixfrdist @@ -1299,7 +1310,10 @@ workflows: build-and-test-all: jobs: - - build-auth + - checkout + - build-auth: + requires: + - checkout - test-auth-api: requires: - build-auth @@ -1336,7 +1350,9 @@ workflows: - test-auth-regress-tinydns: requires: - build-auth - - build-recursor + - build-recursor: + requires: + - checkout - test-recursor-regression: requires: - build-recursor @@ -1346,7 +1362,9 @@ workflows: - test-recursor-api: requires: - build-recursor - - build-dnsdist + - build-dnsdist: + requires: + - checkout - test-dnsdist-regression: requires: - build-dnsdist @@ -1356,18 +1374,25 @@ workflows: build-docs: jobs: + - checkout - build-auth-docs: filters: branches: ignore: master + requires: + - checkout - build-recursor-docs: filters: branches: ignore: master + requires: + - checkout - build-dnsdist-docs: filters: branches: ignore: master + requires: + - checkout # These actually deploy - deploy-auth-docs: @@ -1375,13 +1400,19 @@ workflows: filters: branches: only: master + requires: + - checkout - deploy-recursor-docs: context: docs filters: branches: only: master + requires: + - checkout - deploy-dnsdist-docs: context: docs filters: branches: only: master + requires: + - checkout -- 2.40.0