Skip to content

Commit 2ab6903

Browse files
committed
chore: prepare ci 3.9.5.1
1 parent 8a42099 commit 2ab6903

3 files changed

Lines changed: 225 additions & 41 deletions

File tree

.github/Dockerfile.ci

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM eclipse-temurin:21-jdk-jammy
2+
3+
ARG MAVEN_VERSION=3.9.9
4+
5+
RUN apt-get update && apt-get install -y --no-install-recommends \
6+
libcppunit-dev \
7+
libsasl2-dev \
8+
build-essential \
9+
autoconf \
10+
automake \
11+
libtool \
12+
pkg-config \
13+
git \
14+
curl \
15+
&& curl -fsSL https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
16+
| tar -xz -C /opt \
17+
&& ln -s /opt/apache-maven-${MAVEN_VERSION}/bin/mvn /usr/local/bin/mvn \
18+
&& rm -rf /var/lib/apt/lists/*

.github/workflows/ci.yaml

Lines changed: 103 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,74 +15,136 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
# This workflow will build a Java project with Maven
19-
# See also:
20-
# https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
21-
2218
name: CI
2319

2420
on:
2521
push:
26-
branches: [ '*' ]
22+
branches: ['develop/**', 'release/**', 'master']
2723
pull_request:
28-
branches: [ '*' ]
24+
branches: ['develop/**', 'release/**', 'master']
25+
26+
concurrency:
27+
group: ${{ github.workflow }}-${{ github.ref }}
28+
cancel-in-progress: true
29+
30+
permissions:
31+
packages: write
32+
33+
env:
34+
IMAGE: ghcr.io/${{ github.repository }}/ci
2935

3036
jobs:
31-
mvn:
32-
strategy:
33-
matrix:
34-
profile:
35-
- name: 'full-build-jdk8'
36-
jdk: 8
37-
args: '-Pfull-build apache-rat:check verify -DskipTests spotbugs:check checkstyle:check'
38-
- name: 'full-build-jdk11'
39-
jdk: 11
40-
args: '-Pfull-build apache-rat:check verify -DskipTests spotbugs:check checkstyle:check'
41-
- name: 'full-build-java-tests'
42-
jdk: 11
43-
args: '-Pfull-build verify -Dsurefire-forkcount=1 -DskipCppUnit -Dsurefire.rerunFailingTestsCount=5'
44-
- name: 'full-build-cppunit-tests'
45-
jdk: 11
46-
args: '-Pfull-build verify -Dtest=_ -DfailIfNoTests=false'
47-
fail-fast: false
48-
timeout-minutes: 360
37+
ci-image:
38+
name: CI Image
4939
runs-on: ubuntu-latest
40+
outputs:
41+
image: ${{ steps.result.outputs.image }}
5042
steps:
5143
- uses: actions/checkout@v4
52-
- name: Set up JDK ${{ matrix.profile.jdk }}
53-
uses: actions/setup-java@v4
44+
45+
- id: tag
46+
name: Compute image tag
47+
run: |
48+
TAG=$(sha256sum .github/Dockerfile.ci | cut -c1-12)
49+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
50+
echo "image=${{ env.IMAGE }}:$TAG" >> "$GITHUB_OUTPUT"
51+
52+
- uses: docker/login-action@v3
5453
with:
55-
java-version: ${{ matrix.profile.jdk }}
56-
distribution: temurin
57-
cache: 'maven'
58-
- name: Show the first log message
59-
run: git log -n1
60-
- name: Install C Dependencies
54+
registry: ghcr.io
55+
username: ${{ github.actor }}
56+
password: ${{ secrets.GITHUB_TOKEN }}
57+
58+
- name: Check if image exists
59+
id: check
6160
run: |
62-
sudo apt update
63-
sudo apt install -y libcppunit-dev libsasl2-dev
64-
- name: Build with Maven (${{ matrix.profile.name }})
65-
run: mvn -B -V -e -ntp "-Dstyle.color=always" ${{ matrix.profile.args }}
66-
env:
67-
MAVEN_OPTS: -Djansi.force=true
61+
if docker manifest inspect ${{ steps.tag.outputs.image }} > /dev/null 2>&1; then
62+
echo "exists=true" >> "$GITHUB_OUTPUT"
63+
else
64+
echo "exists=false" >> "$GITHUB_OUTPUT"
65+
fi
66+
67+
- if: steps.check.outputs.exists == 'false'
68+
uses: docker/build-push-action@v6
69+
with:
70+
context: .github
71+
file: .github/Dockerfile.ci
72+
push: true
73+
tags: |
74+
${{ steps.tag.outputs.image }}
75+
${{ env.IMAGE }}:latest
76+
77+
- id: result
78+
run: echo "image=${{ steps.tag.outputs.image }}" >> "$GITHUB_OUTPUT"
79+
80+
compile:
81+
name: Compile + Checkstyle
82+
runs-on: ubuntu-latest
83+
needs: ci-image
84+
container: ${{ needs.ci-image.outputs.image }}
85+
timeout-minutes: 30
86+
steps:
87+
- uses: actions/checkout@v4
88+
- name: Cache Maven repository
89+
uses: actions/cache@v4
90+
with:
91+
path: ~/.m2/repository
92+
key: maven-${{ hashFiles('**/pom.xml') }}
93+
restore-keys: maven-
94+
- name: Compile and check style
95+
run: mvn -B -V -e -ntp -Pfull-build verify -DskipTests checkstyle:check
96+
97+
java-tests:
98+
name: Java Tests
99+
runs-on: ubuntu-latest
100+
needs: [ci-image, compile]
101+
container: ${{ needs.ci-image.outputs.image }}
102+
timeout-minutes: 120
103+
steps:
104+
- uses: actions/checkout@v4
105+
- name: Cache Maven repository
106+
uses: actions/cache@v4
107+
with:
108+
path: ~/.m2/repository
109+
key: maven-${{ hashFiles('**/pom.xml') }}
110+
restore-keys: maven-
111+
- name: Run Java tests
112+
run: mvn -B -V -e -ntp -Pfull-build verify -Dsurefire-forkcount=1 -DskipCppUnit
68113
- name: Upload unit test results
69114
if: ${{ failure() }}
70115
uses: actions/upload-artifact@v4
71116
with:
72-
name: surefire-reports-${{ matrix.profile.name }}
117+
name: surefire-reports
73118
path: ./**/target/surefire-reports/
74119
if-no-files-found: ignore
75120
- name: Upload integration test results
76121
if: ${{ failure() }}
77122
uses: actions/upload-artifact@v4
78123
with:
79-
name: failsafe-reports-${{ matrix.profile.name }}
124+
name: failsafe-reports
80125
path: ./**/target/failsafe-reports/
81126
if-no-files-found: ignore
127+
128+
c-tests:
129+
name: C Tests
130+
runs-on: ubuntu-latest
131+
needs: [ci-image, compile]
132+
container: ${{ needs.ci-image.outputs.image }}
133+
timeout-minutes: 30
134+
steps:
135+
- uses: actions/checkout@v4
136+
- name: Cache Maven repository
137+
uses: actions/cache@v4
138+
with:
139+
path: ~/.m2/repository
140+
key: maven-${{ hashFiles('**/pom.xml') }}
141+
restore-keys: maven-
142+
- name: Run C tests
143+
run: mvn -B -V -e -ntp -Pfull-build verify -Dtest=_ -Dsurefire.failIfNoSpecifiedTests=false
82144
- name: Upload cppunit test logs
83145
if: ${{ failure() }}
84146
uses: actions/upload-artifact@v4
85147
with:
86-
name: cppunit-logs-${{ matrix.profile.name }}
148+
name: cppunit-logs
87149
path: ./zookeeper-client/zookeeper-client-c/target/c/TEST-*.txt
88150
if-no-files-found: ignore

