Skip to content

Commit 3d2bc08

Browse files
authored
Merge pull request #3842 from jacomago/github-ci-extend
GitHub ci extend
2 parents abb29f3 + a81c2eb commit 3d2bc08

48 files changed

Lines changed: 595 additions & 503 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CI_VERSIONS.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# CI version pins
2+
3+
Some versions used by CI are pinned manually and must be kept current. This
4+
file is the checklist of what needs periodic review and where each pin lives.
5+
6+
| What | Version | Defined in | Notes |
7+
|------|---------|------------|-------|
8+
| Java (JDK) | `21` | `.github/actions/setup-java/action.yml` | Single source of truth for the CI JDK. Must match `maven.compiler.source`/`maven.compiler.target` in `pom.xml`. Review when the project adopts a new LTS. |
9+
| Elasticsearch | `8.11.2` | `.github/workflows/_integration-test.yml` and `services/save-and-restore/docker-compose.yml` | Service container for the save-and-restore integration tests. Update both files together. |
10+
11+
## Automatically maintained
12+
13+
GitHub Action versions (the `uses:` refs in `.github/workflows/*` and
14+
`.github/actions/**`) are bumped by Dependabot — see `.github/dependabot.yml`.
15+
These do **not** need manual tracking here.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Set up Java
2+
description: Set up the project's pinned JDK with Maven dependency caching.
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- uses: actions/setup-java@ad2b38190b15e4d6bdf0c97fb4fca8412226d287
8+
with:
9+
distribution: temurin
10+
java-version: '21'
11+
cache: maven

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
# Auto-PR bumps for GitHub Action versions referenced in .github/workflows/*
4+
# and in the local composite action (.github/actions/**). The JDK and
5+
# Elasticsearch pins are not visible to Dependabot; see .github/CI_VERSIONS.md.
6+
- package-ecosystem: github-actions
7+
directory: /
8+
schedule:
9+
interval: weekly
10+
cooldown:
11+
default-days: 7

.github/workflows/_build.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
description: Runner to build on.
8+
type: string
9+
default: ubuntu-latest
10+
upload-artifacts:
11+
description: Upload the product tarball/zip (used by the master build).
12+
type: boolean
13+
default: false
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
build:
20+
runs-on: ${{ inputs.os }}
21+
steps:
22+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
23+
with:
24+
persist-credentials: false
25+
- name: Set up Java
26+
uses: ./.github/actions/setup-java
27+
- name: Build
28+
run: mvn --batch-mode install -DskipTests
29+
- name: Archive build artifacts
30+
if: ${{ inputs.upload-artifacts }}
31+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
32+
with:
33+
name: Phoebus product ${{ inputs.os }}
34+
path: |
35+
${{ github.workspace }}/phoebus-product/target/*.tar.gz
36+
${{ github.workspace }}/phoebus-product/target/*.zip
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Docker image
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
image-suffix:
7+
description: Image name under ghcr.io/<owner>/<repo>/ (e.g. service-alarm-server).
8+
required: true
9+
type: string
10+
context:
11+
description: Docker build context directory.
12+
required: true
13+
type: string
14+
maven-args:
15+
description: Maven goals/flags for the package step.
16+
type: string
17+
default: --update-snapshots package
18+
19+
permissions:
20+
contents: read
21+
packages: write
22+
23+
jobs:
24+
build-and-push-image:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
28+
with:
29+
persist-credentials: false
30+
- name: Set up Java
31+
uses: ./.github/actions/setup-java
32+
- name: Build with Maven
33+
run: mvn --batch-mode $MAVEN_ARGS
34+
env:
35+
MAVEN_ARGS: ${{ inputs.maven-args }}
36+
- name: Login to the registry
37+
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee
38+
with:
39+
registry: ghcr.io
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
- name: Extract meta-data for Docker
43+
id: meta
44+
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9
45+
with:
46+
images: ghcr.io/${{ github.repository }}/${{ inputs.image-suffix }}
47+
- name: Set up Docker Build
48+
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5
49+
- name: Build and publish the Docker image
50+
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf
51+
with:
52+
context: ${{ inputs.context }}
53+
push: true
54+
platforms: linux/amd64,linux/arm64
55+
tags: ${{ steps.meta.outputs.tags }}
56+
labels: ${{ steps.meta.outputs.labels }}
57+
cache-from: type=gha
58+
cache-to: type=gha,mode=max
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Integration test
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
integration-test:
11+
runs-on: ubuntu-latest
12+
services:
13+
# TODO swap to testcontainers for integration tests
14+
elasticsearch:
15+
image: docker.elastic.co/elasticsearch/elasticsearch:8.11.2
16+
env:
17+
discovery.type: single-node
18+
xpack.security.enabled: "false"
19+
ports:
20+
- 9200:9200
21+
options: >-
22+
--health-cmd "curl -s http://localhost:9200/_cluster/health || exit 1"
23+
--health-interval 10s
24+
--health-timeout 5s
25+
--health-retries 30
26+
steps:
27+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
28+
with:
29+
persist-credentials: false
30+
- name: Set up Java
31+
uses: ./.github/actions/setup-java
32+
- name: Integration tests (Elasticsearch-backed)
33+
run: >
34+
mvn --batch-mode install -P it-tests,docker-tests
35+
-Dskip-executable-jar
36+
-pl services/save-and-restore -am
37+
- name: Upload integration test reports
38+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
39+
if: always()
40+
with:
41+
name: integration-test-reports
42+
path: services/save-and-restore/target/failsafe-reports/**
43+
if-no-files-found: ignore

.github/workflows/_lint.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: pre-commit
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
pre-commit:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
14+
with:
15+
persist-credentials: false
16+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
17+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd

.github/workflows/_test.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
name:
7+
description: Name used for the uploaded report artifact.
8+
type: string
9+
required: true
10+
run:
11+
description: Command that runs the tests.
12+
type: string
13+
required: true
14+
report-path:
15+
description: Glob for the test reports to upload.
16+
type: string
17+
required: true
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
test:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
27+
with:
28+
persist-credentials: false
29+
- name: Set up Java
30+
uses: ./.github/actions/setup-java
31+
- name: Test
32+
run: $TEST_COMMAND
33+
env:
34+
TEST_COMMAND: ${{ inputs.run }}
35+
- name: Upload test reports
36+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
37+
if: always()
38+
with:
39+
name: ${{ inputs.name }}-reports
40+
path: ${{ inputs.report-path }}
41+
if-no-files-found: ignore

.github/workflows/_ui-test.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: UI test
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
ui-test:
11+
uses: ./.github/workflows/_test.yml
12+
with:
13+
name: ui-test
14+
run: xvfb-run -a mvn --batch-mode --fail-at-end verify -P ui-tests
15+
report-path: '**/target/failsafe-reports/**'

.github/workflows/_unit-test.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Unit test
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
unit-test:
11+
uses: ./.github/workflows/_test.yml
12+
with:
13+
name: unit-test
14+
run: mvn --batch-mode --fail-at-end verify
15+
report-path: '**/target/surefire-reports/**'

0 commit comments

Comments
 (0)