Skip to content

Commit 7794c0d

Browse files
authored
Issue 2190 - Set up new Simbank tests to replace inttests (galasa-dev#184)
* Bash script for running the Simbank app and all IVTs locally, GH workflow to run the SimBankIVT locally in a workflow, updates to the .secrets.baseline Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Fix path to build.properties file in the 'galasa' repo Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Allow maven build of Simplatform app and tests to draw from the development maven repo Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Update .secrets.baseline file Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Pass the simplatform settings.xml file into the maven build of the Simplatform app and tests Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Optionally skip docker build and detect secrets steps in build-locally.sh Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Do not run docker build and detect secrets steps in build-locally.sh when running it from the Test Simbank workflow Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Update Test Simbank workflow to download or build depending on the calling event Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Fix incorrect if statements to check the workflow trigger event Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Pass in the GALASA_VERSION output to use in the galasactl runs submit local command Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Add a --remoteMaven location to the galasactl runs submit local command so it can find the Uber OBR in the dev maven repo Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Add .galasa directory with cps.properties file for the local tests to use Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Checkout Simplatform repo at very start of Test Simbank workflow and fix working directories Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Fix incorrect credentials ID in comment in Test Simbank workflow Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Add missing CPS properties needed for the Simbank manager Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Update comment in cps.properties file Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Call the Test Simbank workflow at the end of a Main Build Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> * Update the .secrets.baseline Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk> --------- Signed-off-by: Jade Carino <carino_jade@yahoo.co.uk>
1 parent e0b3a14 commit 7794c0d

File tree

6 files changed

+340
-22
lines changed

6 files changed

+340
-22
lines changed

.galasa/cps.properties

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# File: cps.properties
3+
#
4+
# Purpose:
5+
# To provide properties to the Galasa runtime when running tests in a local JVM.
6+
# These properties are used in the test.yaml Github Actions workflow.
7+
#
8+
9+
simbank.dse.instance.name=SIMBANK
10+
simbank.instance.SIMBANK.zos.image=SIMBANK
11+
simbank.instance.SIMBANK.credentials.id=SIMBANK
12+
13+
zos.dse.tag.SIMBANK.imageid=SIMBANK
14+
zos.image.SIMBANK.ipv4.hostname=127.0.0.1
15+
zos.image.SIMBANK.telnet.tls=false
16+
zos.image.SIMBANK.telnet.port=2023
17+
zos.image.SIMBANK.webnet.port=2080
18+
zos.image.SIMBANK.credentials=SIMBANK

.github/workflows/build.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ jobs:
8383
path: galasa-simbank-tests-build.log
8484
retention-days: 7
8585

86+
- name: Upload Simplatform
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: simplatform
90+
path: /home/runner/.m2/repository
91+
8692
- name: Login to Github Container Registry
8793
uses: docker/login-action@v3
8894
with:
@@ -142,6 +148,12 @@ jobs:
142148
run: |
143149
docker run --env ARGOCD_AUTH_TOKEN=${{ env.ARGOCD_AUTH_TOKEN }} --rm -v ${{ github.workspace }}:/var/workspace ghcr.io/galasa-dev/argocdcli:main app wait ${{ env.BRANCH }}-simplatform --resource apps:Deployment:simplatform-${{ env.BRANCH }} --health --server argocd.galasa.dev
144150
151+
run-simbank-tests:
152+
name: Run the SimBank Tests
153+
needs: [build-simplatform]
154+
uses: ./.github/workflows/test.yaml
155+
secrets: inherit
156+
145157
report-failure:
146158
# Skip this job for forks
147159
if: ${{ failure() && github.repository_owner == 'galasa-dev' }}

.github/workflows/test.yaml

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
#
2+
# Copyright contributors to the Galasa project
3+
#
4+
# SPDX-License-Identifier: EPL-2.0
5+
#
6+
name: Test SimBank
7+
8+
on:
9+
# This workflow_call is used after the Main Build of Simplatform.
10+
workflow_call:
11+
# This workflow_dispatch allows this workflow to be called by a
12+
# scheduled regression run in the Automation repository. It also
13+
# allows this workflow to be called by pressing 'Run Workflow'.
14+
workflow_dispatch:
15+
16+
env:
17+
NAMESPACE: ${{ github.repository_owner }}
18+
19+
jobs:
20+
get-galasa-version:
21+
name: Get Galasa Version
22+
# Use the build.properties file in the galasa repo to source the galasa-version output variable.
23+
# This variable can be referenced by other jobs in this flow using ${{ needs.get-galasa-version.outputs.galasa-version }}
24+
runs-on: macos-latest
25+
26+
steps:
27+
- name: Checkout 'galasa' repository
28+
uses: actions/checkout@v4
29+
with:
30+
repository: ${{ env.NAMESPACE }}/galasa
31+
path: ${{ github.workspace }}/galasa
32+
sparse-checkout: |
33+
build.properties
34+
35+
- name: Get Galasa Version from build.properties file
36+
id: get-galasa-version
37+
run: |
38+
cat ${{ github.workspace }}/galasa/build.properties | grep "=" >> $GITHUB_OUTPUT
39+
40+
outputs:
41+
galasa-version: ${{ steps.get-galasa-version.outputs.GALASA_VERSION }}
42+
43+
build-and-run-simbank-tests:
44+
name: Build and Run SimBank Tests
45+
runs-on: macos-latest
46+
47+
needs: [get-galasa-version]
48+
49+
env:
50+
GALASA_HOME: ${{ github.workspace }}/.galasa
51+
52+
steps:
53+
#----------------------------------------------------------------------------------
54+
- name: Checkout the Simplatform repository
55+
uses: actions/checkout@v4
56+
with:
57+
repository: ${{ env.NAMESPACE }}/simplatform
58+
59+
#----------------------------------------------------------------------------------
60+
# Set up pre-requesite technology (Java, Gradle and galasactl)
61+
- name: Setup JDK
62+
uses: actions/setup-java@v4
63+
with:
64+
java-version: '17'
65+
distribution: 'semeru'
66+
67+
- name: Setup Gradle
68+
uses: gradle/actions/setup-gradle@v3
69+
with:
70+
gradle-version: '8.9'
71+
72+
- name: Install galasactl with Homebrew
73+
run: |
74+
brew tap galasa-dev/tap
75+
brew install --no-quarantine galasactl
76+
#----------------------------------------------------------------------------------
77+
# Set up Galasa environment
78+
- name: Create credentials.properties file
79+
working-directory: ${{ env.GALASA_HOME }}
80+
run: |
81+
echo "${{ secrets.SIMBANK_CREDENTIALS }}" >> credentials.properties
82+
83+
# The credentials.properties file should look something like this:
84+
# secure.credentials.SIMBANK.username=XXX
85+
# secure.credentials.SIMBANK.password=XXX
86+
# Needs to be created dynamically as they cannot be checked into GitHub and exposed.
87+
88+
- name: Initialise local Galasa environment to create remaining files and folders
89+
run: |
90+
galasactl local init --log -
91+
92+
#----------------------------------------------------------------------------------
93+
# Download or build the Simplatform application that the tests connect to
94+
- name: Download SimBank from Main Build
95+
if: ${{ github.event_name == 'workflow_call' }}
96+
uses: actions/download-artifact@v4
97+
with:
98+
name: simplatform
99+
path: /home/runner/.m2/repository
100+
101+
- name: Build SimBank using local build script
102+
if: ${{ github.event_name == 'workflow_dispatch' }}
103+
run: |
104+
./build-locally.sh --skip-docker --skip-secrets
105+
106+
#----------------------------------------------------------------------------------
107+
# Run the Simplatform application
108+
- name: Start the Simplatform application
109+
env:
110+
GALASA_VERSION: ${{ needs.get-galasa-version.outputs.galasa-version }}
111+
run: |
112+
echo "Starting SimBank application..."
113+
java -jar /Users/runner/.m2/repository/dev/galasa/galasa-simplatform/${GALASA_VERSION}/galasa-simplatform-${GALASA_VERSION}.jar &
114+
115+
#----------------------------------------------------------------------------------
116+
# Run the Simbank tests
117+
- name: Run the SimBankIVT
118+
env:
119+
GALASA_VERSION: ${{ needs.get-galasa-version.outputs.galasa-version }}
120+
run: |
121+
galasactl runs submit local \
122+
--obr mvn:dev.galasa/dev.galasa.simbank.obr/${GALASA_VERSION}/obr \
123+
--obr mvn:dev.galasa/dev.galasa.uber.obr/${GALASA_VERSION}/obr \
124+
--class dev.galasa.simbank.tests/dev.galasa.simbank.tests.SimBankIVT \
125+
--remoteMaven https://development.galasa.dev/main/maven-repo/obr \
126+
--log -
127+
128+
- name: Run the BasicAccountCreditTest
129+
env:
130+
GALASA_VERSION: ${{ needs.get-galasa-version.outputs.galasa-version }}
131+
run: |
132+
galasactl runs submit local \
133+
--obr mvn:dev.galasa/dev.galasa.simbank.obr/${GALASA_VERSION}/obr \
134+
--obr mvn:dev.galasa/dev.galasa.uber.obr/${GALASA_VERSION}/obr \
135+
--class dev.galasa.simbank.tests/dev.galasa.simbank.tests.BasicAccountCreditTest \
136+
--remoteMaven https://development.galasa.dev/main/maven-repo/obr \
137+
--log -
138+
139+
- name: Run the ProvisionedAccountCreditTests
140+
env:
141+
GALASA_VERSION: ${{ needs.get-galasa-version.outputs.galasa-version }}
142+
run: |
143+
galasactl runs submit local \
144+
--obr mvn:dev.galasa/dev.galasa.simbank.obr/${GALASA_VERSION}/obr \
145+
--obr mvn:dev.galasa/dev.galasa.uber.obr/${GALASA_VERSION}/obr \
146+
--class dev.galasa.simbank.tests/dev.galasa.simbank.tests.ProvisionedAccountCreditTests \
147+
--remoteMaven https://development.galasa.dev/main/maven-repo/obr \
148+
--log -
149+
150+
# - name: Report results into Slack channel
151+
# env:
152+
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
153+
# run: |
154+
# docker run --rm \
155+
# --env SLACK_WEBHOOK=${{ env.SLACK_WEBHOOK }} \
156+
# -v ${{ github.workspace }}/galasa:/galasa:rw \
157+
# ghcr.io/${{ env.NAMESPACE }}/galasabld-ibm:main \
158+
# slackpost tests \
159+
# --path /galasa/test.json \
160+
# --name "Simbank" \
161+
# --desc "Tests running locally on GitHub Actions" \
162+
# --hook ${{ env.SLACK_WEBHOOK }}

.secrets.baseline

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,28 @@
7575
"name": "TwilioKeyDetector"
7676
}
7777
],
78-
"results": {},
78+
"results": {
79+
".galasa/cps.properties": [
80+
{
81+
"hashed_secret": "877704f69026efee10f08e8f95568749f2682203",
82+
"is_secret": false,
83+
"is_verified": false,
84+
"line_number": 18,
85+
"type": "Secret Keyword",
86+
"verified_result": null
87+
}
88+
],
89+
".github/workflows/test.yaml": [
90+
{
91+
"hashed_secret": "b60d121b438a380c343d5ec3c2037564b82ffef3",
92+
"is_secret": false,
93+
"is_verified": false,
94+
"line_number": 85,
95+
"type": "Secret Keyword",
96+
"verified_result": null
97+
}
98+
]
99+
},
79100
"version": "0.13.1+ibm.62.dss",
80101
"word_list": {
81102
"file": null,

build-locally.sh

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#
1010
# Objectives: Build this repository code locally.
1111
#
12+
# Environment variable overrides:
13+
# SOURCE_MAVEN - Optional. Where a maven repository is from which the build will draw artifacts.
14+
#
1215
#-----------------------------------------------------------------------------------------
1316

1417
# Where is this script executing from ?
@@ -77,14 +80,22 @@ EOF
7780
#-----------------------------------------------------------------------------------------
7881
export build_type=""
7982

83+
SKIP_DOCKER=false
84+
SKIP_SECRETS=false
85+
8086
while [ "$1" != "" ]; do
8187
case $1 in
88+
--skip-docker ) SKIP_DOCKER=true
89+
;;
90+
--skip-secrets ) SKIP_SECRETS=true
91+
;;
8292
-h | --help ) usage
8393
exit
8494
;;
8595
* ) error "Unexpected argument $1"
8696
usage
8797
exit 1
98+
;;
8899
esac
89100
shift
90101
done
@@ -99,11 +110,11 @@ project=$(basename ${BASEDIR})
99110
h1 "Building ${project}"
100111

