Skip to content

Commit 74be717

Browse files
authored
ci: run tests (#127)
1 parent 0a92105 commit 74be717

2 files changed

Lines changed: 132 additions & 6 deletions

File tree

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: integration-tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
# Manual trigger for integration tests - requires approval via environment protection
9+
inputs:
10+
skip_integration_tests:
11+
description: 'Skip integration tests'
12+
required: false
13+
type: boolean
14+
default: false
15+
16+
# Cancel in-progress runs when a new commit is pushed
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
integration-tests:
23+
name: Integration Tests (Java ${{ matrix.java-version }})
24+
runs-on: ubuntu-latest
25+
environment:
26+
name: test-integration-dal
27+
deployment: false
28+
timeout-minutes: 30
29+
strategy:
30+
matrix:
31+
java-version: ['11', '17']
32+
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v5
36+
37+
- name: Set up Java ${{ matrix.java-version }}
38+
uses: actions/setup-java@v5
39+
with:
40+
java-version: ${{ matrix.java-version }}
41+
distribution: 'temurin'
42+
cache: 'maven'
43+
44+
- name: Build project
45+
run: mvn clean install -DskipTests --settings build/.github.settings.xml
46+
47+
- name: Create .env files
48+
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && !inputs.skip_integration_tests)
49+
env:
50+
CLOUD_API_KEY: ${{ secrets.CLOUD_API_KEY }}
51+
CD_TOOLCHAIN_URL: ${{ vars.CD_TOOLCHAIN_URL }}
52+
CD_TOOLCHAIN_AUTH_TYPE: ${{ vars.CD_TOOLCHAIN_AUTH_TYPE }}
53+
CD_TOOLCHAIN_EVENT_NOTIFICATIONS_SERVICE_CRN: ${{ vars.CD_TOOLCHAIN_EVENT_NOTIFICATIONS_SERVICE_CRN }}
54+
CD_TOOLCHAIN_RESOURCE_GROUP_ID: ${{ vars.CD_TOOLCHAIN_RESOURCE_GROUP_ID }}
55+
CD_TEKTON_PIPELINE_URL: ${{ vars.CD_TEKTON_PIPELINE_URL }}
56+
CD_TEKTON_PIPELINE_AUTH_TYPE: ${{ vars.CD_TEKTON_PIPELINE_AUTH_TYPE }}
57+
CD_TEKTON_PIPELINE_RESOURCE_GROUP_ID: ${{ vars.CD_TEKTON_PIPELINE_RESOURCE_GROUP_ID }}
58+
run: |
59+
set -e
60+
61+
# Verify all required environment variables are set
62+
if [ -z "$CLOUD_API_KEY" ]; then
63+
echo "Error: CLOUD_API_KEY secret is not set"
64+
exit 1
65+
fi
66+
67+
if [ -z "$CD_TOOLCHAIN_URL" ] || [ -z "$CD_TOOLCHAIN_AUTH_TYPE" ] || \
68+
[ -z "$CD_TOOLCHAIN_RESOURCE_GROUP_ID" ] || [ -z "$CD_TOOLCHAIN_EVENT_NOTIFICATIONS_SERVICE_CRN" ]; then
69+
echo "Error: One or more CD_TOOLCHAIN variables are not set"
70+
echo "Please configure all required variables in GitHub repository settings"
71+
exit 1
72+
fi
73+
74+
if [ -z "$CD_TEKTON_PIPELINE_URL" ] || [ -z "$CD_TEKTON_PIPELINE_AUTH_TYPE" ] || \
75+
[ -z "$CD_TEKTON_PIPELINE_RESOURCE_GROUP_ID" ]; then
76+
echo "Error: One or more CD_TEKTON_PIPELINE variables are not set"
77+
echo "Please configure all required variables in GitHub repository settings"
78+
exit 1
79+
fi
80+
81+
# cd_toolchain_v2.env
82+
cat > cd_toolchain_v2.env << EOF
83+
CD_TOOLCHAIN_URL=${CD_TOOLCHAIN_URL}
84+
CD_TOOLCHAIN_AUTH_TYPE=${CD_TOOLCHAIN_AUTH_TYPE}
85+
CD_TOOLCHAIN_APIKEY=${CLOUD_API_KEY}
86+
CD_TOOLCHAIN_EVENT_NOTIFICATIONS_SERVICE_CRN=${CD_TOOLCHAIN_EVENT_NOTIFICATIONS_SERVICE_CRN}
87+
CD_TOOLCHAIN_RESOURCE_GROUP_ID=${CD_TOOLCHAIN_RESOURCE_GROUP_ID}
88+
EOF
89+
90+
# cd_tekton_pipeline_v2.env
91+
cat > cd_tekton_pipeline_v2.env << EOF
92+
CD_TEKTON_PIPELINE_URL=${CD_TEKTON_PIPELINE_URL}
93+
CD_TEKTON_PIPELINE_AUTH_TYPE=${CD_TEKTON_PIPELINE_AUTH_TYPE}
94+
CD_TEKTON_PIPELINE_APIKEY=${CLOUD_API_KEY}
95+
CD_TEKTON_PIPELINE_RESOURCE_GROUP_ID=${CD_TEKTON_PIPELINE_RESOURCE_GROUP_ID}
96+
CD_TOOLCHAIN_URL=${CD_TOOLCHAIN_URL}
97+
CD_TOOLCHAIN_AUTH_TYPE=${CD_TOOLCHAIN_AUTH_TYPE}
98+
CD_TOOLCHAIN_APIKEY=${CLOUD_API_KEY}
99+
CD_TOOLCHAIN_RESOURCE_GROUP_ID=${CD_TOOLCHAIN_RESOURCE_GROUP_ID}
100+
EOF
101+
102+
# Verify files were created successfully
103+
if [ ! -f cd_toolchain_v2.env ] || [ ! -f cd_tekton_pipeline_v2.env ]; then
104+
echo "Error: Failed to create .env files"
105+
exit 1
106+
fi
107+
108+
echo "✓ Environment files created successfully"
109+
echo "✓ cd_toolchain_v2.env: $(wc -l < cd_toolchain_v2.env) lines"
110+
echo "✓ cd_tekton_pipeline_v2.env: $(wc -l < cd_tekton_pipeline_v2.env) lines"
111+
112+
- name: Run integration tests
113+
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && !inputs.skip_integration_tests)
114+
run: mvn verify -DskipTests --settings build/.github.settings.xml
115+
116+
- name: Cleanup .env files
117+
if: always() && (github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && !inputs.skip_integration_tests))
118+
run: |
119+
rm -f cd_tekton_pipeline_v2.env cd_toolchain_v2.env
120+
echo "✓ Environment files cleaned up"

