Skip to content

Commit

Permalink
support sapmachine 22 (java22) and Deprecated java8 from docker images (
Browse files Browse the repository at this point in the history
#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>
  • Loading branch information
yutaoj and JiangYuTao committed Jun 3, 2024
1 parent 42d6d4a commit 970355a
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 128 deletions.
205 changes: 81 additions & 124 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,102 +275,6 @@ jobs:
goreleaser release
#curl -sfL https://goreleaser.com/static/run | bash
publish-to-dockerhub-java8-node14:
docker:
- image: cimg/go:1.19
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
steps:
- checkout
- setup_remote_docker:
version: 20.10.6
- run:
name: build image pre-setup
command: |
#Make sure HEAD points to master
git checkout master
git fetch
git rebase
- run:
name: build Java 8.1.095 & Node 14.21.1 image
command: |
MBT_VERSION=$(cat ./VERSION)
sh $PWD/scripts/build_image 8.1.095 14.21.1 ${MBT_VERSION}
- run:
name: publish Java 8.1.095 & Node 14.21.1 image
command: |
MBT_VERSION=$(cat ./VERSION)
echo "Image release: ${MBT_VERSION}"
#Push to Docker Hub
echo "$DOCKER_HUB_TOKEN" | docker login --username $DOCKER_HUB_USER --password-stdin
sh $PWD/scripts/publish_image 8.1.095 14.21.1 ${MBT_VERSION} "devxci"
#Push to GitHub Container Registry
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
sh $PWD/scripts/publish_image 8.1.095 14.21.1 ${MBT_VERSION} "ghcr.io/sap"
publish-to-dockerhub-java8-node16:
docker:
- image: cimg/go:1.19
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
steps:
- checkout
- setup_remote_docker:
version: 20.10.6
- run:
name: build image pre-setup
command: |
#Make sure HEAD points to master
git checkout master
git fetch
git rebase
- run:
name: build Java 8.1.095 & Node 16.18.1 image
command: |
MBT_VERSION=$(cat ./VERSION)
sh $PWD/scripts/build_image 8.1.095 16.18.1 ${MBT_VERSION}
- run:
name: publish Java 8.1.095 & Node 16.18.1 image
command: |
MBT_VERSION=$(cat ./VERSION)
echo "Image release: ${MBT_VERSION}"
#Push to Docker Hub
echo "$DOCKER_HUB_TOKEN" | docker login --username $DOCKER_HUB_USER --password-stdin
sh $PWD/scripts/publish_image 8.1.095 16.18.1 ${MBT_VERSION} "devxci"
#Push to GitHub Container Registry
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
sh $PWD/scripts/publish_image 8.1.095 16.18.1 ${MBT_VERSION} "ghcr.io/sap"
publish-to-dockerhub-java8-node18:
docker:
- image: cimg/go:1.19
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
steps:
- checkout
- setup_remote_docker:
version: 20.10.6
- run:
name: build image pre-setup
command: |
#Make sure HEAD points to master
git checkout master
git fetch
git rebase
- run:
name: build Java 8.1.095 & Node 18.20.2 image
command: |
MBT_VERSION=$(cat ./VERSION)
sh $PWD/scripts/build_image 8.1.095 18.20.2 ${MBT_VERSION}
- run:
name: publish Java 8.1.095 & Node 18.20.2 image
command: |
MBT_VERSION=$(cat ./VERSION)
echo "Image release: ${MBT_VERSION}"
#Push to Docker Hub
echo "$DOCKER_HUB_TOKEN" | docker login --username $DOCKER_HUB_USER --password-stdin
sh $PWD/scripts/publish_image 8.1.095 18.20.2 ${MBT_VERSION} "devxci"
#Push to GitHub Container Registry
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
sh $PWD/scripts/publish_image 8.1.095 18.20.2 ${MBT_VERSION} "ghcr.io/sap"
publish-to-dockerhub-java11-node14:
docker:
- image: cimg/go:1.19
Expand Down Expand Up @@ -754,7 +658,6 @@ jobs:
#Push to GitHub Container Registry
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
sh $PWD/scripts/publish_image 21.0.1 16.18.1 ${MBT_VERSION} "ghcr.io/sap"
publish-to-dockerhub-java21-node18:
docker:
- image: cimg/go:1.19
Expand Down Expand Up @@ -818,6 +721,69 @@ jobs:
#Push to GitHub Container Registry
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
sh $PWD/scripts/publish_image 21.0.1 20.9.0 ${MBT_VERSION} "ghcr.io/sap"
publish-to-dockerhub-java22-node18:
docker:
- image: cimg/go:1.19
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
steps:
- checkout
- setup_remote_docker:
version: 20.10.6
- run:
name: build image pre-setup
command: |
#Make sure HEAD points to master
git checkout master
git fetch
git rebase
- run:
name: build Java 22.0.1 & Node 18.20.2 image
command: |
MBT_VERSION=$(cat ./VERSION)
sh $PWD/scripts/build_image 22.0.1 18.20.2 ${MBT_VERSION}
- run:
name: publish Java 22.0.1 & Node 18.20.2 image
command: |
MBT_VERSION=$(cat ./VERSION)
echo "Image release: ${MBT_VERSION}"
#Push to Docker Hub
echo "$DOCKER_HUB_TOKEN" | docker login --username $DOCKER_HUB_USER --password-stdin
sh $PWD/scripts/publish_image 22.0.1 18.20.2 ${MBT_VERSION} "devxci"
#Push to GitHub Container Registry
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
sh $PWD/scripts/publish_image 22.0.1 18.20.2 ${MBT_VERSION} "ghcr.io/sap"
publish-to-dockerhub-java22-node20:
docker:
- image: cimg/go:1.19
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
steps:
- checkout
- setup_remote_docker:
version: 20.10.6
- run:
name: build image pre-setup
command: |
#Make sure HEAD points to master
git checkout master
git fetch
git rebase
- run:
name: build Java 22.0.1 & Node 20.9.0 image
command: |
MBT_VERSION=$(cat ./VERSION)
sh $PWD/scripts/build_image 22.0.1 20.9.0 ${MBT_VERSION}
- run:
name: publish Java 22.0.1 & Node 20.9.0 image
command: |
MBT_VERSION=$(cat ./VERSION)
echo "Image release: ${MBT_VERSION}"
#Push to Docker Hub
echo "$DOCKER_HUB_TOKEN" | docker login --username $DOCKER_HUB_USER --password-stdin
sh $PWD/scripts/publish_image 22.0.1 20.9.0 ${MBT_VERSION} "devxci"
#Push to GitHub Container Registry
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
sh $PWD/scripts/publish_image 22.0.1 20.9.0 ${MBT_VERSION} "ghcr.io/sap"
remove-github-release-tag:
docker:
Expand Down Expand Up @@ -1026,30 +992,6 @@ workflows:
only: /release/
branches:
ignore: /.*/
- publish-to-dockerhub-java8-node14:
requires:
- publish-to-npm
filters:
tags:
only: /release/
branches:
ignore: /.*/
- publish-to-dockerhub-java8-node16:
requires:
- publish-to-npm
filters:
tags:
only: /release/
branches:
ignore: /.*/
- publish-to-dockerhub-java8-node18:
requires:
- publish-to-npm
filters:
tags:
only: /release/
branches:
ignore: /.*/
- publish-to-dockerhub-java11-node14:
requires:
- publish-to-npm
Expand Down Expand Up @@ -1162,11 +1104,24 @@ workflows:
only: /release/
branches:
ignore: /.*/
- publish-to-dockerhub-java22-node18:
requires:
- publish-to-npm
filters:
tags:
only: /release/
branches:
ignore: /.*/
- publish-to-dockerhub-java22-node20:
requires:
- publish-to-npm
filters:
tags:
only: /release/
branches:
ignore: /.*/
- remove-github-release-tag:
requires:
- publish-to-dockerhub-java8-node14
- publish-to-dockerhub-java8-node16
- publish-to-dockerhub-java8-node18
- publish-to-dockerhub-java11-node14
- publish-to-dockerhub-java11-node16
- publish-to-dockerhub-java11-node18
Expand All @@ -1181,6 +1136,8 @@ workflows:
- publish-to-dockerhub-java21-node16
- publish-to-dockerhub-java21-node18
- publish-to-dockerhub-java21-node20
- publish-to-dockerhub-java22-node18
- publish-to-dockerhub-java22-node20
filters:
tags:
only: /release/
Expand Down
22 changes: 21 additions & 1 deletion internal/artifacts/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

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

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

required := make(map[string]entry)
requriredEntryOrder := make([]string, 0)

// Add module entries to modules. Add non-module entries to mergedEntries.
for index, entry := range entries {
if entry.EntryType == moduleEntry {
Expand All @@ -86,11 +89,28 @@ func mergeDuplicateEntries(entries []entry) []entry {
modules[entry.EntryPath] = entries[index]
pathsOrder = append(pathsOrder, entry.EntryPath)
}
} else if entry.EntryType == requiredEntry {
if existing, ok := required[entry.EntryPath]; ok {
existing.EntryName += ", " + entry.EntryName
required[entry.EntryPath] = existing
} else {
required[entry.EntryPath] = entries[index]
requriredEntryOrder = append(requriredEntryOrder, entry.EntryPath)
}

} else {
mergedEntries = append(mergedEntries, entry)
}
}

// Sort required entries by order of insertion
requiredTypeEntries := make([]entry, 0)
for _, entryType := range requriredEntryOrder {
requiredTypeEntries = append(requiredTypeEntries, required[entryType])
}
// Add the required entries first to the merged entries
mergedEntries = append(requiredTypeEntries, mergedEntries...)

// Sort module entries by order of insertion
moduleEntries := make([]entry, 0)
for _, path := range pathsOrder {
Expand Down
33 changes: 31 additions & 2 deletions internal/artifacts/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
. "github.com/onsi/gomega"
"github.com/pkg/errors"

"github.com/SAP/cloud-mta-build-tool/internal/archive"
dir "github.com/SAP/cloud-mta-build-tool/internal/archive"
"github.com/SAP/cloud-mta-build-tool/internal/buildops"
"github.com/SAP/cloud-mta-build-tool/internal/commands"
"github.com/SAP/cloud-mta-build-tool/internal/conttype"
Expand Down Expand Up @@ -349,8 +349,8 @@ bad config
{EntryName: "e3", EntryPath: "b", EntryType: resourceEntry, ContentType: "t"},
{EntryName: "e4", EntryPath: "b", EntryType: resourceEntry, ContentType: "t"},
}, []entry{
{EntryName: "e1", EntryPath: "a", EntryType: resourceEntry, ContentType: "t"},
{EntryName: "e2", EntryPath: "a", EntryType: requiredEntry, ContentType: "t"},
{EntryName: "e1", EntryPath: "a", EntryType: resourceEntry, ContentType: "t"},
{EntryName: "e3", EntryPath: "b", EntryType: resourceEntry, ContentType: "t"},
{EntryName: "e4", EntryPath: "b", EntryType: resourceEntry, ContentType: "t"},
},
Expand All @@ -368,6 +368,19 @@ bad config
{EntryName: "e6", EntryPath: "c", EntryType: moduleEntry, ContentType: "t6"},
},
),
Entry("merges required entries with the same path and keeps the entries order", []entry{
{EntryName: "e1", EntryPath: "a", EntryType: requiredEntry, ContentType: "t1"},
{EntryName: "e2", EntryPath: "a", EntryType: requiredEntry, ContentType: "t2"},
{EntryName: "e3", EntryPath: "a", EntryType: requiredEntry, ContentType: "t3"},
{EntryName: "e4", EntryPath: "b", EntryType: requiredEntry, ContentType: "t4"},
{EntryName: "e5", EntryPath: "b", EntryType: requiredEntry, ContentType: "t5"},
{EntryName: "e6", EntryPath: "c", EntryType: requiredEntry, ContentType: "t6"},
}, []entry{
{EntryName: "e1, e2, e3", EntryPath: "a", EntryType: requiredEntry, ContentType: "t1"},
{EntryName: "e4, e5", EntryPath: "b", EntryType: requiredEntry, ContentType: "t4"},
{EntryName: "e6", EntryPath: "c", EntryType: requiredEntry, ContentType: "t6"},
},
),
Entry("merges module entries and keeps non-module entries unchanged at the end", []entry{
{EntryName: "e1", EntryPath: "a", EntryType: resourceEntry, ContentType: "t1"},
{EntryName: "e2", EntryPath: "a", EntryType: moduleEntry, ContentType: "t2"},
Expand All @@ -377,8 +390,24 @@ bad config
}, []entry{
{EntryName: "e2, e3", EntryPath: "a", EntryType: moduleEntry, ContentType: "t2"},
{EntryName: "e4", EntryPath: "b", EntryType: moduleEntry, ContentType: "t4"},
{EntryName: "e5", EntryPath: "b", EntryType: requiredEntry, ContentType: "t5"},
{EntryName: "e1", EntryPath: "a", EntryType: resourceEntry, ContentType: "t1"},
},
),
Entry("merges module&required entries and keeps the other entries unchanged at the end", []entry{
{EntryName: "e1", EntryPath: "a", EntryType: resourceEntry, ContentType: "t1"},
{EntryName: "e2", EntryPath: "a", EntryType: moduleEntry, ContentType: "t2"},
{EntryName: "e3", EntryPath: "a", EntryType: moduleEntry, ContentType: "t3"},
{EntryName: "e4", EntryPath: "b", EntryType: moduleEntry, ContentType: "t4"},
{EntryName: "e5", EntryPath: "b", EntryType: requiredEntry, ContentType: "t5"},
{EntryName: "e6", EntryPath: "b", EntryType: requiredEntry, ContentType: "t6"},
{EntryName: "e7", EntryPath: "c", EntryType: requiredEntry, ContentType: "t7"},
}, []entry{
{EntryName: "e2, e3", EntryPath: "a", EntryType: moduleEntry, ContentType: "t2"},
{EntryName: "e4", EntryPath: "b", EntryType: moduleEntry, ContentType: "t4"},
{EntryName: "e5, e6", EntryPath: "b", EntryType: requiredEntry, ContentType: "t5"},
{EntryName: "e7", EntryPath: "c", EntryType: requiredEntry, ContentType: "t7"},
{EntryName: "e1", EntryPath: "a", EntryType: resourceEntry, ContentType: "t1"},
},
),
)
Expand Down
2 changes: 1 addition & 1 deletion scripts/common_image
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export NODE_MAJOR_VERSION="$(echo ${NODE_VERSION_TEMPLATE}|awk -F. '{printf "%d"

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

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" ]) || \
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" ]) || \
([ "$NODE_MAJOR_VERSION" -ne "14" ] && [ "$NODE_MAJOR_VERSION" -ne "16" ] && [ "$NODE_MAJOR_VERSION" -ne "18" ] && [ "$NODE_MAJOR_VERSION" -ne "20" ])
then
echo "Java: ${JAVA_MAJOR_VERSION}, Node: ${NODE_MAJOR_VERSION} combination is not supported!"
Expand Down

0 comments on commit 970355a

Please sign in to comment.