Skip to content

Commit 970355a

Browse files
yutaojJiangYuTao
andauthored
support sapmachine 22 (java22) and Deprecated java8 from docker images (#1118)
* support sapmachine 22 (java22) * Enhancement to MANIFEST.MF Generation in Cloud MTA Build Tool --------- Co-authored-by: Jiang, Yu-tao <yu-tao.jiang@sap.com>
1 parent 42d6d4a commit 970355a

File tree

4 files changed

+134
-128
lines changed

4 files changed

+134
-128
lines changed

.circleci/config.yml

Lines changed: 81 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -275,102 +275,6 @@ jobs:
275275
goreleaser release
276276
#curl -sfL https://goreleaser.com/static/run | bash
277277
278-
publish-to-dockerhub-java8-node14:
279-
docker:
280-
- image: cimg/go:1.19
281-
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
282-
steps:
283-
- checkout
284-
- setup_remote_docker:
285-
version: 20.10.6
286-
- run:
287-
name: build image pre-setup
288-
command: |
289-
#Make sure HEAD points to master
290-
git checkout master
291-
git fetch
292-
git rebase
293-
- run:
294-
name: build Java 8.1.095 & Node 14.21.1 image
295-
command: |
296-
MBT_VERSION=$(cat ./VERSION)
297-
sh $PWD/scripts/build_image 8.1.095 14.21.1 ${MBT_VERSION}
298-
- run:
299-
name: publish Java 8.1.095 & Node 14.21.1 image
300-
command: |
301-
MBT_VERSION=$(cat ./VERSION)
302-
echo "Image release: ${MBT_VERSION}"
303-
#Push to Docker Hub
304-
echo "$DOCKER_HUB_TOKEN" | docker login --username $DOCKER_HUB_USER --password-stdin
305-
sh $PWD/scripts/publish_image 8.1.095 14.21.1 ${MBT_VERSION} "devxci"
306-
#Push to GitHub Container Registry
307-
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
308-
sh $PWD/scripts/publish_image 8.1.095 14.21.1 ${MBT_VERSION} "ghcr.io/sap"
309-
310-
publish-to-dockerhub-java8-node16:
311-
docker:
312-
- image: cimg/go:1.19
313-
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
314-
steps:
315-
- checkout
316-
- setup_remote_docker:
317-
version: 20.10.6
318-
- run:
319-
name: build image pre-setup
320-
command: |
321-
#Make sure HEAD points to master
322-
git checkout master
323-
git fetch
324-
git rebase
325-
- run:
326-
name: build Java 8.1.095 & Node 16.18.1 image
327-
command: |
328-
MBT_VERSION=$(cat ./VERSION)
329-
sh $PWD/scripts/build_image 8.1.095 16.18.1 ${MBT_VERSION}
330-
- run:
331-
name: publish Java 8.1.095 & Node 16.18.1 image
332-
command: |
333-
MBT_VERSION=$(cat ./VERSION)
334-
echo "Image release: ${MBT_VERSION}"
335-
#Push to Docker Hub
336-
echo "$DOCKER_HUB_TOKEN" | docker login --username $DOCKER_HUB_USER --password-stdin
337-
sh $PWD/scripts/publish_image 8.1.095 16.18.1 ${MBT_VERSION} "devxci"
338-
#Push to GitHub Container Registry
339-
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
340-
sh $PWD/scripts/publish_image 8.1.095 16.18.1 ${MBT_VERSION} "ghcr.io/sap"
341-
342-
publish-to-dockerhub-java8-node18:
343-
docker:
344-
- image: cimg/go:1.19
345-
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
346-
steps:
347-
- checkout
348-
- setup_remote_docker:
349-
version: 20.10.6
350-
- run:
351-
name: build image pre-setup
352-
command: |
353-
#Make sure HEAD points to master
354-
git checkout master
355-
git fetch
356-
git rebase
357-
- run:
358-
name: build Java 8.1.095 & Node 18.20.2 image
359-
command: |
360-
MBT_VERSION=$(cat ./VERSION)
361-
sh $PWD/scripts/build_image 8.1.095 18.20.2 ${MBT_VERSION}
362-
- run:
363-
name: publish Java 8.1.095 & Node 18.20.2 image
364-
command: |
365-
MBT_VERSION=$(cat ./VERSION)
366-
echo "Image release: ${MBT_VERSION}"
367-
#Push to Docker Hub
368-
echo "$DOCKER_HUB_TOKEN" | docker login --username $DOCKER_HUB_USER --password-stdin
369-
sh $PWD/scripts/publish_image 8.1.095 18.20.2 ${MBT_VERSION} "devxci"
370-
#Push to GitHub Container Registry
371-
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
372-
sh $PWD/scripts/publish_image 8.1.095 18.20.2 ${MBT_VERSION} "ghcr.io/sap"
373-
374278
publish-to-dockerhub-java11-node14:
375279
docker:
376280
- image: cimg/go:1.19
@@ -754,7 +658,6 @@ jobs:
754658
#Push to GitHub Container Registry
755659
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
756660
sh $PWD/scripts/publish_image 21.0.1 16.18.1 ${MBT_VERSION} "ghcr.io/sap"
757-
758661
publish-to-dockerhub-java21-node18:
759662
docker:
760663
- image: cimg/go:1.19
@@ -818,6 +721,69 @@ jobs:
818721
#Push to GitHub Container Registry
819722
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
820723
sh $PWD/scripts/publish_image 21.0.1 20.9.0 ${MBT_VERSION} "ghcr.io/sap"
724+
publish-to-dockerhub-java22-node18:
725+
docker:
726+
- image: cimg/go:1.19
727+
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
728+
steps:
729+
- checkout
730+
- setup_remote_docker:
731+
version: 20.10.6
732+
- run:
733+
name: build image pre-setup
734+
command: |
735+
#Make sure HEAD points to master
736+
git checkout master
737+
git fetch
738+
git rebase
739+
- run:
740+
name: build Java 22.0.1 & Node 18.20.2 image
741+
command: |
742+
MBT_VERSION=$(cat ./VERSION)
743+
sh $PWD/scripts/build_image 22.0.1 18.20.2 ${MBT_VERSION}
744+
- run:
745+
name: publish Java 22.0.1 & Node 18.20.2 image
746+
command: |
747+
MBT_VERSION=$(cat ./VERSION)
748+
echo "Image release: ${MBT_VERSION}"
749+
#Push to Docker Hub
750+
echo "$DOCKER_HUB_TOKEN" | docker login --username $DOCKER_HUB_USER --password-stdin
751+
sh $PWD/scripts/publish_image 22.0.1 18.20.2 ${MBT_VERSION} "devxci"
752+
#Push to GitHub Container Registry
753+
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
754+
sh $PWD/scripts/publish_image 22.0.1 18.20.2 ${MBT_VERSION} "ghcr.io/sap"
755+
756+
publish-to-dockerhub-java22-node20:
757+
docker:
758+
- image: cimg/go:1.19
759+
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
760+
steps:
761+
- checkout
762+
- setup_remote_docker:
763+
version: 20.10.6
764+
- run:
765+
name: build image pre-setup
766+
command: |
767+
#Make sure HEAD points to master
768+
git checkout master
769+
git fetch
770+
git rebase
771+
- run:
772+
name: build Java 22.0.1 & Node 20.9.0 image
773+
command: |
774+
MBT_VERSION=$(cat ./VERSION)
775+
sh $PWD/scripts/build_image 22.0.1 20.9.0 ${MBT_VERSION}
776+
- run:
777+
name: publish Java 22.0.1 & Node 20.9.0 image
778+
command: |
779+
MBT_VERSION=$(cat ./VERSION)
780+
echo "Image release: ${MBT_VERSION}"
781+
#Push to Docker Hub
782+
echo "$DOCKER_HUB_TOKEN" | docker login --username $DOCKER_HUB_USER --password-stdin
783+
sh $PWD/scripts/publish_image 22.0.1 20.9.0 ${MBT_VERSION} "devxci"
784+
#Push to GitHub Container Registry
785+
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
786+
sh $PWD/scripts/publish_image 22.0.1 20.9.0 ${MBT_VERSION} "ghcr.io/sap"
821787
822788
remove-github-release-tag:
823789
docker:
@@ -1026,30 +992,6 @@ workflows:
1026992
only: /release/
1027993
branches:
1028994
ignore: /.*/
1029-
- publish-to-dockerhub-java8-node14:
1030-
requires:
1031-
- publish-to-npm
1032-
filters:
1033-
tags:
1034-
only: /release/
1035-
branches:
1036-
ignore: /.*/
1037-
- publish-to-dockerhub-java8-node16:
1038-
requires:
1039-
- publish-to-npm
1040-
filters:
1041-
tags:
1042-
only: /release/
1043-
branches:
1044-
ignore: /.*/
1045-
- publish-to-dockerhub-java8-node18:
1046-
requires:
1047-
- publish-to-npm
1048-
filters:
1049-
tags:
1050-
only: /release/
1051-
branches:
1052-
ignore: /.*/
1053995
- publish-to-dockerhub-java11-node14:
1054996
requires:
1055997
- publish-to-npm
@@ -1162,11 +1104,24 @@ workflows:
11621104
only: /release/
11631105
branches:
11641106
ignore: /.*/
1107+
- publish-to-dockerhub-java22-node18:
1108+
requires:
1109+
- publish-to-npm
1110+
filters:
1111+
tags:
1112+
only: /release/
1113+
branches:
1114+
ignore: /.*/
1115+
- publish-to-dockerhub-java22-node20:
1116+
requires:
1117+
- publish-to-npm
1118+
filters:
1119+
tags:
1120+
only: /release/
1121+
branches:
1122+
ignore: /.*/
11651123
- remove-github-release-tag:
11661124
requires:
1167-
- publish-to-dockerhub-java8-node14
1168-
- publish-to-dockerhub-java8-node16
1169-
- publish-to-dockerhub-java8-node18
11701125
- publish-to-dockerhub-java11-node14
11711126
- publish-to-dockerhub-java11-node16
11721127
- publish-to-dockerhub-java11-node18
@@ -1181,6 +1136,8 @@ workflows:
11811136
- publish-to-dockerhub-java21-node16
11821137
- publish-to-dockerhub-java21-node18
11831138
- publish-to-dockerhub-java21-node20
1139+
- publish-to-dockerhub-java22-node18
1140+
- publish-to-dockerhub-java22-node20
11841141
filters:
11851142
tags:
11861143
only: /release/

internal/artifacts/manifest.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
"github.com/SAP/cloud-mta/mta"
1414

15-
"github.com/SAP/cloud-mta-build-tool/internal/archive"
15+
dir "github.com/SAP/cloud-mta-build-tool/internal/archive"
1616
"github.com/SAP/cloud-mta-build-tool/internal/buildops"
1717
"github.com/SAP/cloud-mta-build-tool/internal/commands"
1818
"github.com/SAP/cloud-mta-build-tool/internal/conttype"
@@ -76,6 +76,9 @@ func mergeDuplicateEntries(entries []entry) []entry {
7676
// To keep a consistent sort order for the map entries we must keep another data structure (slice of keys by order of addition here)
7777
pathsOrder := make([]string, 0)
7878

79+
required := make(map[string]entry)
80+
requriredEntryOrder := make([]string, 0)
81+
7982
// Add module entries to modules. Add non-module entries to mergedEntries.
8083
for index, entry := range entries {
8184
if entry.EntryType == moduleEntry {
@@ -86,11 +89,28 @@ func mergeDuplicateEntries(entries []entry) []entry {
8689
modules[entry.EntryPath] = entries[index]
8790
pathsOrder = append(pathsOrder, entry.EntryPath)
8891
}
92+
} else if entry.EntryType == requiredEntry {
93+
if existing, ok := required[entry.EntryPath]; ok {
94+
existing.EntryName += ", " + entry.EntryName
95+
required[entry.EntryPath] = existing
96+
} else {
97+
required[entry.EntryPath] = entries[index]
98+
requriredEntryOrder = append(requriredEntryOrder, entry.EntryPath)
99+
}
100+
89101
} else {
90102
mergedEntries = append(mergedEntries, entry)
91103
}
92104
}
93105

106+
// Sort required entries by order of insertion
107+
requiredTypeEntries := make([]entry, 0)
108+
for _, entryType := range requriredEntryOrder {
109+
requiredTypeEntries = append(requiredTypeEntries, required[entryType])
110+
}
111+
// Add the required entries first to the merged entries
112+
mergedEntries = append(requiredTypeEntries, mergedEntries...)
113+
94114
// Sort module entries by order of insertion
95115
moduleEntries := make([]entry, 0)
96116
for _, path := range pathsOrder {

internal/artifacts/manifest_test.go

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
. "github.com/onsi/gomega"
1111
"github.com/pkg/errors"
1212

13-
"github.com/SAP/cloud-mta-build-tool/internal/archive"
13+
dir "github.com/SAP/cloud-mta-build-tool/internal/archive"
1414
"github.com/SAP/cloud-mta-build-tool/internal/buildops"
1515
"github.com/SAP/cloud-mta-build-tool/internal/commands"
1616
"github.com/SAP/cloud-mta-build-tool/internal/conttype"
@@ -349,8 +349,8 @@ bad config
349349
{EntryName: "e3", EntryPath: "b", EntryType: resourceEntry, ContentType: "t"},
350350
{EntryName: "e4", EntryPath: "b", EntryType: resourceEntry, ContentType: "t"},
351351
}, []entry{
352-
{EntryName: "e1", EntryPath: "a", EntryType: resourceEntry, ContentType: "t"},
353352
{EntryName: "e2", EntryPath: "a", EntryType: requiredEntry, ContentType: "t"},
353+
{EntryName: "e1", EntryPath: "a", EntryType: resourceEntry, ContentType: "t"},
354354
{EntryName: "e3", EntryPath: "b", EntryType: resourceEntry, ContentType: "t"},
355355
{EntryName: "e4", EntryPath: "b", EntryType: resourceEntry, ContentType: "t"},
356356
},
@@ -368,6 +368,19 @@ bad config
368368
{EntryName: "e6", EntryPath: "c", EntryType: moduleEntry, ContentType: "t6"},
369369
},
370370
),
371+
Entry("merges required entries with the same path and keeps the entries order", []entry{
372+
{EntryName: "e1", EntryPath: "a", EntryType: requiredEntry, ContentType: "t1"},
373+
{EntryName: "e2", EntryPath: "a", EntryType: requiredEntry, ContentType: "t2"},
374+
{EntryName: "e3", EntryPath: "a", EntryType: requiredEntry, ContentType: "t3"},
375+
{EntryName: "e4", EntryPath: "b", EntryType: requiredEntry, ContentType: "t4"},
376+
{EntryName: "e5", EntryPath: "b", EntryType: requiredEntry, ContentType: "t5"},
377+
{EntryName: "e6", EntryPath: "c", EntryType: requiredEntry, ContentType: "t6"},
378+
}, []entry{
379+
{EntryName: "e1, e2, e3", EntryPath: "a", EntryType: requiredEntry, ContentType: "t1"},
380+
{EntryName: "e4, e5", EntryPath: "b", EntryType: requiredEntry, ContentType: "t4"},
381+
{EntryName: "e6", EntryPath: "c", EntryType: requiredEntry, ContentType: "t6"},
382+
},
383+
),
371384
Entry("merges module entries and keeps non-module entries unchanged at the end", []entry{
372385
{EntryName: "e1", EntryPath: "a", EntryType: resourceEntry, ContentType: "t1"},
373386
{EntryName: "e2", EntryPath: "a", EntryType: moduleEntry, ContentType: "t2"},
@@ -377,8 +390,24 @@ bad config
377390
}, []entry{
378391
{EntryName: "e2, e3", EntryPath: "a", EntryType: moduleEntry, ContentType: "t2"},
379392
{EntryName: "e4", EntryPath: "b", EntryType: moduleEntry, ContentType: "t4"},
393+
{EntryName: "e5", EntryPath: "b", EntryType: requiredEntry, ContentType: "t5"},
380394
{EntryName: "e1", EntryPath: "a", EntryType: resourceEntry, ContentType: "t1"},
395+
},
396+
),
397+
Entry("merges module&required entries and keeps the other entries unchanged at the end", []entry{
398+
{EntryName: "e1", EntryPath: "a", EntryType: resourceEntry, ContentType: "t1"},
399+
{EntryName: "e2", EntryPath: "a", EntryType: moduleEntry, ContentType: "t2"},
400+
{EntryName: "e3", EntryPath: "a", EntryType: moduleEntry, ContentType: "t3"},
401+
{EntryName: "e4", EntryPath: "b", EntryType: moduleEntry, ContentType: "t4"},
381402
{EntryName: "e5", EntryPath: "b", EntryType: requiredEntry, ContentType: "t5"},
403+
{EntryName: "e6", EntryPath: "b", EntryType: requiredEntry, ContentType: "t6"},
404+
{EntryName: "e7", EntryPath: "c", EntryType: requiredEntry, ContentType: "t7"},
405+
}, []entry{
406+
{EntryName: "e2, e3", EntryPath: "a", EntryType: moduleEntry, ContentType: "t2"},
407+
{EntryName: "e4", EntryPath: "b", EntryType: moduleEntry, ContentType: "t4"},
408+
{EntryName: "e5, e6", EntryPath: "b", EntryType: requiredEntry, ContentType: "t5"},
409+
{EntryName: "e7", EntryPath: "c", EntryType: requiredEntry, ContentType: "t7"},
410+
{EntryName: "e1", EntryPath: "a", EntryType: resourceEntry, ContentType: "t1"},
382411
},
383412
),
384413
)

