Skip to content

Commit 1421927

Browse files
authored
backport .github/workflows from develop to v1.17.x (#694)
* backport .github/workflows from develop branch (upcoming v2) * update changelog * revert github workflows to jdk 17 to match pom * revert maven-verify workflow to mongodb * try using mongo 8 in maven-verify workflow to prevent 'Error: Command failed: sudo systemctl start mongod' see ankane/setup-mongodb#6 looks like mongo 8 is the lowest version supported by ankane/setup-mongodb for ubuntu 24 runners: https://github.com/ankane/setup-mongodb?tab=readme-ov-file#versions * match mongo-setup db version to github runner version * check with preliminary changes to maven-verify workflow * Revert "check with preliminary changes to maven-verify workflow" This reverts commit ce3177d. the preliminary workflow resulted in successful tests, so we can patch the maven-verify workflow v2 (in the github-workflows repo) * revert Dockerfile base images to from alpine to focal to prevent error "no match for platform in manifest" when building for arm64 architecture * adapt adduser command to ubuntu (focal) in Dockerfile because the commands and option flags differ between alpine and focal we can now use adduser to create both user and group in one go (see man adduser)
1 parent 16acdb2 commit 1421927

File tree

7 files changed

+95
-182
lines changed

7 files changed

+95
-182
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 164 deletions
This file was deleted.

.github/workflows/code-style.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ name: "Code Style"
22

33
on:
44
push:
5+
branches:
6+
- develop
57
pull_request:
68

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
713
jobs:
814

915
checkstyle:
@@ -16,10 +22,10 @@ jobs:
1622

1723
steps:
1824
- name: Checkout repository
19-
uses: actions/checkout@v3
25+
uses: actions/checkout@v4
2026

2127
- name: Setup Java
22-
uses: actions/setup-java@v3
28+
uses: actions/setup-java@v4
2329
with:
2430
distribution: ${{ env.JAVA_DISTRIBUTION }}
2531
java-version: ${{ env.JAVA_VERSION }}
@@ -43,10 +49,10 @@ jobs:
4349

4450
steps:
4551
- name: Checkout repository
46-
uses: actions/checkout@v3
52+
uses: actions/checkout@v4
4753

4854
- name: Setup Java
49-
uses: actions/setup-java@v3
55+
uses: actions/setup-java@v4
5056
with:
5157
distribution: ${{ env.JAVA_DISTRIBUTION }}
5258
java-version: ${{ env.JAVA_VERSION }}
@@ -70,10 +76,10 @@ jobs:
7076

7177
steps:
7278
- name: Checkout repository
73-
uses: actions/checkout@v3
79+
uses: actions/checkout@v4
7480

7581
- name: Setup Java
76-
uses: actions/setup-java@v3
82+
uses: actions/setup-java@v4
7783
with:
7884
distribution: ${{ env.JAVA_DISTRIBUTION }}
7985
java-version: ${{ env.JAVA_VERSION }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish to Docker Hub
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
pull_request:
8+
release:
9+
types:
10+
- created
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
verify:
18+
uses: FAIRDataTeam/github-workflows/.github/workflows/maven-verify.yml@v2
19+
with:
20+
java-version: 17
21+
# todo: enable tests when test duration has been minimized
22+
mvn-options: "-DskipTests"
23+
publish:
24+
needs: verify
25+
uses: FAIRDataTeam/github-workflows/.github/workflows/docker-publish.yml@v2
26+
secrets: inherit
27+
with:
28+
file: './Dockerfile'
29+
push: ${{ github.event_name == 'push' || github.event_name == 'release' }}

.github/workflows/maven-verify.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-maven
2+
3+
name: Maven verify
4+
5+
on:
6+
push:
7+
branches:
8+
- develop
9+
pull_request:
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
test:
18+
strategy:
19+
matrix:
20+
runner:
21+
# https://github.com/ankane/setup-mongodb?tab=readme-ov-file#versions
22+
- os: ubuntu-24.04
23+
mongo: 8
24+
- os: windows-2022
25+
mongo: 5
26+
- os: macos-14
27+
mongo: 8
28+
java-version:
29+
- 17
30+
uses: FAIRDataTeam/github-workflows/.github/workflows/maven-verify.yml@v2
31+
with:
32+
runner: ${{ matrix.runner.os }}
33+
java-version: ${{ matrix.java-version }}
34+
# db settings must match testing profile
35+
db-type: mongodb
36+
db-version: ${{ matrix.runner.mongo }} # see https://github.com/ankane/setup-mongodb/issues/6

.github/workflows/security.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ name: "Security Audit"
22

33
on:
44
push:
5-
branches: [ develop, master ]
5+
branches:
6+
- develop
67
pull_request:
7-
branches: [ develop ]
88
schedule:
99
- cron: '23 4 * * 1'
1010

11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
1115
jobs:
1216
codeql:
1317
name: CodeQL
@@ -23,10 +27,10 @@ jobs:
2327

2428
steps:
2529
- name: Checkout repository
26-
uses: actions/checkout@v3
30+
uses: actions/checkout@v4
2731

2832
- name: Setup Java
29-
uses: actions/setup-java@v3
33+
uses: actions/setup-java@v4
3034
with:
3135
distribution: ${{ env.JAVA_DISTRIBUTION }}
3236
java-version: ${{ env.JAVA_VERSION }}
@@ -37,7 +41,7 @@ jobs:
3741
mvn --version
3842
3943
- name: Initialize CodeQL
40-
uses: github/codeql-action/init@v2
44+
uses: github/codeql-action/init@v3
4145
with:
4246
languages: 'java'
4347

@@ -46,7 +50,7 @@ jobs:
4650
mvn --quiet -B -U --fail-fast -DskipTests package
4751
4852
- name: Perform CodeQL Analysis
49-
uses: github/codeql-action/analyze@v2
53+
uses: github/codeql-action/analyze@v3
5054

5155
snyk:
5256
name: Snyk (Maven)
@@ -59,7 +63,7 @@ jobs:
5963
steps:
6064

6165
- name: Checkout repository
62-
uses: actions/checkout@v3
66+
uses: actions/checkout@v4
6367

6468
- name: Perform Snyk Check (Maven)
6569
uses: snyk/actions/maven@master
@@ -83,12 +87,12 @@ jobs:
8387
steps:
8488

8589
- name: Checkout repository
86-
uses: actions/checkout@v3
90+
uses: actions/checkout@v4
8791

8892
- name: Docker build
8993
run: |
9094
docker pull $PUBLIC_IMAGE:$TAG_DEVELOP
91-
docker build --cache-from $PUBLIC_IMAGE:$TAG_DEVELOP -t fdp:snyk-test -f Dockerfile.build .
95+
docker build --cache-from $PUBLIC_IMAGE:$TAG_DEVELOP -t fdp:snyk-test -f Dockerfile .
9296
9397
- name: Perform Snyk Check (Docker)
9498
uses: snyk/actions/docker@master

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1414
### Changed
1515

1616
- Cleaned up Dockerfile (backport)
17+
- Separate Github workflows for test and publish (backport)
1718

1819
## [1.17.2]
1920

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
################################################################################
55
# BUILD JAR
66

7-
FROM maven:3-eclipse-temurin-17-alpine AS builder
7+
FROM maven:3-eclipse-temurin-17-focal AS builder
88

99
WORKDIR /builder
1010

@@ -16,11 +16,12 @@ RUN mvn --quiet --batch-mode --update-snapshots --fail-fast -DskipTests package
1616
################################################################################
1717
# BUILD IMAGE
1818

19-
FROM eclipse-temurin:17-jdk-alpine
19+
FROM eclipse-temurin:17-jdk-focal
2020

2121
# add non-root user to run the app
2222
# https://spring.io/guides/gs/spring-boot-docker
23-
RUN addgroup -S spring && adduser -S spring -G spring
23+
# on ubuntu the following creates a group with the same name as user
24+
RUN adduser spring --system --group
2425
USER spring:spring
2526

2627
WORKDIR /fdp

0 commit comments

Comments
 (0)