2020-09-02 21:34:52 +02:00
|
|
|
version: 2.1
|
2019-11-20 20:57:50 +01:00
|
|
|
|
2020-09-02 21:34:52 +02:00
|
|
|
commands:
|
|
|
|
setup-home-local-bin:
|
2019-03-14 21:57:50 +01:00
|
|
|
steps:
|
|
|
|
- run:
|
2020-09-02 21:34:52 +02:00
|
|
|
shell: /bin/bash -euo pipefail
|
2019-03-14 21:57:50 +01:00
|
|
|
command: |
|
2020-09-02 21:34:52 +02:00
|
|
|
mkdir -p "$HOME/.local/bin"
|
|
|
|
line='export PATH="$HOME/.local/bin:$PATH"'
|
|
|
|
if grep "$line" $BASH_ENV >/dev/null; then
|
|
|
|
echo "$line" >> $BASH_ENV
|
|
|
|
fi
|
2019-03-14 21:57:50 +01:00
|
|
|
|
2020-09-02 21:34:52 +02:00
|
|
|
invoke-lazy-sh:
|
|
|
|
parameters:
|
|
|
|
subcommand:
|
|
|
|
type: string
|
|
|
|
steps:
|
|
|
|
- run:
|
|
|
|
environment:
|
|
|
|
TERM: xterm
|
|
|
|
command: ./lazy.sh <<parameters.subcommand>>
|
2019-03-14 21:57:50 +01:00
|
|
|
|
2020-09-02 21:34:52 +02:00
|
|
|
apt-update-and-install-common-deps:
|
|
|
|
steps:
|
|
|
|
- run: sudo apt update && sudo apt install gawk make
|
2019-03-14 21:57:50 +01:00
|
|
|
|
2020-09-02 21:34:52 +02:00
|
|
|
restore-cache-gomod:
|
|
|
|
steps:
|
|
|
|
- restore_cache:
|
|
|
|
key: go-mod-v4-{{ checksum "go.sum" }}
|
|
|
|
save-cache-gomod:
|
|
|
|
steps:
|
2019-03-14 21:57:50 +01:00
|
|
|
- save_cache:
|
2020-09-02 21:34:52 +02:00
|
|
|
key: go-mod-v4-{{ checksum "go.sum" }}
|
2019-03-14 21:57:50 +01:00
|
|
|
paths:
|
2020-09-02 21:34:52 +02:00
|
|
|
- "/go/pkg/mod"
|
|
|
|
|
|
|
|
install-godep:
|
|
|
|
steps:
|
|
|
|
- apt-update-and-install-common-deps
|
|
|
|
- invoke-lazy-sh:
|
|
|
|
subcommand: godep
|
|
|
|
|
|
|
|
install-docdep:
|
|
|
|
steps:
|
|
|
|
- apt-update-and-install-common-deps
|
|
|
|
- run: sudo apt install python3 python3-pip libgirepository1.0-dev
|
|
|
|
- invoke-lazy-sh:
|
|
|
|
subcommand: docdep
|
|
|
|
|
|
|
|
download-and-install-minio-client:
|
|
|
|
steps:
|
|
|
|
- setup-home-local-bin
|
|
|
|
- restore_cache:
|
|
|
|
key: minio-client-v2
|
|
|
|
- run:
|
|
|
|
shell: /bin/bash -eo pipefail
|
|
|
|
command: |
|
|
|
|
if which mc; then exit 0; fi
|
|
|
|
sudo curl -sSL https://dl.min.io/client/mc/release/linux-amd64/archive/mc.RELEASE.2020-08-20T00-23-01Z \
|
|
|
|
-o "$HOME/.local/bin/mc"
|
|
|
|
sudo chmod +x "$HOME/.local/bin/mc"
|
2019-03-14 21:57:50 +01:00
|
|
|
- save_cache:
|
2020-09-02 21:34:52 +02:00
|
|
|
key: minio-client-v2
|
2019-03-14 21:57:50 +01:00
|
|
|
paths:
|
2020-09-02 21:34:52 +02:00
|
|
|
- "$HOME/.local/bin/mc"
|
2019-03-14 21:57:50 +01:00
|
|
|
|
2020-09-02 21:34:52 +02:00
|
|
|
upload-minio:
|
|
|
|
parameters:
|
|
|
|
src:
|
|
|
|
type: string
|
|
|
|
dst:
|
|
|
|
type: string
|
|
|
|
steps:
|
2020-08-31 15:56:40 +02:00
|
|
|
- run:
|
2020-09-02 21:34:52 +02:00
|
|
|
shell: /bin/bash -eo pipefail
|
|
|
|
when: always
|
2020-08-31 15:56:40 +02:00
|
|
|
command: |
|
2020-09-02 21:34:52 +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
|
2020-08-31 15:56:40 +02:00
|
|
|
fi
|
2020-09-02 21:34:52 +02:00
|
|
|
set -u # from now on
|
2019-03-28 13:34:07 +01:00
|
|
|
|
2020-09-02 21:34:52 +02:00
|
|
|
mc config host add --api s3v4 zrepl-minio https://minio.cschwarz.com ${MINIO_ACCESS_KEY} ${MINIO_SECRET_KEY}
|
|
|
|
|
|
|
|
# keep in sync with set-github-minio-status
|
2020-09-06 17:22:23 +02:00
|
|
|
jobprefix=zrepl-ci-artifacts/${CIRCLE_SHA1}-pipeline-<<pipeline.number>>/${CIRCLE_JOB}
|
2019-03-14 21:57:50 +01:00
|
|
|
|
2020-09-02 21:34:52 +02:00
|
|
|
# Upload artifacts
|
|
|
|
mkdir -p ./artifacts
|
|
|
|
mc cp -r <<parameters.src>> "zrepl-minio/$jobprefix/<<parameters.dst>>"
|
|
|
|
|
|
|
|
set-github-minio-status:
|
|
|
|
parameters:
|
|
|
|
context:
|
|
|
|
type: string
|
|
|
|
description:
|
|
|
|
type: string
|
|
|
|
minio-dst:
|
|
|
|
type: string
|
|
|
|
steps:
|
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
|
|
|
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
|
|
|
|
|
2020-09-02 21:34:52 +02:00
|
|
|
# keep in sync with with upload-minio command
|
2020-09-06 17:22:23 +02:00
|
|
|
jobprefix=zrepl-ci-artifacts/${CIRCLE_SHA1}-pipeline-<<pipeline.number>>/${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-09-02 21:34:52 +02:00
|
|
|
CONTEXT="<<parameters.context>>"
|
|
|
|
DESCRIPTION="<<parameters.description>>"
|
|
|
|
TARGETURL=https://minio.cschwarz.com/minio/"$jobprefix"/"<<parameters.minio-dst>>"
|
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 \
|
2020-09-02 21:34:52 +02:00
|
|
|
-d '{"context":"'"$CONTEXT"'", "state": "success", "description":"'"$DESCRIPTION"'", "target_url":"'"$TARGETURL"'"}'
|
2019-03-28 13:34:07 +01:00
|
|
|
|
2020-04-18 22:14:29 +02:00
|
|
|
|
2020-09-06 15:46:53 +02:00
|
|
|
trigger-pipeline:
|
|
|
|
parameters:
|
|
|
|
body_no_shell_subst:
|
|
|
|
type: string
|
|
|
|
steps:
|
|
|
|
- run: |
|
|
|
|
curl -X POST https://circleci.com/api/v2/project/github/zrepl/zrepl/pipeline \
|
|
|
|
-H 'Content-Type: application/json' \
|
|
|
|
-H 'Accept: application/json' \
|
|
|
|
-H "Circle-Token: $ZREPL_BOT_CIRCLE_TOKEN" \
|
|
|
|
--data '<<parameters.body_no_shell_subst>>'
|
2020-09-06 15:39:34 +02:00
|
|
|
|
2020-09-06 15:46:53 +02:00
|
|
|
parameters:
|
2020-09-06 15:39:34 +02:00
|
|
|
do_ci:
|
|
|
|
type: boolean
|
|
|
|
default: true
|
|
|
|
|
|
|
|
do_release:
|
|
|
|
type: boolean
|
|
|
|
default: false
|
|
|
|
|
|
|
|
release_docker_baseimage_tag:
|
|
|
|
type: string
|
2021-10-09 16:17:20 +02:00
|
|
|
default: "1.17"
|
2020-09-02 21:34:52 +02:00
|
|
|
|
|
|
|
workflows:
|
|
|
|
version: 2
|
2020-09-06 15:39:34 +02:00
|
|
|
|
|
|
|
ci:
|
|
|
|
when: << pipeline.parameters.do_ci >>
|
2020-09-02 21:34:52 +02:00
|
|
|
jobs:
|
|
|
|
- quickcheck-docs
|
|
|
|
- quickcheck-go: &quickcheck-go-smoketest
|
2021-10-09 16:17:20 +02:00
|
|
|
name: quickcheck-go-amd64-linux-1.17
|
|
|
|
goversion: &latest-go-release "1.17"
|
2020-09-02 21:34:52 +02:00
|
|
|
goos: linux
|
|
|
|
goarch: amd64
|
|
|
|
- test-go-on-latest-go-release:
|
|
|
|
goversion: *latest-go-release
|
|
|
|
- quickcheck-go:
|
|
|
|
requires:
|
2021-10-09 16:17:20 +02:00
|
|
|
- quickcheck-go-amd64-linux-1.17 #quickcheck-go-smoketest.name
|
2020-09-02 21:34:52 +02:00
|
|
|
matrix: &quickcheck-go-matrix
|
|
|
|
alias: quickcheck-go-matrix
|
|
|
|
parameters:
|
2021-01-24 23:31:45 +01:00
|
|
|
goversion: [*latest-go-release, "1.12"]
|
2020-09-02 21:34:52 +02:00
|
|
|
goos: ["linux", "freebsd"]
|
|
|
|
goarch: ["amd64", "arm64"]
|
|
|
|
exclude:
|
|
|
|
# don't re-do quickcheck-go-smoketest
|
|
|
|
- goversion: *latest-go-release
|
|
|
|
goos: linux
|
|
|
|
goarch: amd64
|
2021-01-24 23:31:45 +01:00
|
|
|
# not supported by Go 1.12
|
|
|
|
- goversion: "1.12"
|
2020-09-02 21:34:52 +02:00
|
|
|
goos: freebsd
|
|
|
|
goarch: arm64
|
|
|
|
|
2020-09-06 15:39:34 +02:00
|
|
|
release:
|
|
|
|
when: << pipeline.parameters.do_release >>
|
|
|
|
jobs:
|
|
|
|
- release-build
|
2020-09-02 21:34:52 +02:00
|
|
|
- release-deb:
|
|
|
|
requires:
|
|
|
|
- release-build
|
|
|
|
- release-rpm:
|
|
|
|
requires:
|
|
|
|
- release-build
|
|
|
|
- release-upload:
|
|
|
|
requires:
|
|
|
|
- release-build
|
|
|
|
- release-deb
|
|
|
|
- release-rpm
|
|
|
|
|
2020-09-06 15:46:53 +02:00
|
|
|
periodic:
|
|
|
|
triggers:
|
|
|
|
- schedule:
|
2020-11-04 17:53:54 +01:00
|
|
|
cron: "00 17 * * *"
|
2020-09-06 15:46:53 +02:00
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only:
|
|
|
|
- master
|
|
|
|
- stable
|
|
|
|
- problame/circleci-build
|
|
|
|
jobs:
|
2020-11-04 17:53:54 +01:00
|
|
|
- periodic-full-pipeline-run
|
2020-09-06 15:46:53 +02:00
|
|
|
|
2020-09-12 12:28:32 +02:00
|
|
|
zrepl.github.io:
|
|
|
|
jobs:
|
|
|
|
- publish-zrepl-github-io:
|
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only:
|
|
|
|
- stable
|
|
|
|
|
2020-09-02 21:34:52 +02:00
|
|
|
jobs:
|
|
|
|
quickcheck-docs:
|
2019-03-14 21:57:50 +01:00
|
|
|
docker:
|
2020-09-02 21:34:52 +02:00
|
|
|
- image: cimg/base:2020.08
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- install-docdep
|
|
|
|
- run: make docs
|
2019-09-03 14:45:18 +02:00
|
|
|
|
2020-09-06 17:27:49 +02:00
|
|
|
- download-and-install-minio-client
|
|
|
|
- upload-minio:
|
|
|
|
src: artifacts
|
|
|
|
dst: ""
|
|
|
|
- set-github-minio-status:
|
|
|
|
context: artifacts/${CIRCLE_JOB}
|
|
|
|
description: artifacts of CI job ${CIRCLE_JOB}
|
|
|
|
minio-dst: ""
|
|
|
|
|
2020-09-02 21:34:52 +02:00
|
|
|
quickcheck-go:
|
|
|
|
parameters:
|
|
|
|
goversion:
|
|
|
|
type: string
|
|
|
|
goos:
|
|
|
|
type: string
|
|
|
|
goarch:
|
|
|
|
type: string
|
2019-03-14 21:57:50 +01:00
|
|
|
docker:
|
2020-09-02 21:34:52 +02:00
|
|
|
- image: circleci/golang:<<parameters.goversion>>
|
|
|
|
environment:
|
|
|
|
GOOS: <<parameters.goos>>
|
|
|
|
GOARCH: <<parameters.goarch>>
|
2019-09-03 14:45:18 +02:00
|
|
|
|
2020-09-02 21:34:52 +02:00
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
|
|
|
|
- restore-cache-gomod
|
|
|
|
- run: go mod download
|
|
|
|
- run: cd build && go mod download
|
|
|
|
- save-cache-gomod
|
|
|
|
|
|
|
|
- install-godep
|
|
|
|
- run: make formatcheck
|
|
|
|
- run: make generate-platform-test-list
|
|
|
|
- run: make zrepl-bin test-platform-bin
|
|
|
|
- run: make vet
|
|
|
|
- run: make lint
|
|
|
|
|
|
|
|
- download-and-install-minio-client
|
|
|
|
- run: rm -f artifacts/generate-platform-test-list
|
|
|
|
- store_artifacts:
|
|
|
|
path: artifacts
|
|
|
|
- upload-minio:
|
|
|
|
src: artifacts
|
|
|
|
dst: ""
|
|
|
|
- set-github-minio-status:
|
|
|
|
context: artifacts/${CIRCLE_JOB}
|
|
|
|
description: artifacts of CI job ${CIRCLE_JOB}
|
|
|
|
minio-dst: ""
|
|
|
|
|
|
|
|
test-go-on-latest-go-release:
|
|
|
|
parameters:
|
|
|
|
goversion:
|
|
|
|
type: string
|
2019-09-03 14:45:18 +02:00
|
|
|
docker:
|
2020-09-02 21:34:52 +02:00
|
|
|
- image: circleci/golang:<<parameters.goversion>>
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- restore-cache-gomod
|
|
|
|
- run: make test-go
|
|
|
|
# don't save-cache-gomod here, test-go doesn't pull all the dependencies
|
2019-11-20 20:57:50 +01:00
|
|
|
|
2020-09-02 21:34:52 +02:00
|
|
|
release-build:
|
2022-02-15 22:55:25 +01:00
|
|
|
machine:
|
|
|
|
image: ubuntu-2004:202201-02
|
2020-09-02 21:34:52 +02:00
|
|
|
steps:
|
|
|
|
- checkout
|
2020-09-06 15:39:34 +02:00
|
|
|
- run: make release-docker RELEASE_DOCKER_BASEIMAGE_TAG=<<pipeline.parameters.release_docker_baseimage_tag>>
|
2020-09-02 21:34:52 +02:00
|
|
|
- persist_to_workspace:
|
|
|
|
root: .
|
|
|
|
paths: [.]
|
|
|
|
release-deb:
|
2022-02-15 22:55:25 +01:00
|
|
|
machine:
|
|
|
|
image: ubuntu-2004:202201-02
|
2020-09-02 21:34:52 +02:00
|
|
|
steps:
|
|
|
|
- attach_workspace:
|
|
|
|
at: .
|
|
|
|
- run: make debs-docker
|
|
|
|
- persist_to_workspace:
|
|
|
|
root: .
|
|
|
|
paths:
|
|
|
|
- "artifacts/*.deb"
|
|
|
|
|
|
|
|
release-rpm:
|
2022-02-15 22:55:25 +01:00
|
|
|
machine:
|
|
|
|
image: ubuntu-2004:202201-02
|
2020-09-02 21:34:52 +02:00
|
|
|
steps:
|
|
|
|
- attach_workspace:
|
|
|
|
at: .
|
|
|
|
- run: make rpms-docker
|
|
|
|
- persist_to_workspace:
|
|
|
|
root: .
|
|
|
|
paths:
|
|
|
|
- "artifacts/*.rpm"
|
|
|
|
|
|
|
|
release-upload:
|
2020-03-27 00:23:10 +01:00
|
|
|
docker:
|
2020-09-02 21:34:52 +02:00
|
|
|
- image: cimg/base:2020.08
|
|
|
|
steps:
|
|
|
|
- attach_workspace:
|
|
|
|
at: .
|
|
|
|
- store_artifacts:
|
|
|
|
path: artifacts
|
|
|
|
- download-and-install-minio-client
|
|
|
|
- upload-minio:
|
|
|
|
src: artifacts
|
|
|
|
dst: ""
|
|
|
|
- set-github-minio-status:
|
|
|
|
context: artifacts/release
|
|
|
|
description: CI-generated release artifacts
|
|
|
|
minio-dst: ""
|
2020-09-06 15:46:53 +02:00
|
|
|
|
2020-11-04 17:53:54 +01:00
|
|
|
periodic-full-pipeline-run:
|
2020-09-06 15:46:53 +02:00
|
|
|
docker:
|
|
|
|
- image: cimg/base:2020.08
|
|
|
|
steps:
|
|
|
|
- trigger-pipeline:
|
2020-11-04 17:53:54 +01:00
|
|
|
body_no_shell_subst: '{"branch":"<<pipeline.git.branch>>", "parameters": { "do_ci": true, "do_release": true }}'
|
2020-09-12 12:28:32 +02:00
|
|
|
|
|
|
|
publish-zrepl-github-io:
|
|
|
|
docker:
|
|
|
|
- image: cimg/python:3.7
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- invoke-lazy-sh:
|
|
|
|
subcommand: docdep
|
|
|
|
- run:
|
|
|
|
command: |
|
2021-07-08 16:52:11 +02:00
|
|
|
git config --global user.email "zreplbot@cschwarz.com"
|
2020-09-12 12:28:32 +02:00
|
|
|
git config --global user.name "zrepl-github-io-ci"
|
|
|
|
|
|
|
|
# https://circleci.com/docs/2.0/add-ssh-key/#adding-multiple-keys-with-blank-hostnames
|
|
|
|
- run: ssh-add -D
|
|
|
|
# the default circleci ssh config only additional ssh keys for Host !github.com
|
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
cat > ~/.ssh/config \<<EOF
|
|
|
|
Host *
|
|
|
|
IdentityFile /home/circleci/.ssh/id_rsa_458e62c517f6c480e40452126ce47421
|
|
|
|
EOF
|
|
|
|
- add_ssh_keys:
|
|
|
|
fingerprints:
|
|
|
|
# deploy key for zrepl.github.io
|
|
|
|
- "45:8e:62:c5:17:f6:c4:80:e4:04:52:12:6c:e4:74:21"
|
|
|
|
|
|
|
|
- run: bash -x docs/publish.sh -c -a
|