diff --git a/.circleci/config.yml b/.circleci/config.yml index 3c58063..39c23bf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -59,6 +59,7 @@ jobs: - run: ./lazy.sh devsetup - run: make zrepl-bin + - run: make test-platform-bin - run: make vet - run: make lint - run: make release @@ -98,6 +99,30 @@ jobs: -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"'/"}' + - run: + shell: /bin/bash -eo pipefail + when: always + command: | + 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 + + # Trigger Platform Tests + # ZREPL_BOT_GIT_PRWN_EU_ACCESS_TOKEN from secrets + ## Sync this commit to the GitLab + git remote add prwn-gitlab "https://zrepl-bot:$ZREPL_BOT_GIT_PRWN_EU_ACCESS_TOKEN@git.prwn.eu/problame/zrepl.git" + REMOTE_REF=circleci/$CIRCLE_BRANCH/$CIRCLE_BUILD_NUM + git push -f prwn-gitlab "HEAD:$REMOTE_REF" + ## Trigger Tests + curl -v --request POST \ + --header "PRIVATE-TOKEN: $ZREPL_BOT_GIT_PRWN_EU_ACCESS_TOKEN" \ + --header "Content-Type: application/json" \ + --data '{ "ref":"'"$REMOTE_REF"'", "variables": [ {"key":"ZREPL_MAIN_REPO_COMMIT", "value": "'"$CIRCLE_SHA1"'" }, { "key":"ZREPL_CI_BUILDJOB", "value": "'"$CIRCLE_JOB"'" } ] } ' \ + "https://git.prwn.eu/api/v4/projects/13/pipeline" + + - run: shell: /bin/bash -euo pipefail command: | diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..488d704 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,16 @@ +build-and-run-platformtests: + variables: + GIT_STRATEGY: none + script: + - mkdir artifacts + # platformtests are installed by the CI environment + - /opt/platformtest-linux-amd64 + -test.coverprofile artifacts/platformtest.cover + -test.v + __DEVEL--i-heard-you-like-tests + -poolname zreplplatformtest + -imagepath /tmp/zreplplatformtest.pool.img + -mountpoint /tmp/zreplplatformtest.pool + artifacts: + paths: + - artifacts diff --git a/.platformtest-ci/download_ci_file.bash b/.platformtest-ci/download_ci_file.bash new file mode 100755 index 0000000..f42aab8 --- /dev/null +++ b/.platformtest-ci/download_ci_file.bash @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -euo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")" + +commit="$1" +build="$2" +src="$3" +dst="$4" + +[ -n "$commit" -a -n "$build" -a -n "$src" -a -n "$dst" ] || ( echo "arguments must not be empty"; exit 1 ) + +aws="aws --endpoint-url https://minio.cschwarz.com --no-sign-request" + + +path="s3://zrepl-ci-artifacts/$commit/$build/$src" +$aws s3 cp "$path" "$dst"