Skip to content

Commit 07ea14b

Browse files
MDBF-1109 - Auto update the Debian Sid environment
[skip ci] Quick recap on how images are deployed to production: 1. On Pull Request : an image is only built 2. On Push to DEV branch: the image is built and pushed to quay / ghcr but with a `dev_` prefix tag. `buildbot.dev.mariadb.org` uses images starting with`dev_` 3. On push to MAIN branch: the `dev_` tag is moved in quay / ghcr replacing the production image that doesn't have `dev_` in its name. `buildbot.mariadb.org` looks for images not having `dev_` in their name. On schedule goal: - on schedule event (which by GitHub laws is triggered on the default branch >>dev<<). We want to build the container image, push it to dev and then deploy it to prod. Framework: The dispatcher is scheduled to run on the third of the month. Child workflows having `is_scheduled_event` input will be triggered. In the child workflow only the images with `deploy_on_schedule: true` are rebuilt. In the workflow template `bbw_build_container_template.yml`: - the job runs if the run is scheduled and the matrix item has 'deploy_on_schedule: true` or for any other event type (pull request, push) If `is_scheduled_event` is True then tags are moved to Production.
1 parent d4b5d8a commit 07ea14b

File tree

4 files changed

+107
-3
lines changed

4 files changed

+107
-3
lines changed

.github/workflows/REAMDE.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Building containerized build environments for Buildbot
2+
3+
**A build environment is a Docker container image used by Buildbot to build and test the server.**
4+
5+
Most of the build environments are created using `build-` workflows that share the same template file: [bbw_build_container_template.yml](bbw_build_container_template.yml).
6+
An exception is [bbw_build_container_rhel.yml](bbw_build_container_rhel.yml), which contains special tasks only applicable to `RHEL`.
7+
8+
Each workflow defines a matrix of images to be built. Adding a new image is as simple as adding a new item to the matrix. See **Adding a new image**.
9+
10+
## From Build to Production
11+
12+
Workflows are triggered by `Dockerfile` changes in [/ci_build_images/](../../ci_build_images/)
13+
14+
In **quay** and **ghcr**, we use two types of tags:
15+
16+
1. `dev_#image_name#` — used by `buildbot.dev.mariadb.org`
17+
1. `#image_name#` — used by `buildbot.mariadb.org`
18+
19+
To update a **production** image, create a Pull Request, merge it into the `DEV` branch, and then sync the changes to `MAIN`.
20+
21+
## Events that trigger a workflow
22+
23+
1. **Pull Request** – The image is built, and the result is reported as a CI Check.
24+
1. **Push to DEV** – The image is built and pushed to **quay** and **ghcr** with the tag `dev_#image_name#`.
25+
1. **Push to MAIN** – The `dev_#image_name#` tag is moved to `#image_name#` in both **quay** and **ghcr**.
26+
1. **Schedule** – See **Workflow dispatcher**.
27+
28+
## Adding a new image
29+
30+
You need to identify the group where the new image belongs.
31+
For example, adding `Fedora 42` means modifying [build-fedora-based.yml](build-fedora-based.yml).
32+
33+
An item should be added under `matrix/include`. For example:
34+
35+
```
36+
matrix:
37+
include:
38+
- image: debian:11
39+
platforms: linux/amd64, linux/arm64/v8
40+
branch: 10.11
41+
nogalera: false
42+
```
43+
44+
**Required parameters**:
45+
46+
- **Image** – This is the value used in the `FROM` instruction of the Dockerfile.
47+
- **Platforms** – Specify more than one to build a multi-architecture container image.
48+
- **Dockerfile** – A space-delimited list of `Dockerfiles` from the **ci_build_images** directory. The order is important, as they are concatenated.
49+
50+
**Optional**:
51+
52+
- **tag** – The displayed tag in **quay** and **ghcr**. If not specified, it's the same as the image name with `:` removed.
53+
- **runner** – GitHub Runner used for the build.
54+
- **clang_version** – Only relevant for [ci_build_images/msan.fragment.Dockerfile](msan.fragment.Dockerfile).
55+
- **branch** – For `debian`-based `Dockerfiles`, this installs build dependencies based on the control file from the specified MariaDB branch, e.g. `mk-build-deps -r -i debian/control`.
56+
- **install_valgrind** – Installs Valgrind in the final container image. Required for builders running tests under Valgrind.
57+
- **files** – JSON list of repository files needed in the final container image.
58+
- **nogalera** – If **True**, `galera-4` will not be installed in the container. Set to **True** when no Galera package is available on `ci.mariadb.org` for the distribution.
59+
- **deploy_on_schedule** – If **True**, the image will be rebuilt and deployed to production on the schedule defined by the **workflow dispatcher**.
60+
61+
## Workflow dispatcher
62+
63+
All `build-` workflows can be manually dispatched using `build-workflow-dispatcher.yml`.
64+
65+
When dispatching the workflow, behavior depends on the `source branch`:
66+
67+
- **DEV** – Builds the image and pushes it to **quay** and **ghcr** with the `dev_#image_name#` tag.
68+
- **MAIN** – Performs a production deployment by moving the `dev_#image_name#` tag to `#image_name#`.
69+
70+
### Scheduler
71+
72+
On the specified schedule, this workflow will trigger (on the default branch) all workflows that implement `is_scheduled_event` as an input to the `workflow_call` event.
73+
74+
```
75+
on:
76+
schedule:
77+
- cron: '0 3 3 * *' # Third of the month
78+
```
79+
80+
During this event, the image is not only rebuilt and pushed to **quay** and **ghcr**, but the tag is also moved and deployed to **production**.

