Skip to content

Commit

Permalink
Merge branch 'master' into 1084565-infra-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
tiloKo authored May 7, 2024
2 parents 258caf4 + 6c4a860 commit 9c6163c
Show file tree
Hide file tree
Showing 77 changed files with 3,288 additions and 912 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
go-version: '1.21.x'

- name: Install Groovy
run: sudo apt-get update && sudo apt-get install groovy -y
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-go-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
go-version: '1.21.x'
- name: Perform update
run: |
git checkout -B gh-action-update-golang-dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upload-go-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
go-version: '1.21.x'
- env:
CGO_ENABLED: 0
run: |
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/verify-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: styfle/[email protected]
- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
go-version: '1.21.x'
- name: Cache Golang Packages
uses: actions/cache@v3
with:
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
go-version: '1.21.x'
- name: Cache Golang Packages
uses: actions/cache@v3
with:
Expand All @@ -63,8 +63,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
# action requires [email protected]
go-version: '1.21.x'
- name: checkout
uses: actions/checkout@v4
with:
Expand All @@ -79,7 +78,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
go-version: '1.21.x'
- name: Cache Golang Packages
uses: actions/cache@v3
with:
Expand All @@ -99,7 +98,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
go-version: '1.21.x'
- name: Cache Golang Packages
uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20 AS build-env
FROM golang:1.21 AS build-env
COPY . /build
WORKDIR /build

Expand Down
94 changes: 94 additions & 0 deletions cmd/abapAddonAssemblyKitCheck.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package cmd

import (
"github.com/SAP/jenkins-library/pkg/abap/aakaas"
abapbuild "github.com/SAP/jenkins-library/pkg/abap/build"
"github.com/SAP/jenkins-library/pkg/abaputils"
"github.com/SAP/jenkins-library/pkg/log"
"github.com/SAP/jenkins-library/pkg/piperutils"
"github.com/SAP/jenkins-library/pkg/telemetry"
)

func abapAddonAssemblyKitCheck(config abapAddonAssemblyKitCheckOptions, telemetryData *telemetry.CustomData, commonPipelineEnvironment *abapAddonAssemblyKitCheckCommonPipelineEnvironment) {
utils := aakaas.NewAakBundle()

err := runAbapAddonAssemblyKitCheck(&config, telemetryData, utils, commonPipelineEnvironment)
if err != nil {
log.Entry().WithError(err).Fatal("step execution failed")
}
}

func runAbapAddonAssemblyKitCheck(config *abapAddonAssemblyKitCheckOptions, telemetryData *telemetry.CustomData, utils aakaas.AakUtils, commonPipelineEnvironment *abapAddonAssemblyKitCheckCommonPipelineEnvironment) error {

log.Entry().Info("╔═══════════════════════════╗")
log.Entry().Info("║ abapAddonAssemblyKitCheck ║")
log.Entry().Info("╚═══════════════════════════╝")

conn := new(abapbuild.Connector)
if err := conn.InitAAKaaS(config.AbapAddonAssemblyKitEndpoint, config.Username, config.Password, utils, "", config.AbapAddonAssemblyKitCertificateFile, config.AbapAddonAssemblyKitCertificatePass); err != nil {
return err
}

log.Entry().Infof("reading addonDescriptor (aka addon.yml) file: %s", config.AddonDescriptorFileName)
addonDescriptor, err := utils.ReadAddonDescriptor(config.AddonDescriptorFileName)
if err != nil {
return err
}
log.Entry().Info("building product modelling (and resolving potential wildcards)")
pvh, err := aakaas.NewProductVersionHeader(&addonDescriptor, conn)
if err != nil {
return err
}
printProductVersionHeader(*pvh)

log.Entry().Info("calling AAKaaS to check product modelling...")
if err := pvh.CheckAndResolveVersion(conn); err != nil {
return err
}
log.Entry().Info("... success!")
pvh.SyncAddonDescriptorVersionFields(&addonDescriptor)
log.Entry().Info("resolved version fields:")
printAddonDescriptorVersionFields(addonDescriptor)
log.Entry().Info("transferring addonDescriptor to commonPipelineEnvironment for usage by subsequent steps of the pipeline")
commonPipelineEnvironment.abap.addonDescriptor = string(addonDescriptor.AsJSON())

publishAddonYaml(config, utils)
return nil
}

func printProductVersionHeader(pvh aakaas.ProductVersionHeader) {
logLine30 := "──────────────────────────────"
log.Entry().Infof("┌─%-30v─┬─%-30v─┐", logLine30, logLine30)
log.Entry().Infof("│ %-30v │ %-30v │", "Product Name", pvh.ProductName)
log.Entry().Infof("│ %-30v │ %-30v │", "Product Version", pvh.SemanticProductVersion)
log.Entry().Infof("├─%-30v─┼─%-30v─┤", logLine30, logLine30)
log.Entry().Infof("│ %-30v │ %-30v │", "Software Component Name", "Software Component Version")
log.Entry().Infof("├─%-30v─┼─%-30v─┤", logLine30, logLine30)
for _, pvc := range pvh.Content {
log.Entry().Infof("│ %-30v │ %-30v │", pvc.SoftwareComponentName, pvc.SemanticSoftwareComponentVersion)
}
log.Entry().Infof("└─%-30v─┴─%-30v─┘", logLine30, logLine30)
}

func printAddonDescriptorVersionFields(addonDescriptor abaputils.AddonDescriptor) {
logLine30 := "──────────────────────────────"
logLine4 := "────"
log.Entry().Infof("┌─%-30v─┬─%-4v─┬─%-4v─┬─%-4v─┐", logLine30, logLine4, logLine4, logLine4)
log.Entry().Infof("│ %-30v │ %-4v │ %-4v │ %-4v │", "Name", "Vers", "SP", "Pat.")
log.Entry().Infof("├─%-30v─┼─%-4v─┼─%-4v─┼─%-4v─┤", logLine30, logLine4, logLine4, logLine4)
log.Entry().Infof("│ %-30v │ %-4v │ %-4v │ %-4v │", addonDescriptor.AddonProduct, addonDescriptor.AddonVersion, addonDescriptor.AddonSpsLevel, addonDescriptor.AddonPatchLevel)
for _, repo := range addonDescriptor.Repositories {
log.Entry().Infof("│ %-30v │ %-4v │ %-4v │ %-4v │", repo.Name, repo.Version, repo.SpLevel, repo.PatchLevel)
}
log.Entry().Infof("└─%-30v─┴─%-4v─┴─%-4v─┴─%-4v─┘", logLine30, logLine4, logLine4, logLine4)
}

func publishAddonYaml(config *abapAddonAssemblyKitCheckOptions, utils aakaas.AakUtils) {
var filesToPublish []piperutils.Path
log.Entry().Infof("adding %s to be published", config.AddonDescriptorFileName)
filesToPublish = append(filesToPublish, piperutils.Path{Target: config.AddonDescriptorFileName, Name: "AddonDescriptor", Mandatory: true})
log.Entry().Infof("publishing %v files", len(filesToPublish))
if err := piperutils.PersistReportsAndLinks("abapAddonAssemblyKitCheckPV", "", utils, filesToPublish, nil); err != nil {
log.Entry().WithError(err).Error("failed to persist report information")
}
}
Loading

0 comments on commit 9c6163c

Please sign in to comment.