Skip to content

Commit 399a19f

Browse files
authored
Add GitHub Actions (#295)
Signed-off-by: Jakub Stejskal <xstejs24@gmail.com>
1 parent df4cd91 commit 399a19f

9 files changed

Lines changed: 396 additions & 19 deletions

File tree

.azure/build-pipeline.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ stages:
1616
displayName: Java build
1717
jobs:
1818
- template: 'templates/jobs/build_java.yaml'
19-
- stage: java_deploy
20-
displayName: Deploy Java
21-
condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/main'))
22-
jobs:
23-
- template: 'templates/jobs/deploy_java.yaml'
24-
parameters:
25-
artifactSource: 'current'
26-
artifactProject: 'strimzi'
27-
artifactPipeline: ''
28-
artifactRunVersion: ''
29-
artifactRunId: ''
19+
# - stage: java_deploy
20+
# displayName: Deploy Java
21+
# condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/main'))
22+
# jobs:
23+
# - template: 'templates/jobs/deploy_java.yaml'
24+
# parameters:
25+
# artifactSource: 'current'
26+
# artifactProject: 'strimzi'
27+
# artifactPipeline: ''
28+
# artifactRunVersion: ''
29+
# artifactRunId: ''

.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: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: "Build Kafka OAuth Binaries"
2+
description: "Build and test kafka-oauth binaries"
3+
4+
inputs:
5+
javaVersion:
6+
description: "Java version"
7+
required: false
8+
default: "17"
9+
runnerArch:
10+
description: "Architecture of GitHub runner"
11+
required: false
12+
default: "amd64"
13+
mainBuild:
14+
description: "Whether this is the main build"
15+
required: false
16+
default: "false"
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- name: Setup Java
22+
uses: strimzi/strimzi-kafka-operator/.github/actions/dependencies/setup-java@main
23+
with:
24+
javaVersion: ${{ inputs.javaVersion }}
25+
26+
- name: Restore Maven cache
27+
uses: actions/cache/restore@v5
28+
with:
29+
path: ~/.m2/repository
30+
key: maven-${{ hashFiles('**/pom.xml') }}
31+
restore-keys: |
32+
maven-
33+
34+
- name: Build & Test Java
35+
shell: bash
36+
run: mvn -e -V -B install
37+
env:
38+
BUILD_REASON: ${{ github.event_name }}
39+
BRANCH: ${{ github.ref }}
40+
TESTCONTAINERS_RYUK_DISABLED: "TRUE"
41+
TESTCONTAINERS_CHECKS_DISABLE: "TRUE"
42+
43+
- name: Run Spotbugs
44+
shell: bash
45+
run: mvn -e -V -B spotbugs:check
46+
47+
- name: Test Docker Examples
48+
shell: bash
49+
run: mvn -e -V -B clean install -f examples/docker --no-transfer-progress
50+
51+
- name: Test Spring Example
52+
shell: bash
53+
run: |
54+
cd examples/docker
55+
./spring/test-spring.sh
56+
57+
- name: Modify /etc/hosts for tests
58+
shell: bash
59+
run: |
60+
echo "127.0.0.1 keycloak" | sudo tee -a /etc/hosts
61+
echo "127.0.0.1 hydra" | sudo tee -a /etc/hosts
62+
echo "127.0.0.1 hydra-jwt" | sudo tee -a /etc/hosts
63+
echo "127.0.0.1 kafka" | sudo tee -a /etc/hosts
64+
echo "127.0.0.1 mockoauth" | sudo tee -a /etc/hosts
65+
echo "127.0.0.1 kerberos" | sudo tee -a /etc/hosts
66+
echo "Modified /etc/hosts:"
67+
cat /etc/hosts
68+
69+
- name: Install Docker Compose
70+
shell: bash
71+
run: |
72+
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
73+
sudo chmod +x /usr/local/bin/docker-compose
74+
75+
- name: Testsuite Compile & Spotbugs
76+
shell: bash
77+
run: mvn -e -V -B test-compile spotbugs:check -f testsuite
78+
79+
- name: Run Testsuite
80+
shell: bash
81+
run: mvn -e -V -B install -f testsuite --no-transfer-progress
82+
83+
- name: Create tarball with target directory
84+
shell: bash
85+
run: tar -cvpf oauth.tar ./target
86+
87+
- name: Upload binaries artifact
88+
if: ${{ inputs.mainBuild == 'true' }}
89+
uses: actions/upload-artifact@v5
90+
with:
91+
name: oauth.tar
92+
path: oauth.tar
93+
94+
- name: Upload binaries artifact with Java version
95+
uses: actions/upload-artifact@v5
96+
with:
97+
name: oauth-java-${{ inputs.javaVersion }}.tar
98+
path: oauth.tar
99+
100+
- name: Clean external SNAPSHOT dependencies from Maven repository
101+
if: github.ref == 'refs/heads/main'
102+
shell: bash
103+
run: |
104+
mvn dependency:purge-local-repository \
105+
-DsnapshotsOnly=true \
106+
-DreResolve=false || true
107+
108+
- name: Save Maven cache
109+
if: github.ref == 'refs/heads/main' && inputs.mainBuild == 'true'
110+
uses: actions/cache/save@v5
111+
with:
112+
path: ~/.m2/repository
113+
key: maven-${{ hashFiles('**/pom.xml') }}
114+
115+
- name: Publish test results
116+
uses: dorny/test-reporter@v2
117+
if: always()
118+
with:
119+
name: 'Unit & Integration Tests'
120+
path: '**/TEST-*.xml'
121+
reporter: java-junit
122+
fail-on-error: false
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: "Deploy Java Artifacts"
2+
description: "Deploys Java artifacts to Maven Central"
3+
4+
inputs:
5+
javaVersion:
6+
description: "Java version"
7+
required: false
8+
default: "17"
9+
runnerArch:
10+
description: "Runner architecture (amd64, arm64)"
11+
required: false
12+
default: "amd64"
13+
gpgPassphrase:
14+
description: "GPG passphrase for signing"
15+
required: true
16+
gpgSigningKey:
17+
description: "GPG signing key"
18+
required: true
19+
centralUsername:
20+
description: "Maven Central username"
21+
required: true
22+
centralPassword:
23+
description: "Maven Central password"
24+
required: true
25+
26+
runs:
27+
using: "composite"
28+
steps:
29+
- name: Setup Java and Maven
30+
uses: strimzi/strimzi-kafka-operator/.github/actions/dependencies/setup-java@main
31+
with:
32+
javaVersion: ${{ inputs.javaVersion }}
33+
34+
- name: Restore Maven cache
35+
uses: actions/cache/restore@v5
36+
with:
37+
path: ~/.m2/repository
38+
key: maven-${{ hashFiles('**/pom.xml') }}
39+
restore-keys: |
40+
maven-
41+
42+
- name: Download binaries from build
43+
uses: actions/download-artifact@v7
44+
with:
45+
name: oauth.tar
46+
47+
- name: Extract target directory
48+
shell: bash
49+
run: tar -xvf oauth.tar
50+
51+
- name: Deploy Java artifacts
52+
shell: bash
53+
run: ./.azure/scripts/push-to-central.sh
54+
env:
55+
BUILD_REASON: "IndividualCI"
56+
BRANCH: ${{ github.ref }}
57+
GPG_PASSPHRASE: ${{ inputs.gpgPassphrase }}
58+
GPG_SIGNING_KEY: ${{ inputs.gpgSigningKey }}
59+
CENTRAL_USERNAME: ${{ inputs.centralUsername }}
60+
CENTRAL_PASSWORD: ${{ inputs.centralPassword }}
61+
MVN_ARGS: "-e -V -B"
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: "Build Release Artifacts"
2+
description: "Builds and releases OAuth artifacts to Maven Central"
3+
4+
inputs:
5+
releaseVersion:
6+
description: "Release version (e.g., 0.15.0)"
7+
required: true
8+
runnerArch:
9+
description: "Runner architecture (amd64, arm64)"
10+
required: false
11+
default: "amd64"
12+
gpgPassphrase:
13+
description: "GPG passphrase for signing"
14+
required: true
15+
gpgSigningKey:
16+
description: "GPG signing key"
17+
required: true
18+
centralUsername:
19+
description: "Maven Central username"
20+
required: true
21+
centralPassword:
22+
description: "Maven Central password"
23+
required: true
24+
25+
runs:
26+
using: "composite"
27+
steps:
28+
- name: Setup Java
29+
uses: strimzi/strimzi-kafka-operator/.github/actions/dependencies/setup-java@main
30+
with:
31+
javaVersion: "17"
32+
33+
- name: Restore Maven cache
34+
uses: actions/cache/restore@v5
35+
with:
36+
path: ~/.m2/repository
37+
key: maven-${{ hashFiles('**/pom.xml') }}
38+
restore-keys: |
39+
maven-
40+
41+
- name: Set release version
42+
shell: bash
43+
run: mvn versions:set -DnewVersion=${{ inputs.releaseVersion }}
44+
env:
45+
RELEASE_VERSION: ${{ inputs.releaseVersion }}
46+
47+
- name: Build Java artifacts
48+
shell: bash
49+
run: mvn -B install -DskipTests
50+
51+
- name: Deploy Java artifacts to Maven Central
52+
shell: bash
53+
run: ./.azure/scripts/push-to-central.sh
54+
env:
55+
BUILD_REASON: "IndividualCI"
56+
BRANCH: ${{ github.ref }}
57+
GPG_PASSPHRASE: ${{ inputs.gpgPassphrase }}
58+
GPG_SIGNING_KEY: ${{ inputs.gpgSigningKey }}
59+
CENTRAL_USERNAME: ${{ inputs.centralUsername }}
60+
CENTRAL_PASSWORD: ${{ inputs.centralPassword }}
61+
MVN_ARGS: "-e -V -B"
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: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
- "release-*"
8+
pull_request:
9+
branches:
10+
- "*"
11+
12+
# Declare default permissions as read only
13+
permissions:
14+
contents: read
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
build-kafka-oauth:
22+
name: Build & Test Kafka OAuth
23+
strategy:
24+
matrix:
25+
java:
26+
# Java 17 is used as default version
27+
# In case of adding new version make sure that build-containers and deploy-java has correct static version set
28+
- version: "17"
29+
mainBuild: true
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v6
33+
- uses: ./.github/actions/build/build-binaries
34+
with:
35+
javaVersion: ${{ matrix.java.version }}
36+
mainBuild: ${{ matrix.java.mainBuild }}
37+
runnerArch: "amd64"
38+
39+
deploy-java:
40+
name: Deploy Java artifacts to Maven Central
41+
needs:
42+
- build-kafka-oauth
43+
if: ${{ github.ref == 'refs/heads/main' }}
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v6
47+
- uses: ./.github/actions/build/deploy-java
48+
with:
49+
javaVersion: "17"
50+
runnerArch: "amd64"
51+
gpgPassphrase: ${{ secrets.GPG_PASSPHRASE }}
52+
gpgSigningKey: ${{ secrets.GPG_SIGNING_KEY }}
53+
centralUsername: ${{ secrets.CENTRAL_USERNAME }}
54+
centralPassword: ${{ secrets.CENTRAL_PASSWORD }}

0 commit comments

Comments
 (0)