Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(buildkite): bypass drafted dependency builds #7243

Merged
merged 5 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 13 additions & 10 deletions .buildkite/pipeline.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/usr/bin/env bash
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using modern command substitution syntax for better readability.

- BUILD_DUO=$(git diff --name-only HEAD~1 | grep -q ^internal/suites/example/compose/duo-api/Dockerfile && echo true || echo false)
+ BUILD_DUO=$(git diff --name-only $(git rev-parse HEAD~1) | grep -q ^internal/suites/example/compose/duo-api/Dockerfile && echo true || echo false)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if [[ ${BUILDKITE_BRANCH} == "master" ]]; 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 +15,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 +31,11 @@ else
CI_BYPASS="false"
fi

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

cat << EOF
env:
BUILD_DUO: ${BUILD_DUO}
Expand Down Expand Up @@ -60,7 +63,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 +78,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 +93,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