Skip to content

Commit

Permalink
ci(buildkite): bypass drafted dependency builds
Browse files Browse the repository at this point in the history
Signed-off-by: Amir Zarrinkafsh <nightah@me.com>
  • Loading branch information
nightah committed Apr 26, 2024
1 parent 5836cb1 commit d3e54e3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .buildkite/annotations/artifacts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
<a href="artifact://authelia-public_html.tar.gz.sha256">authelia-public_html.tar.gz.sha256</a>
</dd>
</div>
</dl>
</dl>
2 changes: 1 addition & 1 deletion .buildkite/annotations/bypass
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
CI/CD steps have been skipped as this build will not affect code.
</dd>
</div>
</dl>
</dl>
8 changes: 8 additions & 0 deletions .buildkite/annotations/draft
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<h4>Draft Build</h4>
<dl class="flex flex-wrap mxn1">
<div class="m1">
<dd>
CI/CD steps have been skipped as this is a draft build related to dependencies.
</dd>
</div>
</dl>
26 changes: 13 additions & 13 deletions .buildkite/hooks/post-command
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,55 @@

set +u

if [[ "${BUILDKITE_PULL_REQUEST}" != "false" ]]; then
if [[ "${BUILDKITE_LABEL}" == ":service_dog: Linting" ]]; then
if [[ ${BUILDKITE_PULL_REQUEST} != "false" ]]; then
if [[ ${BUILDKITE_LABEL} == ":service_dog: Linting" ]]; then
echo "--- :go::service_dog: Provide in-line commentary for pull request"
reviewdog -reporter=github-pr-review
fi
fi

if [[ ! "${BUILDKITE_BRANCH}" =~ ^(v.*) ]] && [[ "${BUILDKITE_COMMAND_EXIT_STATUS}" == 0 ]]; then
if [[ "${BUILDKITE_LABEL}" == ":hammer_and_wrench: Unit Test" ]] || [[ "${BUILDKITE_LABEL}" =~ ":selenium:" ]]; then
if [[ ! ${BUILDKITE_BRANCH} =~ ^(v.*) ]] && [[ ${BUILDKITE_COMMAND_EXIT_STATUS} == 0 ]]; then
if [[ ${BUILDKITE_LABEL} == ":hammer_and_wrench: Unit Test" ]] || [[ ${BUILDKITE_LABEL} =~ ":selenium:" ]]; then
echo "--- :codecov: Upload coverage reports"
NAME="UnitTest"
if [[ "${SUITE}" != "" ]]; then
if [[ ${SUITE} != "" ]]; then
NAME=${SUITE}
go tool covdata percent -i=coverage
go tool covdata textfmt -i=coverage -o coverage.txt
fi
if [[ "${BUILDKITE_AGENT_META_DATA_CODECOV}" == "verbose" ]]; then
if [[ ${BUILDKITE_AGENT_META_DATA_CODECOV} == "verbose" ]]; then
BUILDKITE_AGENT_META_DATA_CODECOV="-v"
fi
codecov -Z -c -f 'coverage*.txt' -n ${NAME} -F backend "${BUILDKITE_AGENT_META_DATA_CODECOV}"
if [[ "${BUILDKITE_LABEL}" =~ ":selenium:" ]]; then
if [[ ${BUILDKITE_LABEL} =~ ":selenium:" ]]; then
cd web && pnpm report
fi
codecov -Z -c -f '!Dockerfile*' -f '!*.go' -f '!*.tar' -f '!*.zst' -n ${NAME} -F frontend "${BUILDKITE_AGENT_META_DATA_CODECOV}"
fi
fi

if [[ "${BUILDKITE_LABEL}" =~ ":selenium:" ]] || [[ "${BUILDKITE_LABEL}" =~ ":docker: Build Image" ]]; then
if [[ ${BUILDKITE_LABEL} =~ ":selenium:" ]] || [[ ${BUILDKITE_LABEL} =~ ":docker: Build Image" ]]; then
CONTAINERS=$(docker ps -a -q)
if [[ ${CONTAINERS} != "" ]]; then
echo "--- :docker: Remove lingering containers"
docker rm -f ${CONTAINERS}
fi
fi

if [[ "${BUILDKITE_LABEL}" == ":debian: Package Builds" ]]; then
cat .buildkite/annotations/artifacts | buildkite-agent annotate --style "success" --context "ctx-success"
if [[ ${BUILDKITE_LABEL} == ":debian: Package Builds" ]]; then
buildkite-agent annotate --style "success" --context "ctx-success" < .buildkite/annotations/artifacts
fi

if [[ "${BUILDKITE_LABEL}" == ":docker: Build and Deploy Image" ]]; then
if [[ ${BUILDKITE_LABEL} == ":docker: Build and Deploy Image" ]]; then
docker logout
fi