.github/workflows/release.yaml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: Release
19+
20+
on:
21+
push:
22+
tags: ['v*']
23+
24+
permissions:
25+
contents: write
26+
packages: write
27+
28+
jobs:
29+
release:
30+
name: Build and Release
31+
runs-on: ubuntu-latest
32+
timeout-minutes: 60
33+
steps:
34+
- uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Verify tag is on release branch
39+
run: |
40+
BRANCHES=$(git branch -r --contains ${{ github.sha }} | grep 'origin/release/' || true)
41+
if [ -z "$BRANCHES" ]; then
42+
echo "Tag must be on a release/** branch. Found on:"
43+
git branch -r --contains ${{ github.sha }}
44+
exit 1
45+
fi
46+
echo "Tag is on: $BRANCHES"
47+
48+
- name: Verify CI passed
49+
run: |
50+
CONCLUSION=$(gh run list --commit ${{ github.sha }} --workflow CI --json conclusion -q '.[0].conclusion')
51+
if [ -z "$CONCLUSION" ]; then
52+
echo "No CI run found for this commit. Push to release/** branch first."
53+
exit 1
54+
fi
55+
if [ "$CONCLUSION" != "success" ]; then
56+
echo "CI has not passed for this commit (status: $CONCLUSION)"
57+
exit 1
58+
fi
59+
echo "CI passed"
60+
env:
61+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
63+
- uses: actions/setup-java@v4
64+
with:
65+
java-version: 21
66+
distribution: temurin
67+
cache: maven
68+
69+
- name: Install C Dependencies
70+
run: |
71+
sudo apt update
72+
sudo apt install -y libcppunit-dev libsasl2-dev
73+
74+
- name: Build and Deploy to GitHub Packages
75+
run: mvn -B -V -ntp -Pfull-build deploy -DskipTests
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
79+
- name: Generate checksums
80+
run: |
81+
cd zookeeper-assembly/target
82+
for f in apache-zookeeper-*.tar.gz; do
83+
sha512sum "$f" > "${f}.sha512"
84+
done
85+
86+
- name: Vulnerability scan (grype)
87+
uses: anchore/scan-action@v6
88+
with:
89+
sbom: zookeeper-assembly/target/bom.json
90+
fail-build: false
91+
output-format: json
92+
output-file: vulnerability-report.json
93+
94+
- name: Create GitHub Release
95+
uses: softprops/action-gh-release@v2
96+
with:
97+
generate_release_notes: true
98+
files: |
99+
zookeeper-assembly/target/apache-zookeeper-*-bin.tar.gz
100+
zookeeper-assembly/target/apache-zookeeper-*-bin.tar.gz.sha512
101+
zookeeper-assembly/target/apache-zookeeper-*-lib.tar.gz
102+
zookeeper-assembly/target/apache-zookeeper-*-lib.tar.gz.sha512
103+
zookeeper-assembly/target/bom.json
104+
vulnerability-report.json

0 commit comments

Comments
 (0)