Skip to content

Commit bd09001

Browse files
authored
Add Github Actions (#42)
* Add Github Actions Signed-off-by: Jakub Stejskal <xstejs24@gmail.com> * Add gha-migration branch for testing purposes Signed-off-by: Jakub Stejskal <xstejs24@gmail.com> * Remove testing branch Signed-off-by: Jakub Stejskal <xstejs24@gmail.com> --------- Signed-off-by: Jakub Stejskal <xstejs24@gmail.com>
1 parent ba151e3 commit bd09001

File tree

10 files changed

+344
-8
lines changed

10 files changed

+344
-8
lines changed

.azure/build_pipeline.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ jobs:
3737
env:
3838
DOCKER_BUILDKIT: 1
3939
ARCHS: 'amd64 s390x arm64 ppc64le'
40-
- bash: make docker_tag_push
41-
condition: and(succeeded(), or(eq(variables['build.sourceBranch'], 'refs/heads/main'), startsWith(variables['build.sourceBranch'], 'refs/tags/')))
42-
displayName: "Tag and push images"
43-
env:
44-
QUAY_USER: $(QUAY_USER)
45-
QUAY_PASS: $(QUAY_PASS)
46-
ARCHS: 'amd64 s390x arm64 ppc64le'
40+
# - bash: make docker_tag_push
41+
# condition: and(succeeded(), or(eq(variables['build.sourceBranch'], 'refs/heads/main'), startsWith(variables['build.sourceBranch'], 'refs/tags/')))
42+
# displayName: "Tag and push images"
43+
# env:
44+
# QUAY_USER: $(QUAY_USER)
45+
# QUAY_PASS: $(QUAY_PASS)
46+
# ARCHS: 'amd64 s390x arm64 ppc64le'

.github/actionlint.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Configuration for GitHub actions linting - docker://rhysd/actionlint:1.7.10
2+
# For more info see https://github.com/rhysd/actionlint/blob/main/docs/config.md
3+
4+
# Configuration related to self-hosted runner.
5+
self-hosted-runner:
6+
# Labels of self-hosted runner in array of strings.
7+
# Add other runners if needed
8+
labels:
9+
# container runners
10+
- oracle-2cpu-8gb-arm64
11+
- oracle-2cpu-8gb-x86_64
12+
# VM runners
13+
- oracle-vm-2cpu-8gb-x86-64
14+
- oracle-vm-2cpu-8gb-arm64
15+
- oracle-vm-4cpu-16gb-x86-64
16+
- oracle-vm-4cpu-16gb-arm64
17+
- oracle-vm-8cpu-32gb-x86-64
18+
- oracle-vm-8cpu-32gb-arm64
19+
20+
# Path-specific configurations.
21+
paths:
22+
.github/workflows/run-system-tests.yml:
23+
ignore:
24+
# Ignore the specific error from shellcheck
25+
- 'shellcheck reported issue in this script: SC2086:.+'
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: "Build Test Container Images"
2+
description: "Build test container images for specific architecture"
3+
4+
inputs:
5+
architecture:
6+
description: "Architecture to build (amd64, arm64, s390x, ppc64le)"
7+
required: false
8+
default: "amd64"
9+
runnerArch:
10+
description: "Architecture of GitHub runner"
11+
required: false
12+
default: "amd64"
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Setup Docker
18+
uses: strimzi/strimzi-kafka-operator/.github/actions/dependencies/install-docker@main
19+
20+
- name: Download Kafka binaries artifact
21+
uses: actions/download-artifact@v7
22+
with:
23+
name: kafka-binaries
24+
path: images/kafka_binaries/
25+
26+
- name: Build base images
27+
shell: bash
28+
run: make docker_prepare_base_images
29+
env:
30+
DOCKER_BUILDKIT: 1
31+
ARCHS: ${{ inputs.architecture }}
32+
33+
- name: Build container images
34+
shell: bash
35+
run: make docker_build
36+
env:
37+
DOCKER_BUILDKIT: 1
38+
ARCHS: ${{ inputs.architecture }}
39+
40+
- name: Save container images
41+
shell: bash
42+
run: make docker_save
43+
env:
44+
ARCHS: ${{ inputs.architecture }}
45+
46+
- name: Upload container images artifact
47+
uses: actions/upload-artifact@v5
48+
with:
49+
name: containers-${{ inputs.architecture }}
50+
path: container-archives/*.tar.gz
51+
52+
- name: List built images
53+
if: ${{ always() }}
54+
shell: bash
55+
run: docker images -a
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: "Prepare Kafka Binaries"
2+
description: "Download and cache Kafka binaries"
3+
4+
inputs:
5+
runnerArch:
6+
description: "Architecture of GitHub runner"
7+
required: false
8+
default: "amd64"
9+
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Cache Kafka binaries
14+
id: cache-kafka
15+
uses: actions/cache@v4
16+
with:
17+
path: images/kafka_binaries
18+
key: kafka-binaries-v3-${{ hashFiles('supported_kafka.versions', 'supported_scala.version') }}
19+
20+
- name: Download Kafka binaries
21+
if: steps.cache-kafka.outputs.cache-hit != 'true'
22+
shell: bash
23+
run: make prepare
24+
25+
- name: Upload Kafka binaries artifact
26+
uses: actions/upload-artifact@v5
27+
with:
28+
name: kafka-binaries
29+
path: images/kafka_binaries/
30+
retention-days: 1
31+
32+
# Made with Bob
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: "Push Test Container Images"
2+
description: "Tag and push test container images to registry"
3+
4+
inputs:
5+
architectures:
6+
description: "Space-separated list of architectures (e.g., 'amd64 arm64 s390x ppc64le')"
7+
required: true
8+
runnerArch:
9+
description: "Runner architecture (amd64, arm64)"
10+
required: false
11+
default: "amd64"
12+
quayUser:
13+
description: "Quay.io username"
14+
required: true
15+
quayPass:
16+
description: "Quay.io password"
17+
required: true
18+
19+
runs:
20+
using: "composite"
21+
steps:
22+
- name: Setup Docker
23+
uses: strimzi/strimzi-kafka-operator/.github/actions/dependencies/install-docker@main
24+
25+
- name: Download container artifacts
26+
uses: actions/download-artifact@v7
27+
with:
28+
pattern: containers-*
29+
path: ./
30+
merge-multiple: true
31+
32+
- name: Extract and organize container archives
33+
shell: bash
34+
run: |
35+
mkdir -p container-archives
36+
mv *.tar.gz container-archives/ || true
37+
ls -la container-archives/
38+
39+
- name: Load container images
40+
shell: bash
41+
run: make docker_load
42+
env:
43+
ARCHS: ${{ inputs.architectures }}
44+
45+
- name: Tag and push images
46+
shell: bash
47+
run: make docker_tag_push
48+
env:
49+
DOCKER_BUILDKIT: 1
50+
QUAY_USER: ${{ inputs.quayUser }}
51+
QUAY_PASS: ${{ inputs.quayPass }}
52+
ARCHS: ${{ inputs.architectures }}
53+
54+
- name: List pushed images
55+
if: ${{ always() }}
56+
shell: bash
57+
run: docker images -a
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Unit & Integration tests of Actions
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '.github/**'
7+
push:
8+
branches:
9+
- "main"
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
lint:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v6
19+
- uses: docker://rhysd/actionlint:1.7.10
20+
with:
21+
args: -color

.github/workflows/build.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
- "release-*"
8+
tags:
9+
- "*"
10+
pull_request:
11+
branches:
12+
- "*"
13+
14+
# Declare default permissions as read only
15+
permissions:
16+
contents: read
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
prepare:
24+
name: Prepare Kafka Binaries
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v6
28+
- uses: ./.github/actions/build/prepare-kafka
29+
with:
30+
runnerArch: "amd64"
31+
32+
build-containers:
33+
name: Build Containers
34+
needs:
35+
- prepare
36+
strategy:
37+
matrix:
38+
architecture:
39+
- amd64
40+
- arm64
41+
- s390x
42+
- ppc64le
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v6
46+
- uses: ./.github/actions/build/build-containers
47+
with:
48+
architecture: ${{ matrix.architecture }}
49+
runnerArch: "amd64"
50+
51+
push-containers:
52+
name: Push Containers
53+
needs:
54+
- build-containers
55+
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v6
59+
- uses: ./.github/actions/build/push-containers
60+
with:
61+
architectures: "amd64 arm64 s390x ppc64le"
62+
runnerArch: "amd64"
63+
quayUser: ${{ secrets.QUAY_USER }}
64+
quayPass: ${{ secrets.QUAY_PASS }}

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ IMAGE_TAG ?= main
88
DOCKER_VERSION_ARG ?= latest
99
ARCHS ?= amd64
1010
DOCKER_CMD ?= docker
11+
ARCHIVE_DIR ?= ./container-archives
1112

1213
all: docker_prepare_base_images prepare docker_build docker_tag_push clean
1314

@@ -17,6 +18,12 @@ docker_prepare_base_images:
1718
docker_build:
1819
./images/build_push_images.sh $(DOCKER_VERSION_ARG) $(PROJECT_NAME) $(DOCKERFILE_DIR) "$(ARCHS)" $(DOCKER_CMD)
1920

21+
docker_save:
22+
./images/save_images.sh $(PROJECT_NAME) "$(ARCHS)" $(DOCKER_CMD) $(ARCHIVE_DIR)
23+
24+
docker_load:
25+
./images/load_images.sh $(PROJECT_NAME) "$(ARCHS)" $(DOCKER_CMD) $(ARCHIVE_DIR)
26+
2027
docker_tag_push:
2128
./images/tag_push_images.sh $(PROJECT_NAME) $(REGISTRY) $(REGISTRY_ORGANIZATION) $(QUAY_USER) $(QUAY_PASS) "$(ARCHS)" $(DOCKER_CMD)
2229

@@ -25,4 +32,5 @@ prepare: clean
2532

2633
clean:
2734
rm -rf images/kafka_binaries || true
28-
rm -rf images/kafka_tars || true
35+
rm -rf images/kafka_tars || true
36+
rm -rf $(ARCHIVE_DIR) || true

images/load_images.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
#####
4+
# SUPPORTED KAFKA VERSIONS
5+
#####
6+
KAFKA_VERSIONS=$(cat supported_kafka.versions)
7+
8+
#####
9+
# PRODUCT VERSION
10+
#####
11+
PRODUCT_VERSION=$(cat release.version)
12+
13+
#####
14+
# DOCKER AND PROJECT auxiliary variables
15+
#####
16+
PROJECT_NAME=$1
17+
ARCHITECTURES=$2
18+
DOCKER_CMD=$3
19+
ARCHIVE_DIR=${4:-./container-archives}
20+
21+
#####
22+
# FOR EACH KAFKA VERSION LOAD IMAGE
23+
#####
24+
for KAFKA_VERSION in $KAFKA_VERSIONS
25+
do
26+
CURRENT_TAG="$PRODUCT_VERSION-kafka-$KAFKA_VERSION"
27+
for ARCH in $ARCHITECTURES
28+
do
29+
ARCHIVE_NAME="$PROJECT_NAME-$CURRENT_TAG-$ARCH.tar.gz"
30+
echo "[INFO] Loading image from: $ARCHIVE_DIR/$ARCHIVE_NAME"
31+
$DOCKER_CMD load < $ARCHIVE_DIR/$ARCHIVE_NAME
32+
done
33+
done
34+
35+
echo "Finished loading images."

images/save_images.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
#####
4+
# SUPPORTED KAFKA VERSIONS
5+
#####
6+
KAFKA_VERSIONS=$(cat supported_kafka.versions)
7+
8+
#####
9+
# PRODUCT VERSION
10+
#####
11+
PRODUCT_VERSION=$(cat release.version)
12+
13+
#####
14+
# DOCKER AND PROJECT auxiliary variables
15+
#####
16+
PROJECT_NAME=$1
17+
ARCHITECTURES=$2
18+
DOCKER_CMD=$3
19+
ARCHIVE_DIR=${4:-./container-archives}
20+
21+
# Create archive directory if it doesn't exist
22+
mkdir -p $ARCHIVE_DIR
23+
24+
#####
25+
# FOR EACH KAFKA VERSION SAVE IMAGE
26+
#####
27+
for KAFKA_VERSION in $KAFKA_VERSIONS
28+
do
29+
CURRENT_TAG="$PRODUCT_VERSION-kafka-$KAFKA_VERSION"
30+
for ARCH in $ARCHITECTURES
31+
do
32+
IMAGE_NAME="strimzi/$PROJECT_NAME:$CURRENT_TAG-$ARCH"
33+
ARCHIVE_NAME="$PROJECT_NAME-$CURRENT_TAG-$ARCH.tar.gz"
34+
echo "[INFO] Saving image: $IMAGE_NAME to $ARCHIVE_DIR/$ARCHIVE_NAME"
35+
$DOCKER_CMD save $IMAGE_NAME | gzip > $ARCHIVE_DIR/$ARCHIVE_NAME
36+
done
37+
done
38+
39+
echo "Finished saving images."

0 commit comments

Comments
 (0)