2020-06-18 14:49:13 +07:00
|
|
|
#!/usr/bin/env bash
|
2020-03-09 08:32:07 +07:00
|
|
|
set -u
|
|
|
|
|
2020-03-21 20:42:29 +07:00
|
|
|
DIVERGED=$(git merge-base --fork-point origin/master > /dev/null; echo $?)
|
|
|
|
|
2021-06-26 08:45:21 +07:00
|
|
|
if [[ "${DIVERGED}" == 0 ]]; then
|
|
|
|
if [[ "${BUILDKITE_TAG}" == "" ]]; then
|
|
|
|
if [[ "${BUILDKITE_BRANCH}" == "master" ]]; then
|
2022-06-05 00:51:33 +07:00
|
|
|
BUILD_DUO=$(git diff --name-only HEAD~1 | grep -q ^internal/suites/example/compose/duo-api/Dockerfile && echo true || echo false)
|
2022-06-04 16:38:13 +07:00
|
|
|
BUILD_HAPROXY=$(git diff --name-only HEAD~1 | grep -q ^internal/suites/example/compose/haproxy/Dockerfile && echo true || echo false)
|
2022-06-05 00:51:33 +07:00
|
|
|
BUILD_SAMBA=$(git diff --name-only HEAD~1 | grep -q ^internal/suites/example/compose/samba/Dockerfile && echo true || echo false)
|
2022-05-24 19:28:45 +07:00
|
|
|
CI_BYPASS=$(git diff --name-only HEAD~1 | sed -rn '/^(CODE_OF_CONDUCT\.md|CONTRIBUTING\.md|README\.md|SECURITY\.md|crowdin\.yml|\.all-contributorsrc|\.editorconfig|\.github\/.*|docs\/.*|examples\/.*)/!{q1}' && echo true || echo false)
|
2020-03-21 20:42:29 +07:00
|
|
|
else
|
2022-06-05 00:51:33 +07:00
|
|
|
BUILD_DUO=$(git diff --name-only `git merge-base --fork-point origin/master` | grep -q ^internal/suites/example/compose/duo-api/Dockerfile && echo true || echo false)
|
2022-06-04 16:38:13 +07:00
|
|
|
BUILD_HAPROXY=$(git diff --name-only `git merge-base --fork-point origin/master` | grep -q ^internal/suites/example/compose/haproxy/Dockerfile && echo true || echo false)
|
2022-06-05 00:51:33 +07:00
|
|
|
BUILD_SAMBA=$(git diff --name-only `git merge-base --fork-point origin/master` | grep -q ^internal/suites/example/compose/samba/Dockerfile && echo true || echo false)
|
2022-05-24 19:28:45 +07:00
|
|
|
CI_BYPASS=$(git diff --name-only `git merge-base --fork-point origin/master` | sed -rn '/^(CODE_OF_CONDUCT\.md|CONTRIBUTING\.md|README\.md|SECURITY\.md|crowdin\.yml|\.all-contributorsrc|\.editorconfig|\.github\/.*|docs\/.*|examples\/.*)/!{q1}' && echo true || echo false)
|
2020-03-21 20:42:29 +07:00
|
|
|
fi
|
|
|
|
|
2022-06-04 16:38:13 +07:00
|
|
|
if [[ "${CI_BYPASS}" == "true" ]]; then
|
2020-04-01 05:44:57 +07:00
|
|
|
cat .buildkite/annotations/bypass | buildkite-agent annotate --style "info" --context "ctx-info"
|
2020-03-21 20:42:29 +07:00
|
|
|
fi
|
2020-03-15 17:07:23 +07:00
|
|
|
else
|
2022-06-04 16:38:13 +07:00
|
|
|
BUILD_DUO="false"
|
|
|
|
BUILD_HAPROXY="false"
|
2022-06-05 00:51:33 +07:00
|
|
|
BUILD_SAMBA="false"
|
2020-04-01 05:44:57 +07:00
|
|
|
CI_BYPASS="false"
|
2020-03-15 17:07:23 +07:00
|
|
|
fi
|
2020-03-15 18:01:52 +07:00
|
|
|
else
|
2022-06-04 16:38:13 +07:00
|
|
|
BUILD_DUO="false"
|
|
|
|
BUILD_HAPROXY="false"
|
2022-06-05 00:51:33 +07:00
|
|
|
BUILD_SAMBA="false"
|
2020-04-01 05:44:57 +07:00
|
|
|
CI_BYPASS="false"
|
2020-03-11 06:25:47 +07:00
|
|
|
fi
|
|
|
|
|
2020-03-09 08:32:07 +07:00
|
|
|
cat << EOF
|
|
|
|
env:
|
2022-06-04 16:38:13 +07:00
|
|
|
BUILD_DUO: ${BUILD_DUO}
|
|
|
|
BUILD_HAPROXY: ${BUILD_HAPROXY}
|
2022-06-05 00:51:33 +07:00
|
|
|
BUILD_SAMBA: ${BUILD_SAMBA}
|
2020-04-01 05:44:57 +07:00
|
|
|
CI_BYPASS: ${CI_BYPASS}
|
2020-03-09 08:32:07 +07:00
|
|
|
|
|
|
|
steps:
|
2020-04-22 20:10:22 +07:00
|
|
|
- label: ":service_dog: Linting"
|
2020-12-03 14:06:42 +07:00
|
|
|
command: "reviewdog -reporter=github-check -filter-mode=nofilter -fail-on-error"
|
2021-08-07 07:06:42 +07:00
|
|
|
if: build.branch !~ /^(v[0-9]+\.[0-9]+\.[0-9]+)$\$/ && build.message !~ /\[(skip test|test skip)\]/
|
2020-04-22 20:10:22 +07:00
|
|
|
|
2020-03-09 08:32:07 +07:00
|
|
|
- label: ":hammer_and_wrench: Unit Test"
|
2021-06-25 18:53:20 +07:00
|
|
|
command: "authelia-scripts --log-level debug ci --buildkite"
|
2021-02-22 10:24:01 +07:00
|
|
|
agents:
|
|
|
|
build: "unit-test"
|
2020-04-28 21:07:20 +07:00
|
|
|
artifact_paths:
|
2021-09-16 19:39:18 +07:00
|
|
|
- "authelia-*.tar.gz"
|
|
|
|
- "authelia-*.tar.gz.sha256"
|
2021-01-03 11:28:46 +07:00
|
|
|
key: "unit-test"
|
2020-05-02 08:41:53 +07:00
|
|
|
if: build.env("CI_BYPASS") != "true"
|
2020-03-09 08:32:07 +07:00
|
|
|
|
|
|
|
- wait:
|
2020-04-01 05:44:57 +07:00
|
|
|
if: build.env("CI_BYPASS") != "true"
|
2022-06-04 16:38:13 +07:00
|
|
|
EOF
|
|
|
|
if [[ "${BUILD_DUO}" == "true" ]]; then
|
|
|
|
cat << EOF
|
|
|
|
- label: ":rocket: Trigger Pipeline [integration-duo]"
|
|
|
|
trigger: "integration-duo"
|
|
|
|
build:
|
|
|
|
message: "${BUILDKITE_MESSAGE}"
|
|
|
|
commit: "${BUILDKITE_COMMIT}"
|
|
|
|
branch: "${BUILDKITE_BRANCH}"
|
|
|
|
env:
|
|
|
|
BUILDKITE_PULL_REQUEST: "${BUILDKITE_PULL_REQUEST}"
|
|
|
|
BUILDKITE_PULL_REQUEST_BASE_BRANCH: "${BUILDKITE_PULL_REQUEST_BASE_BRANCH}"
|
|
|
|
BUILDKITE_PULL_REQUEST_REPO: "${BUILDKITE_PULL_REQUEST_REPO}"
|
|
|
|
depends_on: ~
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
if [[ "${BUILD_HAPROXY}" == "true" ]]; then
|
|
|
|
cat << EOF
|
|
|
|
- label: ":rocket: Trigger Pipeline [integration-haproxy]"
|
|
|
|
trigger: "integration-haproxy"
|
|
|
|
build:
|
|
|
|
message: "${BUILDKITE_MESSAGE}"
|
|
|
|
commit: "${BUILDKITE_COMMIT}"
|
|
|
|
branch: "${BUILDKITE_BRANCH}"
|
|
|
|
env:
|
|
|
|
BUILDKITE_PULL_REQUEST: "${BUILDKITE_PULL_REQUEST}"
|
|
|
|
BUILDKITE_PULL_REQUEST_BASE_BRANCH: "${BUILDKITE_PULL_REQUEST_BASE_BRANCH}"
|
|
|
|
BUILDKITE_PULL_REQUEST_REPO: "${BUILDKITE_PULL_REQUEST_REPO}"
|
|
|
|
depends_on: ~
|
|
|
|
EOF
|
|
|
|
fi
|
2022-06-05 00:51:33 +07:00
|
|
|
if [[ "${BUILD_SAMBA}" == "true" ]]; then
|
|
|
|
cat << EOF
|
|
|
|
- label: ":rocket: Trigger Pipeline [integration-samba]"
|
|
|
|
trigger: "integration-samba"
|
|
|
|
build:
|
|
|
|
message: "${BUILDKITE_MESSAGE}"
|
|
|
|
commit: "${BUILDKITE_COMMIT}"
|
|
|
|
branch: "${BUILDKITE_BRANCH}"
|
|
|
|
env:
|
|
|
|
BUILDKITE_PULL_REQUEST: "${BUILDKITE_PULL_REQUEST}"
|
|
|
|
BUILDKITE_PULL_REQUEST_BASE_BRANCH: "${BUILDKITE_PULL_REQUEST_BASE_BRANCH}"
|
|
|
|
BUILDKITE_PULL_REQUEST_REPO: "${BUILDKITE_PULL_REQUEST_REPO}"
|
|
|
|
depends_on: ~
|
|
|
|
EOF
|
|
|
|
fi
|
2022-06-04 16:38:13 +07:00
|
|
|
cat << EOF
|
2021-09-16 19:39:18 +07:00
|
|
|
- label: ":docker: Build Image [coverage]"
|
|
|
|
command: "authelia-scripts docker build --container=coverage"
|
2022-04-27 08:49:47 +07:00
|
|
|
retry:
|
|
|
|
manual:
|
|
|
|
permit_on_passed: true
|
2021-09-16 19:39:18 +07:00
|
|
|
agents:
|
|
|
|
build: "linux-coverage"
|
|
|
|
artifact_paths:
|
|
|
|
- "authelia-image-coverage.tar.zst"
|
2020-03-09 08:32:07 +07:00
|
|
|
depends_on: ~
|
2021-09-16 19:39:18 +07:00
|
|
|
key: "build-docker-linux-coverage"
|
|
|
|
if: build.env("CI_BYPASS") != "true" && build.branch !~ /^(v[0-9]+\.[0-9]+\.[0-9]+)$\$/ && build.message !~ /\[(skip test|test skip)\]/
|
2020-03-09 08:32:07 +07:00
|
|
|
|
2021-06-26 08:45:21 +07:00
|
|
|
- label: ":debian: Package Builds"
|
|
|
|
command: ".buildkite/steps/debpackages.sh | buildkite-agent pipeline upload"
|
|
|
|
depends_on: ~
|
2021-06-27 10:58:58 +07:00
|
|
|
if: build.branch !~ /^(dependabot|renovate)\/.*/ && build.env("CI_BYPASS") != "true"
|
2021-06-26 08:45:21 +07:00
|
|
|
|
2020-03-09 08:32:07 +07:00
|
|
|
- wait:
|
2021-08-07 07:06:42 +07:00
|
|
|
if: build.branch !~ /^(v[0-9]+\.[0-9]+\.[0-9]+)$\$/ && build.env("CI_BYPASS") != "true" && build.message !~ /\[(skip test|test skip)\]/
|
2020-03-09 08:32:07 +07:00
|
|
|
|
|
|
|
- label: ":chrome: Integration Tests"
|
|
|
|
command: ".buildkite/steps/e2etests.sh | buildkite-agent pipeline upload"
|
|
|
|
depends_on:
|
2020-06-05 07:43:19 +07:00
|
|
|
- "build-docker-linux-coverage"
|
2021-08-07 07:06:42 +07:00
|
|
|
if: build.branch !~ /^(v[0-9]+\.[0-9]+\.[0-9]+)$\$/ && build.env("CI_BYPASS") != "true" && build.message !~ /\[(skip test|test skip)\]/
|
2022-06-04 16:38:13 +07:00
|
|
|
EOF
|