[buildbot] GitLab CI integration
LEDE Commits
lede-commits at lists.infradead.org
Sat Mar 6 07:08:01 GMT 2021
ynezz pushed a commit to buildbot.git, branch master:
https://git.openwrt.org/70883902ecf13135ab83b2a0410efb6e9209b451
commit 70883902ecf13135ab83b2a0410efb6e9209b451
Author: Petr Štetiar <ynezz at true.cz>
AuthorDate: Tue Mar 2 13:39:19 2021 +0100
GitLab CI integration
For improved automation, further QA etc.
Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
.gitignore | 4 ++++
.gitlab-ci.yml | 12 ++++++++++++
.gitlab/docker.yml | 34 ++++++++++++++++++++++++++++++++++
.gitlab/docker/README.md | 6 ++++++
.gitlab/docker/buildmaster/gitlab.yml | 20 ++++++++++++++++++++
.gitlab/docker/buildslave/gitlab.yml | 20 ++++++++++++++++++++
6 files changed, 96 insertions(+)
diff --git a/.gitignore b/.gitignore
index 0c3bc5d..5dca1da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,7 @@ phase[12]/http.log
phase[12]/key-build*
phase[12]/state.sqlite*
phase[12]/twistd.*
+!.gitlab-ci.yml
+!.gitlab
+!.gitlab/*
+!.gitlab/**/*
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..df2d17b
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,12 @@
+variables:
+ BUILDBOT_VERSION: 2.10.1
+
+include:
+ - local: .gitlab/docker.yml
+ - local: .gitlab/docker/buildmaster/gitlab.yml
+ - local: .gitlab/docker/buildslave/gitlab.yml
+
+stages:
+ - docker
+ - docker test
+ - docker deploy
diff --git a/.gitlab/docker.yml b/.gitlab/docker.yml
new file mode 100644
index 0000000..501519b
--- /dev/null
+++ b/.gitlab/docker.yml
@@ -0,0 +1,34 @@
+.docker in docker:
+ tags:
+ - gce
+ image: docker:19.03.7
+ services:
+ - docker:19.03.7-dind
+ variables:
+ DOCKER_DRIVER: overlay2
+ DOCKER_TLS_CERTDIR: "/certs"
+
+.build Docker image:
+ stage: docker
+ extends: .docker in docker
+ script:
+ - export IMAGE_NAME="$(echo $CI_JOB_NAME | sed 's/build Docker image \(.*\)/\1/')"
+ - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
+ - docker build --build-arg BUILDBOT_VERSION=$BUILDBOT_VERSION -t "$IMAGE_NAME" -f "docker/$IMAGE_NAME/Dockerfile" .
+ - docker tag "$IMAGE_NAME" "$CI_REGISTRY_IMAGE/$IMAGE_NAME-$BUILDBOT_VERSION:$CI_COMMIT_REF_SLUG"
+ - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME-$BUILDBOT_VERSION:$CI_COMMIT_REF_SLUG"
+
+.deploy Docker image:
+ extends: .docker in docker
+ script:
+ - export IMAGE_NAME="$(echo $CI_JOB_NAME | sed 's/deploy Docker image \(.*\)/\1/')"
+ - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
+ - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME-$BUILDBOT_VERSION:$CI_COMMIT_REF_SLUG"
+
+ - docker tag "$CI_REGISTRY_IMAGE/$IMAGE_NAME-$BUILDBOT_VERSION:$CI_COMMIT_REF_SLUG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME-$BUILDBOT_VERSION:latest"
+ - docker tag "$CI_REGISTRY_IMAGE/$IMAGE_NAME-$BUILDBOT_VERSION:latest" "$CI_REGISTRY_IMAGE/$IMAGE_NAME-$BUILDBOT_VERSION:$CI_COMMIT_SHORT_SHA"
+ - docker tag "$CI_REGISTRY_IMAGE/$IMAGE_NAME-$BUILDBOT_VERSION:latest" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:latest"
+
+ - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME-$BUILDBOT_VERSION:latest"
+ - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME-$BUILDBOT_VERSION:$CI_COMMIT_SHORT_SHA"
+ - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:latest"
diff --git a/.gitlab/docker/README.md b/.gitlab/docker/README.md
new file mode 100644
index 0000000..a8aef0a
--- /dev/null
+++ b/.gitlab/docker/README.md
@@ -0,0 +1,6 @@
+# Content
+
+This directory contains bits for Docker images used on the GitLab CI.
+
+## buildmaster
+## buildslave
diff --git a/.gitlab/docker/buildmaster/gitlab.yml b/.gitlab/docker/buildmaster/gitlab.yml
new file mode 100644
index 0000000..10460c6
--- /dev/null
+++ b/.gitlab/docker/buildmaster/gitlab.yml
@@ -0,0 +1,20 @@
+build Docker image buildmaster:
+ stage: docker
+ extends: .build Docker image
+
+test Docker image buildmaster:
+ stage: docker test
+ extends: .docker in docker
+ needs: ["build Docker image buildmaster"]
+ script:
+ - export IMAGE_NAME="$(echo $CI_JOB_NAME | sed 's/test Docker image \(.*\)/\1/')"
+ - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
+ - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME-$BUILDBOT_VERSION:$CI_COMMIT_REF_SLUG"
+ - >
+ docker run --rm "$CI_REGISTRY_IMAGE/$IMAGE_NAME-$BUILDBOT_VERSION:$CI_COMMIT_REF_SLUG" |
+ grep "buildmaster configured in /master"
+
+deploy Docker image buildmaster:
+ stage: docker deploy
+ extends: .deploy Docker image
+ needs: ["test Docker image buildmaster"]
diff --git a/.gitlab/docker/buildslave/gitlab.yml b/.gitlab/docker/buildslave/gitlab.yml
new file mode 100644
index 0000000..960ee25
--- /dev/null
+++ b/.gitlab/docker/buildslave/gitlab.yml
@@ -0,0 +1,20 @@
+build Docker image buildslave:
+ stage: docker
+ extends: .build Docker image
+
+test Docker image buildslave:
+ stage: docker test
+ extends: .docker in docker
+ needs: ["build Docker image buildslave"]
+ script:
+ - export IMAGE_NAME="$(echo $CI_JOB_NAME | sed 's/test Docker image \(.*\)/\1/')"
+ - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
+ - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_REF_SLUG"
+ - >
+ docker run --rm --env BUILDSLAVE_NAME=foo --env BUILDSLAVE_PASSWORD=XXX
+ "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_REF_SLUG" | grep "worker configured in /builder"
+
+deploy Docker image buildslave:
+ stage: docker deploy
+ extends: .deploy Docker image
+ needs: ["test Docker image buildslave"]
More information about the lede-commits
mailing list