2019-03-14 21:57:50 +01:00
|
|
|
version: 2.0
|
|
|
|
workflows:
|
|
|
|
version: 2
|
|
|
|
build:
|
|
|
|
jobs:
|
|
|
|
- build-1.11
|
|
|
|
- build-1.12
|
2019-09-03 14:45:18 +02:00
|
|
|
- build-1.13
|
2020-03-27 00:23:10 +01:00
|
|
|
- build-1.14
|
2019-03-14 21:57:50 +01:00
|
|
|
- build-latest
|
2019-11-20 20:57:50 +01:00
|
|
|
- test-build-in-docker
|
2019-03-14 21:57:50 +01:00
|
|
|
jobs:
|
2019-11-20 20:57:50 +01:00
|
|
|
|
2019-03-14 21:57:50 +01:00
|
|
|
# build-latest serves as the template
|
|
|
|
# we use YAML anchors & aliases to exchange the docker image (and hence Go version used for the build)
|
|
|
|
build-latest: &build-latest
|
|
|
|
description: Builds zrepl
|
|
|
|
parameters:
|
|
|
|
image:
|
|
|
|
description: "the docker image that the job should use"
|
|
|
|
type: string
|
|
|
|
docker:
|
|
|
|
- image: circleci/golang:latest
|
|
|
|
environment:
|
|
|
|
# required by lazy.sh
|
|
|
|
TERM: xterm
|
|
|
|
working_directory: /go/src/github.com/zrepl/zrepl
|
|
|
|
steps:
|
|
|
|
- run:
|
|
|
|
name: Setup environment variables
|
|
|
|
command: |
|
|
|
|
# used by pip (for docs)
|
|
|
|
echo 'export PATH="$HOME/.local/bin:$PATH"' >> $BASH_ENV
|
2019-09-03 14:45:18 +02:00
|
|
|
# we use modules
|
|
|
|
echo 'export GO111MODULE=on' >> $BASH_ENV
|
2019-03-14 21:57:50 +01:00
|
|
|
|
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- source
|
|
|
|
- protobuf
|
|
|
|
|
|
|
|
- checkout
|
|
|
|
|
|
|
|
- save_cache:
|
|
|
|
key: source
|
|
|
|
paths:
|
|
|
|
- ".git"
|
|
|
|
|
|
|
|
# install deps
|
|
|
|
- run: wget https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip
|
|
|
|
- run: echo "6003de742ea3fcf703cfec1cd4a3380fd143081a2eb0e559065563496af27807 protoc-3.6.1-linux-x86_64.zip" | sha256sum -c
|
|
|
|
- run: sudo unzip -d /usr protoc-3.6.1-linux-x86_64.zip
|
|
|
|
- save_cache:
|
|
|
|
key: protobuf
|
|
|
|
paths:
|
|
|
|
- "/usr/include/google/protobuf"
|
|
|
|
|
2019-10-20 20:05:46 +02:00
|
|
|
- run: sudo apt update && sudo apt install python3 python3-pip libgirepository1.0-dev gawk
|
2019-03-14 21:57:50 +01:00
|
|
|
- run: ./lazy.sh devsetup
|
|
|
|
|
2019-10-28 16:16:16 +01:00
|
|
|
- run: make zrepl-bin
|
2019-03-14 21:57:50 +01:00
|
|
|
- run: make vet
|
2019-03-27 13:04:38 +01:00
|
|
|
- run: make lint
|
2019-03-14 21:57:50 +01:00
|
|
|
- run: make release
|
2020-05-24 17:43:42 +02:00
|
|
|
- run: make test-go
|
|
|
|
# cannot run test-platform because circle-ci runs in linux containers
|
2019-03-28 13:34:07 +01:00
|
|
|
|
2019-03-14 21:57:50 +01:00
|
|
|
- store_artifacts:
|
|
|
|
path: ./artifacts/release
|
|
|
|
when: always
|
|
|
|
|
2019-03-28 13:34:07 +01:00
|
|
|
- run:
|
2019-07-28 10:10:17 +02:00
|
|
|
shell: /bin/bash -eo pipefail
|
2019-03-28 13:34:07 +01:00
|
|
|
when: always
|
|
|
|
command: |
|
2019-07-28 10:10:17 +02:00
|
|
|
if [ -n "$CIRCLE_PR_NUMBER" ]; then # CIRCLE_PR_NUMBER is guaranteed to be only present in forked PRs (external)
|
|
|
|
echo "Forked PR detected. Sry, can't trust you with credentials to external artifact store, use CircleCI's instead."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
set -u # from now on
|
|
|
|
|
|
|
|
# Download and install minio
|
|
|
|
curl -sSL https://dl.minio.io/client/mc/release/linux-amd64/mc -o ${GOPATH}/bin/mc
|
|
|
|
chmod +x ${GOPATH}/bin/mc
|
|
|
|
mc config host add --api s3v4 zrepl-minio https://minio.cschwarz.com ${MINIO_ACCESS_KEY} ${MINIO_SECRET_KEY}
|
|
|
|
|
|
|
|
# Upload artifacts
|
2019-03-28 13:34:07 +01:00
|
|
|
echo "$CIRCLE_BUILD_URL" > ./artifacts/release/cirlceci_build_url
|
2019-07-14 18:23:36 +02:00
|
|
|
mc cp -r artifacts/release "zrepl-minio/zrepl-ci-artifacts/${CIRCLE_SHA1}/${CIRCLE_JOB}/"
|
2019-07-28 10:10:17 +02:00
|
|
|
|
|
|
|
# Push Artifact Link to GitHub
|
2019-03-28 13:34:07 +01:00
|
|
|
REPO="zrepl/zrepl"
|
|
|
|
COMMIT="${CIRCLE_SHA1}"
|
|
|
|
JOB_NAME="${CIRCLE_JOB}"
|
2020-04-18 21:56:53 +02:00
|
|
|
curl "https://api.github.com/repos/$REPO/statuses/$COMMIT" \
|
2019-03-28 13:34:07 +01:00
|
|
|
-H "Content-Type: application/json" \
|
2020-04-18 21:56:53 +02:00
|
|
|
-H "Authorization: token $GITHUB_COMMIT_STATUS_TOKEN" \
|
2019-03-28 13:34:07 +01:00
|
|
|
-X POST \
|
|
|
|
-d '{"context":"zrepl/publish-ci-artifacts", "state": "success", "description":"CI Build Artifacts for '"$JOB_NAME"'", "target_url":"https://minio.cschwarz.com/minio/zrepl-ci-artifacts/'"$COMMIT"'/"}'
|
|
|
|
|
2020-07-26 13:41:53 +02:00
|
|
|
# kick off binary packaging workflow
|
2020-04-18 22:14:29 +02:00
|
|
|
- run:
|
2020-07-26 13:41:53 +02:00
|
|
|
shell: /bin/bash -eo pipefail
|
2020-04-18 22:14:29 +02:00
|
|
|
command: |
|
2020-07-26 13:41:53 +02:00
|
|
|
if [ -n "$CIRCLE_PR_NUMBER" ]; then # CIRCLE_PR_NUMBER is guaranteed to be only present in forked PRs (external)
|
|
|
|
echo "Forked PR detected. Sry, can't trust you with credentials."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
set -u # from now on
|
|
|
|
GITHUB_ACCESS_TOKEN="$ZREPL_DEBIAN_BINARYPACKAGIN_TRIGGER_BUILD_GITHUB_TOKEN" .circleci/trigger_debian_binary_packaging_workflow.bash "$CIRCLE_SHA1" "${CIRCLE_JOB##build-}"
|
2020-04-18 22:14:29 +02:00
|
|
|
|
2019-03-14 21:57:50 +01:00
|
|
|
build-1.11:
|
|
|
|
<<: *build-latest
|
|
|
|
docker:
|
2019-09-03 14:45:18 +02:00
|
|
|
- image: circleci/golang:1.11
|
|
|
|
|
2019-03-14 21:57:50 +01:00
|
|
|
build-1.12:
|
|
|
|
<<: *build-latest
|
|
|
|
docker:
|
|
|
|
- image: circleci/golang:1.12
|
2019-09-03 14:45:18 +02:00
|
|
|
|
|
|
|
build-1.13:
|
|
|
|
<<: *build-latest
|
|
|
|
docker:
|
|
|
|
- image: circleci/golang:1.13
|
2019-11-20 20:57:50 +01:00
|
|
|
|
2020-03-27 00:23:10 +01:00
|
|
|
build-1.14:
|
|
|
|
<<: *build-latest
|
|
|
|
docker:
|
|
|
|
- image: circleci/golang:1.14
|
|
|
|
|
2019-11-20 20:57:50 +01:00
|
|
|
# this job tries to mimic the build-in-docker instructions
|
|
|
|
# given in docs/installation.rst
|
|
|
|
#
|
|
|
|
# However, CircleCI doesn't support volume mounts, so we have to copy
|
|
|
|
# the source into the build-container by modifying the Dockerfile
|
|
|
|
test-build-in-docker:
|
|
|
|
description: Check that build-in-docker works
|
|
|
|
docker:
|
|
|
|
- image: circleci/golang:latest
|
|
|
|
environment:
|
|
|
|
working_directory: /go/src/github.com/zrepl/zrepl
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- setup_remote_docker
|
|
|
|
- run:
|
|
|
|
name: (hacky) circleci doesn't allow volume mounts, so copy src to container
|
|
|
|
command: echo "ADD . /src" >> build.Dockerfile
|
|
|
|
- run:
|
|
|
|
name: (hacky) commit modified Dockerfile to avoid failing git clean check in Makefile
|
|
|
|
command: git -c user.name='circleci' -c user.email='circleci@localhost' commit -m 'CIRCLECI modified Dockerfile with zrepl src' --author 'autoauthor <circleci@localhost>' -- build.Dockerfile
|
|
|
|
- run:
|
|
|
|
name: build the build image (build deps)
|
|
|
|
command: docker build -t zrepl_build -f build.Dockerfile .
|
|
|
|
- run:
|
|
|
|
name: try compiling
|
|
|
|
command: docker run -it zrepl_build make release
|