101112

102-
# Over-rode SOURCE_MAVEN if you want to build from a different maven repo...
113+
# Override SOURCE_MAVEN if you want to build from a different maven repo...
103114
if [[ -z ${SOURCE_MAVEN} ]]; then
104115
export SOURCE_MAVEN=https://development.galasa.dev/main/maven-repo/obr/
105116
info "SOURCE_MAVEN repo defaulting to ${SOURCE_MAVEN}."
106-
info "Set this environment variable if you want to over-ride this value."
117+
info "Set this environment variable if you want to override this value."
107118
else
108119
info "SOURCE_MAVEN set to ${SOURCE_MAVEN} by caller."
109120
fi
@@ -169,7 +180,10 @@ function check_secrets {
169180
function build_application_code {
170181
h1 "Building simplatform application using maven"
171182
cd ${BASEDIR}/galasa-simplatform-application
172-
mvn clean install
183+
mvn clean install \
184+
-Dgalasa.source.repo=${SOURCE_MAVEN} \
185+
-Dgalasa.central.repo=https://repo.maven.apache.org/maven2/ \
186+
--settings ${BASEDIR}/settings.xml
173187
rc=$?
174188
if [[ "${rc}" != "0" ]]; then
175189
error "make clean install failed. rc=${rc}"
@@ -181,7 +195,10 @@ function build_application_code {
181195
function build_test_code {
182196
h1 "Building simbank tests using maven"
183197
cd ${BASEDIR}/galasa-simbank-tests
184-
mvn clean install
198+
mvn clean install \
199+
-Dgalasa.source.repo=${SOURCE_MAVEN} \
200+
-Dgalasa.central.repo=https://repo.maven.apache.org/maven2/ \
201+
--settings ${BASEDIR}/settings.xml
185202
rc=$?
186203
if [[ "${rc}" != "0" ]]; then
187204
error "make clean install failed. rc=${rc}"
@@ -204,5 +221,11 @@ function build_docker_image {
204221

205222
build_application_code
206223
build_test_code
207-
build_docker_image
208-
check_secrets
224+
225+
if [ "$SKIP_DOCKER" = false ]; then
226+
build_docker_image
227+
fi
228+
229+
if [ "$SKIP_SECRETS" = false ]; then
230+
check_secrets
231+
fi

0 commit comments

Comments
 (0)