Skip to content

Commit 73ec7a7

Browse files
committed
OPHYK-212 Run basic test set during build
1 parent aa7d1fe commit 73ec7a7

File tree

2 files changed

+67
-18
lines changed

2 files changed

+67
-18
lines changed

infra/src/cdk-app-util.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,24 +107,24 @@ class ContinuousDeploymentPipelineStack extends cdk.Stack {
107107
const sourceStage = pipeline.addStage({ stageName: "Source" });
108108
sourceStage.addAction(sourceAction);
109109

110-
//const runTests = env === "hahtuva";
111-
//if (runTests) {
112-
// const testStage = pipeline.addStage({ stageName: "Test" });
113-
// testStage.addAction(
114-
// new codepipeline_actions.CodeBuildAction({
115-
// actionName: "TestOrganisaatio",
116-
// input: sourceOutput,
117-
// project: makeTestProject(
118-
// this,
119-
// env,
120-
// tag,
121-
// "TestOrganisaatio",
122-
// ["scripts/ci/run-tests.sh"],
123-
// "corretto21"
124-
// ),
125-
// })
126-
// );
127-
//}
110+
const runTests = env === "hahtuva";
111+
if (runTests) {
112+
const testStage = pipeline.addStage({ stageName: "Test" });
113+
testStage.addAction(
114+
new codepipeline_actions.CodeBuildAction({
115+
actionName: "TestOrganisaatio",
116+
input: sourceOutput,
117+
project: makeTestProject(
118+
this,
119+
env,
120+
tag,
121+
"TestOrganisaatio",
122+
["scripts/ci/run-tests.sh"],
123+
"corretto21"
124+
),
125+
})
126+
);
127+
}
128128

129129
const deployProject = new codebuild.PipelineProject(
130130
this,

scripts/ci/run-tests.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
set -o errexit -o nounset -o pipefail
3+
4+
repo="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../.. && pwd )"
5+
source "${repo}/scripts/lib/common-functions.sh"
6+
7+
trap stop_database EXIT
8+
9+
function main {
10+
init_nodejs
11+
install_npm_dependencies
12+
start_database
13+
build_and_test_frontend
14+
build_and_test_jar
15+
}
16+
17+
function install_npm_dependencies {
18+
for bom_dir in "${repo}/playwright" \
19+
"${repo}/organisaatio-ui" \
20+
"${repo}/mock-api"; do
21+
cd ${bom_dir}
22+
npm_ci_if_needed
23+
done
24+
}
25+
26+
function start_database {
27+
cd $repo
28+
docker compose up --detach
29+
}
30+
31+
function stop_database {
32+
cd $repo
33+
docker compose down
34+
}
35+
36+
function build_and_test_frontend {
37+
cd $repo/organisaatio-ui
38+
npm run lint
39+
npm run prettier
40+
CI=true npm run test
41+
npm run build
42+
}
43+
44+
function build_and_test_jar {
45+
cd $repo
46+
./gradlew clean build
47+
}
48+
49+
main "$@"

0 commit comments

Comments
 (0)