From 986146783137eb815f44457967c8d545a44df2c4 Mon Sep 17 00:00:00 2001 From: Amir Zarrinkafsh Date: Sun, 5 Jun 2022 03:51:33 +1000 Subject: [PATCH] ci: add integration container for samba and refactor duo (#3480) This change utilises a specific integration container for the ActiveDirectory suite and simplifies the DuoPush suite. --- .buildkite/hooks/pre-command | 6 ++++- .buildkite/integration.sh | 3 +++ .buildkite/pipeline.sh | 24 +++++++++++++++++-- .buildkite/steps/e2etests.sh | 4 ++-- .../suites/example/compose/duo-api/Dockerfile | 4 +--- .../compose/duo-api/docker-compose.dev.yml | 9 ------- ...er-compose.dist.yml => docker-compose.yml} | 2 ++ .../suites/example/compose/samba/Dockerfile | 3 +-- .../example/compose/samba/docker-compose.yml | 5 ++-- internal/suites/suite_duo_push.go | 2 +- 10 files changed, 40 insertions(+), 22 deletions(-) delete mode 100644 internal/suites/example/compose/duo-api/docker-compose.dev.yml rename internal/suites/example/compose/duo-api/{docker-compose.dist.yml => docker-compose.yml} (57%) diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index 2b4754e5c..a7e2411a6 100755 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -37,12 +37,16 @@ if [[ "${BUILDKITE_LABEL}" =~ ":selenium:" ]]; then if [[ "${BUILD_DUO}" == "true" ]] && [[ "${SUITE}" == "DuoPush" ]]; then CONTAINER="integration-duo" - FILE="internal/suites/example/compose/duo-api/docker-compose.dist.yml" + FILE="internal/suites/example/compose/duo-api/docker-compose.yml" INTEGRATION elif [[ "${BUILD_HAPROXY}" == "true" ]] && [[ "${SUITE}" == "HAProxy" ]]; then CONTAINER="integration-haproxy" FILE="internal/suites/example/compose/haproxy/docker-compose.yml" INTEGRATION + elif [[ "${BUILD_SAMBA}" == "true" ]] && [[ "${SUITE}" == "ActiveDirectory" ]]; then + CONTAINER="integration-samba" + FILE="internal/suites/example/compose/samba/docker-compose.yml" + INTEGRATION fi fi diff --git a/.buildkite/integration.sh b/.buildkite/integration.sh index 9ee5a95fd..3f4c3459e 100755 --- a/.buildkite/integration.sh +++ b/.buildkite/integration.sh @@ -22,6 +22,9 @@ if [[ "${BUILDKITE_PIPELINE_NAME}" == "integration-duo" ]]; then elif [[ "${BUILDKITE_PIPELINE_NAME}" == "integration-haproxy" ]]; then DIRECTORY="internal/suites/example/compose/haproxy" GROUP="haproxy-deployments" +elif [[ "${BUILDKITE_PIPELINE_NAME}" == "integration-samba" ]]; then + DIRECTORY="internal/suites/example/compose/samba" + GROUP="samba-deployments" fi cat << EOF diff --git a/.buildkite/pipeline.sh b/.buildkite/pipeline.sh index 12f156d47..74e72e636 100755 --- a/.buildkite/pipeline.sh +++ b/.buildkite/pipeline.sh @@ -6,12 +6,14 @@ DIVERGED=$(git merge-base --fork-point origin/master > /dev/null; echo $?) 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/.* && echo true || echo false) + 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) 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) else - BUILD_DUO=$(git diff --name-only `git merge-base --fork-point origin/master` | grep -q ^internal/suites/example/compose/duo-api/.* && echo true || echo false) + 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) 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) + 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) 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) fi @@ -21,11 +23,13 @@ if [[ "${DIVERGED}" == 0 ]]; then else BUILD_DUO="false" BUILD_HAPROXY="false" + BUILD_SAMBA="false" CI_BYPASS="false" fi else BUILD_DUO="false" BUILD_HAPROXY="false" + BUILD_SAMBA="false" CI_BYPASS="false" fi @@ -33,6 +37,7 @@ cat << EOF env: BUILD_DUO: ${BUILD_DUO} BUILD_HAPROXY: ${BUILD_HAPROXY} + BUILD_SAMBA: ${BUILD_SAMBA} CI_BYPASS: ${CI_BYPASS} steps: @@ -83,6 +88,21 @@ cat << EOF depends_on: ~ EOF fi +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 cat << EOF - label: ":docker: Build Image [coverage]" command: "authelia-scripts docker build --container=coverage" diff --git a/.buildkite/steps/e2etests.sh b/.buildkite/steps/e2etests.sh index df3d85205..68ba7357b 100755 --- a/.buildkite/steps/e2etests.sh +++ b/.buildkite/steps/e2etests.sh @@ -35,9 +35,9 @@ cat << EOF agents: suite: "all" EOF +fi cat << EOF env: SUITE: "${SUITE_NAME}" EOF -fi -done \ No newline at end of file +done diff --git a/internal/suites/example/compose/duo-api/Dockerfile b/internal/suites/example/compose/duo-api/Dockerfile index 57dc13c3c..8f6237e49 100644 --- a/internal/suites/example/compose/duo-api/Dockerfile +++ b/internal/suites/example/compose/duo-api/Dockerfile @@ -5,8 +5,6 @@ WORKDIR /usr/app/src ADD package.json package.json RUN yarn install --frozen-lockfile --production --silent -ADD duo_api.js duo_api.js - EXPOSE 3000 -CMD ["node", "duo_api.js"] \ No newline at end of file +CMD ["node", "duo_api.js"] diff --git a/internal/suites/example/compose/duo-api/docker-compose.dev.yml b/internal/suites/example/compose/duo-api/docker-compose.dev.yml deleted file mode 100644 index ceb40177f..000000000 --- a/internal/suites/example/compose/duo-api/docker-compose.dev.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -version: '3' -services: - duo-api: - build: - context: ./example/compose/duo-api - networks: - - authelianet -... diff --git a/internal/suites/example/compose/duo-api/docker-compose.dist.yml b/internal/suites/example/compose/duo-api/docker-compose.yml similarity index 57% rename from internal/suites/example/compose/duo-api/docker-compose.dist.yml rename to internal/suites/example/compose/duo-api/docker-compose.yml index 79e9aa212..afa1af14d 100644 --- a/internal/suites/example/compose/duo-api/docker-compose.dist.yml +++ b/internal/suites/example/compose/duo-api/docker-compose.yml @@ -3,6 +3,8 @@ version: '3' services: duo-api: image: authelia/integration-duo + volumes: + - ./example/compose/duo-api/duo_api.js:/usr/app/src/duo_api.js networks: - authelianet ... diff --git a/internal/suites/example/compose/samba/Dockerfile b/internal/suites/example/compose/samba/Dockerfile index 947cafdd6..8d6b529e1 100644 --- a/internal/suites/example/compose/samba/Dockerfile +++ b/internal/suites/example/compose/samba/Dockerfile @@ -8,5 +8,4 @@ apk add --no-cache \ samba-dc \ supervisor -ADD init.sh /init.sh -CMD /init.sh setup \ No newline at end of file +CMD /init.sh setup diff --git a/internal/suites/example/compose/samba/docker-compose.yml b/internal/suites/example/compose/samba/docker-compose.yml index 49b7c6358..f4585ace0 100644 --- a/internal/suites/example/compose/samba/docker-compose.yml +++ b/internal/suites/example/compose/samba/docker-compose.yml @@ -2,8 +2,9 @@ version: '3' services: sambaldap: - build: - context: ./example/compose/samba + image: authelia/integration-samba + volumes: + - ./example/compose/samba/init.sh:/init.sh cap_add: - SYS_ADMIN hostname: ldap.example.com diff --git a/internal/suites/suite_duo_push.go b/internal/suites/suite_duo_push.go index 4bef94478..586655844 100644 --- a/internal/suites/suite_duo_push.go +++ b/internal/suites/suite_duo_push.go @@ -16,7 +16,7 @@ func init() { "internal/suites/example/compose/authelia/docker-compose.frontend.{}.yml", "internal/suites/example/compose/nginx/backend/docker-compose.yml", "internal/suites/example/compose/nginx/portal/docker-compose.yml", - "internal/suites/example/compose/duo-api/docker-compose.{}.yml", + "internal/suites/example/compose/duo-api/docker-compose.yml", }) setup := func(suitePath string) error {