.github/workflows/bbw_build_container_template.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,19 @@ on:
3939
required: false
4040
type: string
4141
default: 'false'
42+
deploy_on_schedule:
43+
required: false
44+
type: boolean
45+
default: false
46+
47+
is_scheduled_event:
48+
required: false
49+
type: boolean
50+
default: false
4251

4352
jobs:
4453
build:
54+
if: ${{ (!inputs.is_scheduled_event) || (inputs.is_scheduled_event && inputs.deploy_on_schedule) }}
4555
runs-on: ${{ inputs.runner || 'ubuntu-22.04' }}
4656
services:
4757
registry:
@@ -198,7 +208,7 @@ jobs:
198208
199209
200210
- name: ghcr.io - move tag to production
201-
if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH == 'true' }}
211+
if: ${{ env.DEPLOY_IMAGES == 'true' && (inputs.is_scheduled_event == 'true' || env.MAIN_BRANCH == 'true') }}
202212
run: |
203213
msg="Update tag (dev_${{ env.IMG }} --> ${{ env.IMG }})"
204214
line="${msg//?/=}"
@@ -226,7 +236,7 @@ jobs:
226236
docker://quay.io/mariadb-foundation/${{ env.REPO }}:dev_${{ env.IMG }}
227237
228238
- name: quay.io - move tag to production
229-
if: ${{ env.DEPLOY_IMAGES == 'true' && env.MAIN_BRANCH =='true' }}
239+
if: ${{ env.DEPLOY_IMAGES == 'true' && (inputs.is_scheduled_event == 'true' || env.MAIN_BRANCH == 'true')}}
230240
run: |
231241
msg="Update tag (dev_${{ env.IMG }} --> ${{ env.IMG }})"
232242
line="${msg//?/=}"

.github/workflows/build-debian-based.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ on:
2424
- .github/workflows/bbw_build_container_template.yml
2525

2626
workflow_call:
27+
inputs:
28+
is_scheduled_event:
29+
required: false
30+
type: boolean
31+
default: false
2732

2833
jobs:
2934
build-images:
@@ -65,12 +70,14 @@ jobs:
6570
platforms: linux/amd64, linux/arm64/v8, linux/ppc64le
6671
branch: 11.4
6772
nogalera: false
73+
deploy_on_schedule: true
6874

6975
- image: debian:sid
7076
platforms: linux/386
7177
branch: 11.4
7278
tag: debiansid-386
7379
nogalera: false
80+
deploy_on_schedule: true
7481

7582
- image: ubuntu:22.04
7683
platforms: linux/amd64, linux/arm64/v8, linux/ppc64le, linux/s390x
@@ -95,4 +102,6 @@ jobs:
95102
tag: ${{ matrix.tag }}
96103
branch: ${{ matrix.branch }}
97104
nogalera: ${{ matrix.nogalera }}
105+
is_scheduled_event: ${{ inputs.is_scheduled_event || false }}
106+
deploy_on_schedule: ${{ matrix.deploy_on_schedule || false }}
98107
secrets: inherit

.github/workflows/build-workflow-dispatcher.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Dispatch all build container images workflows
22

33
on:
4+
schedule:
5+
- cron: '0 12 5 * *' # FIXME: Adjust after first run
6+
47
workflow_dispatch:
58
inputs:
69
build-centospip-based:
@@ -50,9 +53,11 @@ jobs:
5053
uses: ./.github/workflows/build-centos.pip-based.yml
5154
secrets: inherit
5255
build-debian-based:
53-
if: ${{ inputs.build-debian-based }}
56+
if: ${{ inputs.build-debian-based || github.event_name == 'schedule'}}
5457
uses: ./.github/workflows/build-debian-based.yml
5558
secrets: inherit
59+
with:
60+
is_scheduled_event: ${{ github.event_name == 'schedule' }}
5661
build-debian-aocc-based:
5762
if: ${{ inputs.build-debian-aocc-based }}
5863
uses: ./.github/workflows/build-debian.aocc-based.yml

0 commit comments

Comments
 (0)