if [[ "${BUILDKITE_LABEL}" =~ ":docker: Deploy" ]]; then
if [[ ${BUILDKITE_LABEL} =~ ":docker: Deploy" ]]; then
docker logout
docker logout ghcr.io
fi

if [[ "${BUILDKITE_LABEL}" == ":docker: Deploy Manifest" ]] && [[ "${BUILDKITE_BRANCH}" == "master" ]] && [[ "${BUILDKITE_PULL_REQUEST}" == "false" ]]; then
if [[ ${BUILDKITE_LABEL} == ":docker: Deploy Manifest" ]] && [[ ${BUILDKITE_BRANCH} == "master" ]] && [[ ${BUILDKITE_PULL_REQUEST} == "false" ]]; then
echo "--- :docker: Removing tags for deleted branches"
anontoken=$(curl -fsL --retry 3 'https://auth.docker.io/token?service=registry.docker.io&scope=repository:authelia/authelia:pull' | jq -r .token)
authtoken=$(curl -fs --retry 3 -H "Content-Type: application/json" -X "POST" -d '{"username": "'${DOCKER_USERNAME}'", "password": "'${DOCKER_PASSWORD}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
Expand Down
23 changes: 15 additions & 8 deletions .buildkite/pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ set -u

DIVERGED=$(git merge-base --fork-point origin/master > /dev/null; echo $?)

if [[ "${DIVERGED}" == 0 ]]; then
if [[ "${BUILDKITE_TAG}" == "" ]]; then
if [[ "${BUILDKITE_BRANCH}" == "master" ]]; then
if [[ ${DIVERGED} == 0 ]]; then
if [[ ${BUILDKITE_TAG} == "" ]]; then
if [[ ${BUILDKITE_BRANCH} == "master" ]]; then
BUILD_DUO=$(git diff --name-only HEAD~1 | grep -q ^internal/suites/example/compose/duo-api/Dockerfile && echo true || echo false)
BUILD_HAPROXY=$(git diff --name-only HEAD~1 | grep -q ^internal/suites/example/compose/haproxy/Dockerfile && echo true || echo false)
BUILD_SAMBA=$(git diff --name-only HEAD~1 | grep -q ^internal/suites/example/compose/samba/Dockerfile && echo true || echo false)
Expand All @@ -17,8 +17,8 @@ if [[ "${DIVERGED}" == 0 ]]; then
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\/.*|cmd\/authelia-gen\/templates\/.*|examples\/.*)/!{q1}' && echo true || echo false)
fi

if [[ "${CI_BYPASS}" == "true" ]]; then
cat .buildkite/annotations/bypass | buildkite-agent annotate --style "info" --context "ctx-info"
if [[ ${CI_BYPASS} == "true" ]]; then
buildkite-agent annotate --style "info" --context "ctx-info" < .buildkite/annotations/bypass
fi
else
BUILD_DUO="false"
Expand All @@ -33,6 +33,13 @@ else
CI_BYPASS="false"
fi

if [[ ${BUILDKITE_PULL_REQUEST_DRAFT} ]]; then
if [[ ${BUILDKITE_PULL_REQUEST_DRAFT} == "true" ]] && [[ ${BUILDKITE_BRANCH} =~ ^(dependabot|renovate) ]]; then
CI_BYPASS="true"
buildkite-agent annotate --style "info" --context "ctx-info" < .buildkite/annotations/draft
fi
fi

cat << EOF
env:
BUILD_DUO: ${BUILD_DUO}
Expand Down Expand Up @@ -60,7 +67,7 @@ steps:
- wait:
if: build.env("CI_BYPASS") != "true"
EOF
if [[ "${BUILD_DUO}" == "true" ]]; then
if [[ ${BUILD_DUO} == "true" ]]; then
cat << EOF
- label: ":rocket: Trigger Pipeline [integration-duo]"
trigger: "integration-duo"
Expand All @@ -75,7 +82,7 @@ cat << EOF
depends_on: ~
EOF
fi
if [[ "${BUILD_HAPROXY}" == "true" ]]; then
if [[ ${BUILD_HAPROXY} == "true" ]]; then
cat << EOF
- label: ":rocket: Trigger Pipeline [integration-haproxy]"
trigger: "integration-haproxy"
Expand All @@ -90,7 +97,7 @@ cat << EOF
depends_on: ~
EOF
fi
if [[ "${BUILD_SAMBA}" == "true" ]]; then
if [[ ${BUILD_SAMBA} == "true" ]]; then
cat << EOF
- label: ":rocket: Trigger Pipeline [integration-samba]"
trigger: "integration-samba"
Expand Down

0 comments on commit d3e54e3

Please sign in to comment.