.github/workflows/pr.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
branches:
66
- main
77
workflow_dispatch:
8-
# Allow workflow to be triggered manually.
98

9+
# Cancel in-progress runs when a new commit is pushed
1010
concurrency:
1111
group: ${{ github.workflow }}-${{ github.ref }}
1212
cancel-in-progress: true
@@ -24,7 +24,7 @@ jobs:
2424
- name: Setup Python
2525
uses: actions/setup-python@v6
2626
with:
27-
python-version: 3.12
27+
python-version: 3.14
2828

2929
- name: Install detect-secrets
3030
run: |
@@ -35,8 +35,8 @@ jobs:
3535
detect-secrets scan --update .secrets.baseline --exclude-files 'build/signing\.key\.enc'
3636
detect-secrets -v audit --report --fail-on-unaudited --fail-on-live --fail-on-audited-real .secrets.baseline
3737
38-
build-test:
39-
name: Build and Test (Java ${{ matrix.java-version }})
38+
unit-tests:
39+
name: Unit Tests (Java ${{ matrix.java-version }})
4040
needs: detect-secrets
4141
runs-on: ubuntu-latest
4242
timeout-minutes: 30
@@ -55,5 +55,11 @@ jobs:
5555
distribution: 'temurin'
5656
cache: 'maven'
5757

58-
- name: Build and test
59-
run: mvn verify -fae -DskipITs --settings build/.github.settings.xml
58+
- name: Build project
59+
run: mvn clean install -DskipTests --settings build/.github.settings.xml
60+
61+
- name: Run unit tests
62+
run: mvn test -DskipITs --settings build/.github.settings.xml
63+
64+
- name: Run linter
65+
run: mvn checkstyle:check --settings build/.github.settings.xml

0 commit comments

Comments
 (0)