scripts/common_image

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export NODE_MAJOR_VERSION="$(echo ${NODE_VERSION_TEMPLATE}|awk -F. '{printf "%d"
1111

1212
echo "Java major version: ${JAVA_MAJOR_VERSION}, Node major version: ${NODE_MAJOR_VERSION}"
1313

14-
if ([ "$JAVA_MAJOR_VERSION" -ne "8" ] && [ "$JAVA_MAJOR_VERSION" -ne "11" ] && [ "$JAVA_MAJOR_VERSION" -ne "17" ] && [ "$JAVA_MAJOR_VERSION" -ne "19" ] && [ "$JAVA_MAJOR_VERSION" -ne "21" ]) || \
14+
if ([ "$JAVA_MAJOR_VERSION" -ne "11" ] && [ "$JAVA_MAJOR_VERSION" -ne "17" ] && [ "$JAVA_MAJOR_VERSION" -ne "19" ] && [ "$JAVA_MAJOR_VERSION" -ne "21" ] && [ "$JAVA_MAJOR_VERSION" -ne "22" ]) || \
1515
([ "$NODE_MAJOR_VERSION" -ne "14" ] && [ "$NODE_MAJOR_VERSION" -ne "16" ] && [ "$NODE_MAJOR_VERSION" -ne "18" ] && [ "$NODE_MAJOR_VERSION" -ne "20" ])
1616
then
1717
echo "Java: ${JAVA_MAJOR_VERSION}, Node: ${NODE_MAJOR_VERSION} combination is not supported!"

0 commit comments

Comments
 (0)