Skip to content

Commit d1327ea

Browse files
authored
klass-forvaltning build and deploy (#209)
* klass-forvaltning Dockerfile * Add build and deploy workflow for klass-forvaltning * Get klass-forvaltning running locally * Simple nais manifest for klass-forvaltning * Trigger workflows on all branches for testing * Give workflows access to Github Packages * Use github profile and supply github token * Use older Maven version for klass-forvaltning * Build other projects when we build klass-api * Add image suffixes to differentiate * Consolidate proifle definition - Define profiles in .mv/settings.xml - Remove nexus profile as it's no longer needed - Always activate the GitHub profile - Remove some outdated files * Standardise on temurin java * Don't use older Maven in workflows * Add Maven authentication instructions * Use setup-java@v4 * Increase resource allocation * Fix macos test worfklow * Allow deploy workflows to run on PR for testing * Deploy workflows don't run on feature branches * Maven github profile is active by default
1 parent c69a374 commit d1327ea

21 files changed

+341
-351
lines changed

.eclipse_dictionary.txt

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

.github/workflows/codeql-analysis.yml

Lines changed: 45 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -34,66 +34,57 @@ jobs:
3434
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
3535

3636
steps:
37-
- name: Checkout repository
38-
uses: actions/checkout@v3
37+
- name: Checkout repository
38+
uses: actions/checkout@v3
3939

40-
- name: Set up JDK 17
41-
uses: actions/setup-java@v3
42-
with:
43-
distribution: 'zulu'
44-
java-version: '17'
45-
cache: maven
40+
- name: Set up JDK 17
41+
uses: actions/setup-java@v4
42+
with:
43+
distribution: 'temurin'
44+
java-version: '17'
45+
cache: maven
4646

47-
# Initializes the CodeQL tools for scanning.
48-
- name: Initialize CodeQL
49-
uses: github/codeql-action/init@v2
50-
with:
51-
languages: ${{ matrix.language }}
52-
# If you wish to specify custom queries, you can do so here or in a config file.
53-
# By default, queries listed here will override any specified in a config file.
54-
# Prefix the list here with "+" to use these queries and those in the config file.
55-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
47+
# Initializes the CodeQL tools for scanning.
48+
- name: Initialize CodeQL
49+
uses: github/codeql-action/init@v2
50+
with:
51+
languages: ${{ matrix.language }}
52+
# If you wish to specify custom queries, you can do so here or in a config file.
53+
# By default, queries listed here will override any specified in a config file.
54+
# Prefix the list here with "+" to use these queries and those in the config file.
55+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
5656

57-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
58-
# If this step fails, then you should remove it and run the build manually (see below)
59-
#- name: Autobuild
60-
# uses: github/codeql-action/autobuild@v1
57+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
58+
# If this step fails, then you should remove it and run the build manually (see below)
59+
#- name: Autobuild
60+
# uses: github/codeql-action/autobuild@v1
6161

62-
# ℹ️ Command-line programs to run using the OS shell.
63-
# 📚 https://git.io/JvXDl
62+
# ℹ️ Command-line programs to run using the OS shell.
63+
# 📚 https://git.io/JvXDl
6464

65-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
66-
# and modify them (or add more) to build your code if your project
67-
# uses a compiled language
65+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
66+
# and modify them (or add more) to build your code if your project
67+
# uses a compiled language
6868

69-
#- run: |
70-
# make bootstrap
71-
# make release
72-
# Build all modules except klass-forvaltning since it is not compatible with JDK 17
73-
- name: Build with Maven
74-
run: mvn -B clean install --settings=.maven.settings.xml -pl '!:klass-forvaltning'
69+
#- run: |
70+
# make bootstrap
71+
# make release
72+
# Build all modules except klass-forvaltning since it is not compatible with JDK 17
73+
- name: Build with Maven
74+
run: mvn -B clean install --settings=.maven.settings.xml -pl '!:klass-forvaltning'
7575

76-
- name: Set up JDK 1.8
77-
uses: actions/setup-java@v3
78-
with:
79-
distribution: 'zulu'
80-
java-version: '8'
81-
cache: maven
76+
- name: Set up JDK 1.8
77+
uses: actions/setup-java@v4
78+
with:
79+
distribution: 'temurin'
80+
java-version: '8'
81+
cache: maven
8282

83-
# Need to downgrade Maven in order to allow HTTP (not HTTPS) packages to be downloaded.
84-
# This is necessary as HTTP repositories were blocked in Maven 3.8.1
85-
# HTTP repositories are used in some outdated dependenciesns
86-
# This step can be removed once KLASS packages have been updated to more recent versions
87-
- name: Set up Maven
88-
uses: stCarolas/setup-maven@v4.5
89-
with:
90-
maven-version: 3.6.3
83+
# Build only klass-forvaltning with JDK 1.8
84+
- name: Build, test and package with Maven
85+
run: mvn --batch-mode --update-snapshots package -Djava.version=1.8 -pl :klass-forvaltning -am
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9188

92-
# Build only klass-forvaltning with JDK 1.8
93-
- name: Build, test and package with Maven
94-
run: mvn --batch-mode --update-snapshots package -Djava.version=1.8 -pl :klass-forvaltning -am -P github
95-
env:
96-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97-
98-
- name: Perform CodeQL Analysis
99-
uses: github/codeql-action/analyze@v2
89+
- name: Perform CodeQL Analysis
90+
uses: github/codeql-action/analyze@v2
Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
name: App build and deploy
1+
name: Klass-api build and deploy
22

33
on:
44
release:
5-
types: [published]
5+
types: [ published ]
66
push:
77
branches:
88
- nais-migration
9-
10-
env:
11-
REGISTRY: europe-north1-docker.pkg.dev/${{ secrets.NAIS_MANAGEMENT_PROJECT_ID }}/dapla-metadata
12-
DOCKER_IMAGE: europe-north1-docker.pkg.dev/${{ secrets.NAIS_MANAGEMENT_PROJECT_ID }}/dapla-metadata/klass-api:${{ github.sha }}
9+
paths:
10+
- "klass-api/**"
11+
- "klass-shared/**"
12+
- ".nais/**/klass-api.yaml"
13+
- ".github/workflows/klass-api-build-and-deploy.yaml"
1314

1415
jobs:
1516
docker-build:
1617
name: Docker build
1718
permissions:
1819
contents: "read"
1920
id-token: "write"
21+
packages: "read"
2022
runs-on: ubuntu-latest
2123
outputs:
2224
nais_config_path: ${{ steps.nais-deploy-vars.outputs.nais_config_path }}
@@ -26,14 +28,23 @@ jobs:
2628
- name: Checkout
2729
uses: actions/checkout@v4
2830

31+
- uses: actions/setup-java@v4
32+
with:
33+
distribution: 'temurin'
34+
java-version: '17'
35+
cache: 'maven'
36+
2937
- name: Build with Maven
30-
run: mvn --batch-mode install -pl '!:klass-forvaltning' -DskipTests
38+
run: mvn --batch-mode --update-snapshots install -pl '!:klass-forvaltning'
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3141

3242
- name: Build and push
3343
uses: nais/docker-build-push@v0
3444
id: docker-build-push
3545
with:
3646
team: dapla-metadata
47+
image_suffix: api
3748
dockerfile: klass-api/Dockerfile
3849
docker_context: klass-api
3950

@@ -42,10 +53,10 @@ jobs:
4253
run: |
4354
if [[ ${{ github.event_name }} == "release" ]]; then
4455
echo "nais_cluster=prod" >> "$GITHUB_OUTPUT"
45-
echo "nais_config_path=.nais/prod/nais.yaml" >> "$GITHUB_OUTPUT"
56+
echo "nais_config_path=.nais/prod/klass-api.yaml" >> "$GITHUB_OUTPUT"
4657
else
4758
echo "nais_cluster=test" >> "$GITHUB_OUTPUT"
48-
echo "nais_config_path=.nais/test/nais.yaml" >> "$GITHUB_OUTPUT"
59+
echo "nais_config_path=.nais/test/klass-api.yaml" >> "$GITHUB_OUTPUT"
4960
fi
5061
5162
- uses: nais/deploy/actions/deploy@v2
@@ -55,4 +66,4 @@ jobs:
5566
VAR: image=${{ steps.docker-build-push.outputs.image }}
5667
DEPLOY_SERVER: deploy.ssb.cloud.nais.io:443
5768
WORKLOAD_IMAGE: ${{ steps.docker-build-push.outputs.image }}
58-
TELEMETRY: ${{ steps.docker-build-push.outputs.telemetry }}
69+
TELEMETRY: ${{ steps.docker-build-push.outputs.telemetry }}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Klass-forvaltning build and deploy
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
push:
7+
branches:
8+
- nais-migration
9+
paths:
10+
- "klass-forvaltning/**"
11+
- "klass-shared/**"
12+
- ".nais/**/klass-forvaltning.yaml"
13+
- ".github/workflows/klass-forvaltning-build-and-deploy.yaml"
14+
15+
16+
jobs:
17+
docker-build:
18+
name: Docker build
19+
permissions:
20+
contents: "read"
21+
id-token: "write"
22+
packages: "read"
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- uses: actions/setup-java@v4
30+
with:
31+
distribution: 'temurin'
32+
java-version: '8'
33+
cache: 'maven'
34+
35+
- name: Build with Maven
36+
working-directory: klass-forvaltning
37+
run: mvn -B install -DskipTests
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Build and push
42+
uses: nais/docker-build-push@v0
43+
id: docker-build-push
44+
with:
45+
team: dapla-metadata
46+
image_suffix: forvaltning
47+
dockerfile: klass-forvaltning/Dockerfile
48+
docker_context: klass-forvaltning
49+
50+
- name: Generate NAIS deploy variables
51+
id: nais-deploy-vars
52+
run: |
53+
if [[ ${{ github.event_name }} == "release" ]]; then
54+
echo "nais_cluster=prod" >> "$GITHUB_OUTPUT"
55+
echo "nais_config_path=.nais/prod/klass-forvaltning.yaml" >> "$GITHUB_OUTPUT"
56+
else
57+
echo "nais_cluster=test" >> "$GITHUB_OUTPUT"
58+
echo "nais_config_path=.nais/test/klass-forvaltning.yaml" >> "$GITHUB_OUTPUT"
59+
fi
60+
61+
- uses: nais/deploy/actions/deploy@v2
62+
env:
63+
CLUSTER: ${{ steps.nais-deploy-vars.outputs.nais_cluster }}
64+
RESOURCE: ${{ steps.nais-deploy-vars.outputs.nais_config_path }}
65+
VAR: image=${{ steps.docker-build-push.outputs.image }}
66+
DEPLOY_SERVER: deploy.ssb.cloud.nais.io:443
67+
WORKLOAD_IMAGE: ${{ steps.docker-build-push.outputs.image }}
68+
TELEMETRY: ${{ steps.docker-build-push.outputs.telemetry }}

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v3
1717
- name: Set up JDK 17
18-
uses: actions/setup-java@v3
18+
uses: actions/setup-java@v4
1919
with:
20-
distribution: 'zulu'
20+
distribution: 'temurin'
2121
java-version: '17'
2222
cache: maven
2323

2424
# Build all modules except klass-forvaltning since it is not compatible with JDK 17
2525
- name: Publish to GitHub Packages
26-
run: mvn --batch-mode deploy -pl '!:klass-forvaltning' -P github -DskipTests
26+
run: mvn --batch-mode deploy -pl '!:klass-forvaltning' -DskipTests
2727
env:
2828
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,27 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@v3
2121
- name: Set up JDK 17
22-
uses: actions/setup-java@v3
22+
uses: actions/setup-java@v4
2323
with:
24-
distribution: 'zulu'
24+
distribution: 'temurin'
2525
java-version: '17'
2626
cache: maven
2727

2828
# Build all modules except klass-forvaltning since it is not compatible with JDK 17
2929
- name: Build, test and package with Maven
30-
run: mvn --batch-mode --update-snapshots package -pl '!:klass-forvaltning' -P nexus
30+
run: mvn --batch-mode --update-snapshots package -pl '!:klass-forvaltning'
3131

3232
- uses: actions/checkout@v3
3333
- name: Set up JDK 1.8
34-
uses: actions/setup-java@v3
34+
uses: actions/setup-java@v4
3535
with:
3636
distribution: 'zulu'
3737
java-version: '8'
3838
cache: maven
3939

40-
# Need to downgrade Maven in order to allow HTTP (not HTTPS) packages to be downloaded.
41-
# This is necessary as HTTP repositories were blocked in Maven 3.8.1
42-
# HTTP repositories are used in some outdated dependenciesns
43-
# This step can be removed once KLASS packages have been updated to more recent versions
44-
- name: Set up Maven
45-
uses: stCarolas/setup-maven@v4.5
46-
with:
47-
maven-version: 3.6.3
48-
4940
# Build only klass-forvaltning with JDK 1.8
5041
- name: Build, test and package with Maven
51-
run: mvn --batch-mode --update-snapshots package -Djava.version=1.8 -pl :klass-forvaltning -am -P github
42+
run: mvn --batch-mode --update-snapshots package -Djava.version=1.8 -pl :klass-forvaltning -am
5243
env:
5344
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5445

@@ -62,13 +53,13 @@ jobs:
6253
steps:
6354
- uses: actions/checkout@v3
6455
- name: Set up JDK 17
65-
uses: actions/setup-java@v3
56+
uses: actions/setup-java@v4
6657
with:
67-
distribution: 'zulu'
58+
distribution: 'temurin'
6859
java-version: '17'
6960
cache: maven
7061

7162
- name: Publish to GitHub Packages
72-
run: mvn --batch-mode deploy -pl '!:klass-forvaltning' -P github -DskipTests
63+
run: mvn --batch-mode deploy -pl '!:klass-forvaltning' -DskipTests
7364
env:
7465
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.maven.settings.xml

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

.mvn/extensions.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
3+
<extension>
4+
<groupId>com.github.gzm55.maven</groupId>
5+
<artifactId>project-settings-extension</artifactId>
6+
<version>0.3.5</version>
7+
</extension>
8+
</extensions>

.mvn/settings.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
4+
http://maven.apache.org/xsd/settings-1.0.0.xsd">
5+
6+
<profiles>
7+
<profile>
8+
<id>github</id>
9+
<activation>
10+
<activeByDefault>true</activeByDefault>
11+
</activation>
12+
<repositories>
13+
<repository>
14+
<id>github</id>
15+
<name>GitHub Packages</name>
16+
<url>https://maven.pkg.github.com/${github.repository}</url>
17+
</repository>
18+
<repository>
19+
<id>maven-restlet</id>
20+
<name>Public online Restlet repository</name>
21+
<url>https://maven.restlet.talend.com</url>
22+
</repository>
23+
</repositories>
24+
</profile>
25+
</profiles>
26+
27+
<mirrors>
28+
<mirror>
29+
<id>maven-restletMirror</id>
30+
<url>https://maven.restlet.talend.com</url>
31+
<mirrorOf>maven-restlet</mirrorOf>
32+
</mirror>
33+
</mirrors>
34+
</settings>

0 commit comments

Comments
 (0)