Skip to content

Commit e84c02f

Browse files
authored
Merge pull request #4 from SAP/ci/rc
feat: add workflow to publish tagged images of a branch and fix e2e route
2 parents 7e0762d + 48ae5fc commit e84c02f

3 files changed

Lines changed: 99 additions & 8 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Release builds and publish a new release.
2+
3+
# Secrets:
4+
# TEST_REGISTRY_USER: registry user for the container registry
5+
# TEST_REGISTRY_PASSWORD: password for container registry
6+
# Vars:
7+
# REGISTRY_URL: registry url for the container registry
8+
9+
name: Publish Release Candidate
10+
11+
on:
12+
workflow_dispatch:
13+
inputs:
14+
nextVersion:
15+
description: 'specify the release version in the semver format v[major].[minor].[patch] e.g. v0.0.0'
16+
required: true
17+
18+
# Releases need permissions to read and write the repository contents.
19+
# GitHub considers creating releases and uploading assets as writing contents.
20+
permissions:
21+
contents: write
22+
packages: write
23+
24+
jobs:
25+
release:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Set Version
29+
id: version
30+
run: echo "VERSION=fromPR-${{}}${{ github.event.inputs.nextVersion }}" >> $GITHUB_OUTPUT
31+
- name: Print Version Number
32+
run: echo "Effective version ${{ github.steps.version.outputs.VERSION }}"
33+
34+
- name: Setup Docker Buildx
35+
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.4.0
36+
with:
37+
version: v0.15.1
38+
install: true
39+
40+
- name: Checkout code
41+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
42+
with:
43+
submodules: true
44+
45+
- name: Fetch History
46+
run: git fetch --prune --unshallow
47+
48+
- name: Set up Go
49+
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
50+
with:
51+
go-version: '1.21'
52+
53+
- name: Vendor Dependencies
54+
run: make vendor vendor.check
55+
56+
- name: Build Images
57+
run: make build VERSION=${{ github.steps.version.outputs.VERSION }}
58+
env:
59+
# We're using docker buildx, which doesn't actually load the images it
60+
# builds by default. Specifying --load does so.
61+
BUILD_ARGS: "--load"
62+
DOCKER_REGISTRY: ${{ vars.REGISTRY_URL }}
63+
BUILD_REGISTRY: ${{ vars.REGISTRY_URL }}
64+
65+
- name: Login to Container Registry
66+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
67+
with:
68+
registry: ${{ vars.REGISTRY_URL }}
69+
username: ${{ github.actor }}
70+
password: ${{ secrets.GITHUB_TOKEN }}
71+
72+
- name: Publish Artifacts to DockerHub
73+
run: make publish VERSION=${{ github.steps.version.outputs.VERSION }}
74+
env:
75+
DOCKER_REGISTRY: ${{ vars.REGISTRY_URL }}
76+
BUILD_REGISTRY: ${{ vars.REGISTRY_URL }}

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ PROJECT_REPO := github.com/SAP/$(PROJECT_NAME)
66

77

88
PLATFORMS ?= linux_amd64 linux_arm64
9+
VERSION ?= $(shell git describe --tags --exact-match 2>/dev/null || git rev-parse HEAD)
10+
$(info VERSION is $(VERSION))
911

1012
# -include will silently skip missing files, which allows us
1113
# to load those files with a target in the Makefile. If only

test/e2e/test_env.go

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var (
2929
testenv env.Environment
3030
testOrgName = "cf-ci-e2e"
3131
testDomain = "e2e.orchestrator.io"
32-
testHostName = "app-host"
32+
testAppDomain = "cfapps.eu12.hana.ondemand.com"
3333
testSpaceName = "e2e-space"
3434
testQuotaName = "e2e-space-quota"
3535
)
@@ -44,7 +44,10 @@ func resetTestOrg(ctx context.Context, t *testing.T) {
4444
if err != nil {
4545
t.Fatalf("test org %s not accessible", testOrgName)
4646
}
47-
_ = deleteDomainRoute(ctx, cfClient, org, testDomain, testHostName)
47+
_ = deleteRoute(ctx, cfClient, org, testDomain, "app-host")
48+
_ = deleteRoute(ctx, cfClient, org, testAppDomain, "app-route-host-domainref")
49+
_ = deleteRoute(ctx, cfClient, org, testAppDomain, "app-route-host-domainname")
50+
_ = deleteDomain(ctx, cfClient, org, testDomain)
4851
_ = deleteSpace(ctx, cfClient, org, testSpaceName)
4952
_ = deleteQuota(ctx, cfClient, org, testQuotaName)
5053
}
@@ -105,14 +108,26 @@ func deleteSpace(ctx context.Context, cfClient *client.Client, org string, space
105108

106109
}
107110

108-
func deleteDomainRoute(ctx context.Context, cfClient *client.Client, org string, domain string, route string) error {
111+
func deleteDomain(ctx context.Context, cfClient *client.Client, org string, domain string) error {
112+
d, err := cfClient.Domains.Single(ctx,
113+
&client.DomainListOptions{
114+
OrganizationGUIDs: client.Filter{Values: []string{org}},
115+
Names: client.Filter{Values: []string{domain}},
116+
})
117+
if err == nil {
118+
_, err = cfClient.Domains.Delete(ctx, d.GUID)
119+
return err
120+
}
121+
return err
122+
}
123+
124+
func deleteRoute(ctx context.Context, cfClient *client.Client, org string, domain string, route string) error {
109125
d, err := cfClient.Domains.Single(ctx,
110126
&client.DomainListOptions{
111127
OrganizationGUIDs: client.Filter{Values: []string{org}},
112128
Names: client.Filter{Values: []string{domain}},
113129
})
114130
if err == nil {
115-
klog.V(4).Info("found test domain! cleaning up")
116131
s, err := cfClient.Routes.Single(ctx,
117132
&client.RouteListOptions{
118133
OrganizationGUIDs: client.Filter{Values: []string{org}},
@@ -125,12 +140,10 @@ func deleteDomainRoute(ctx context.Context, cfClient *client.Client, org string,
125140
_, err = cfClient.Routes.Delete(ctx, s.GUID)
126141
return err
127142
}
128-
_, err = cfClient.Domains.Delete(ctx, d.GUID)
129-
return err
143+
return nil
130144
}
131-
return nil
145+
return err
132146
}
133-
134147
func deleteQuota(ctx context.Context, cfClient *client.Client, org string, quota string) error {
135148
s, err := cfClient.SpaceQuotas.Single(ctx,
136149
&client.SpaceQuotaListOptions{

0 commit comments

Comments
 (0)