-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (116 loc) · 4.96 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Run Tests
on:
workflow_dispatch: {}
push:
branches: [ master ]
paths-ignore: [ '**.md' ]
pull_request:
# Branch settings require status checks before merging, so don't add paths-ignore.
branches: [ master ]
env:
JANITOR_APP_SA_FILE: src/test/resources/rendered/sa-account.json
JANITOR_CLIENT_SA_FILE: src/test/resources/rendered/client-sa-account.json
JANITOR_CLIENT_SA_TOOLS_FILE: src/test/resources/rendered/tools-client-sa-account.json
JANITOR_CLOUD_ACCESS_SA_FILE: src/test/resources/rendered/cloud-access-sa-account.json
LOCAL_PROPERTIES_DIR: config
jobs:
unit-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16.6
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v3
- name: Skip version bump merges
id: skiptest
uses: ./.github/actions/bump-skip
with:
event-name: ${{ github.event_name }}
- name: Render secrets for tests
if: steps.skiptest.outputs.is-bump == 'no'
run: |
JANITOR_APP_SA_B64=${{ secrets.JANITOR_APP_SA }}
echo ::add-mask::$JANITOR_APP_SA_B64
JANITOR_APP_SA=$(echo $JANITOR_APP_SA_B64 | base64 --decode)
echo ::add-mask::$JANITOR_APP_SA
echo $JANITOR_APP_SA > $JANITOR_APP_SA_FILE
JANITOR_CLIENT_SA_B64=${{ secrets.JANITOR_CLIENT_SA }}
echo ::add-mask::$JANITOR_CLIENT_SA_B64
JANITOR_CLIENT_SA=$(echo $JANITOR_CLIENT_SA_B64 | base64 --decode)
echo ::add-mask::$JANITOR_CLIENT_SA
echo $JANITOR_CLIENT_SA > $JANITOR_CLIENT_SA_FILE
JANITOR_CLIENT_SA_TOOLS_B64=${{ secrets.JANITOR_CLIENT_SA_TOOLS }}
echo ::add-mask::$JANITOR_CLIENT_SA_TOOLS_B64
JANITOR_CLIENT_SA_TOOLS=$(echo $JANITOR_CLIENT_SA_TOOLS_B64 | base64 --decode)
echo ::add-mask::$JANITOR_CLIENT_SA_TOOLS
echo $JANITOR_CLIENT_SA_TOOLS > $JANITOR_CLIENT_SA_TOOLS_FILE
JANITOR_CLOUD_ACCESS_SA_B64=${{ secrets.JANITOR_CLOUD_ACCESS_SA }}
echo ::add-mask::JANITOR_CLOUD_ACCESS_SA_B64
JANITOR_CLOUD_ACCESS_SA=$(echo $JANITOR_CLOUD_ACCESS_SA_B64 | base64 --decode)
echo ::add-mask::$JANITOR_CLOUD_ACCESS_SA
echo $JANITOR_CLOUD_ACCESS_SA > $JANITOR_CLOUD_ACCESS_SA_FILE
AZURE_PUBLISHER_CLIENT_ID=${{ secrets.AZURE_PUBLISHER_CLIENT_ID }}
echo ::add-mask::$AZURE_PUBLISHER_CLIENT_ID
AZURE_PUBLISHER_CLIENT_SECRET=${{ secrets.AZURE_PUBLISHER_CLIENT_SECRET }}
echo ::add-mask::$AZURE_PUBLISHER_CLIENT_SECRET
AZURE_PUBLISHER_TENANT_ID=${{ secrets.AZURE_PUBLISHER_TENANT_ID }}
echo ::add-mask::$AZURE_PUBLISHER_TENANT_ID
mkdir -p "${LOCAL_PROPERTIES_DIR}"
cat << EOF > ${LOCAL_PROPERTIES_DIR}/local-properties.yml
janitor:
azure:
managed-app-client-id: ${AZURE_PUBLISHER_CLIENT_ID}
managed-app-client-secret: ${AZURE_PUBLISHER_CLIENT_SECRET}
managed-app-tenant-id: ${AZURE_PUBLISHER_TENANT_ID}
EOF
- name: Initialize Postgres DB
if: steps.skiptest.outputs.is-bump == 'no'
env:
PGPASSWORD: postgres
run: psql -h 127.0.0.1 -U postgres -f ./local-dev/local-postgres-init.sql
- name: Set up JDK 17
if: steps.skiptest.outputs.is-bump == 'no'
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Cache Gradle packages
if: steps.skiptest.outputs.is-bump == 'no'
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: v1-${{ runner.os }}-gradle-${{ hashfiles('**/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle') }}
restore-keys: v1-${{ runner.os }}-gradle-${{ hashfiles('**/gradle-wrapper.properties') }}
- name: Grant execute permission for gradlew
if: steps.skiptest.outputs.is-bump == 'no'
run: chmod +x gradlew
- name: Check Javadoc
if: steps.skiptest.outputs.is-bump == 'no'
run: ./gradlew javadoc --scan
- name: Run unit tests
if: steps.skiptest.outputs.is-bump == 'no'
id: unit-test
run: ./gradlew unitTest --scan
- name: Run integration tests
if: steps.skiptest.outputs.is-bump == 'no'
id: integration-test
run: ./gradlew integrationTest --scan
- name: Upload Test Reports
if: always() && steps.skiptest.outputs.is-bump == 'no'
uses: actions/upload-artifact@v3
with:
name: Test Reports
path: build/reports/tests