Skip to content

Commit 58050f8

Browse files
authored
Merge pull request #16 from hide24/develop
CI by GitHub Actions
2 parents cfa9929 + 78101a7 commit 58050f8

2 files changed

Lines changed: 99 additions & 0 deletions

File tree

.github/scripts/ci/run-tests.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
set -x
4+
5+
if [ "$#" -ne 1 ]; then
6+
echo "usage: $0 <TEST_BUILD>" >&2
7+
exit 1
8+
fi
9+
10+
TEST_BUILD="$1"
11+
REPO_ROOT=$(git rev-parse --show-toplevel)
12+
cd "$REPO_ROOT"
13+
14+
read -r -d '' container_script <<'BASH' || true
15+
rm ~/.m2/settings.xml
16+
cp -R $JAVA_HOME ~/.jdk
17+
export JAVA_HOME=~/.jdk
18+
curl -L --cookie 'oraclelicense=accept-securebackup-cookie;' http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip -o /tmp/policy.zip
19+
unzip -j -o /tmp/policy.zip *.jar -d $JAVA_HOME/jre/lib/security
20+
rm /tmp/policy.zip
21+
mvn install -P nocheck
22+
mvn test -P !nocheck
23+
BASH
24+
25+
docker run --rm -t \
26+
-e TEST_BUILD="$TEST_BUILD" \
27+
${CAS_TEST_IMAGE} bash -lc "$container_script"
28+

.github/workflows/unit-tests.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- '[0-9]*'
7+
pull_request:
8+
branches: [ master, develop ]
9+
10+
jobs:
11+
build-image:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
outputs:
16+
image: ${{ steps.meta.outputs.image }}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Build Docker image
22+
id: build
23+
run: |
24+
docker build -t rdm-cas-test:${{ github.sha }} -f ./Dockerfile .
25+
26+
- name: Save Docker image
27+
run: |
28+
docker save rdm-cas-test:${{ github.sha }} -o /tmp/rdm-cas-image.tar
29+
30+
- name: Upload Docker image artifact
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: rdm-cas-image
34+
path: /tmp/rdm-cas-image.tar
35+
retention-days: 1
36+
37+
- name: Export image reference
38+
id: meta
39+
run: echo "image=rdm-cas-test:${{ github.sha }}" >> "$GITHUB_OUTPUT"
40+
41+
tests:
42+
runs-on: ubuntu-latest
43+
needs: build-image
44+
permissions:
45+
contents: read
46+
timeout-minutes: 90
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
test_build: [cas]
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
55+
- name: Download Docker image artifact
56+
uses: actions/download-artifact@v4
57+
with:
58+
name: rdm-cas-image
59+
path: /tmp
60+
61+
- name: Load Docker image
62+
run: |
63+
docker load -i /tmp/rdm-cas-image.tar
64+
65+
- name: Run matrix job
66+
env:
67+
TEST_BUILD: ${{ matrix.test_build }}
68+
CAS_TEST_IMAGE: ${{ needs.build-image.outputs.image }}
69+
run: |
70+
bash .github/scripts/ci/run-tests.sh "$TEST_BUILD"
71+

0 commit comments

Comments
 (0)