-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (154 loc) · 5.43 KB
/
staging-check.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: staging-check
on:
pull_request:
branches: [ master ]
env:
JAVA_VERSION: "15"
JAVA_DISTRIBUTION: "zulu"
PULUMI_VERSION: "3.136.1"
GCP_SA_KEY_INFRA: ${{ secrets.GCP_SA_KEY_INFRA }}
jobs:
detect-changed-services:
runs-on: ubuntu-24.04
concurrency:
group: ${{ github.ref }}-detect-changed-services
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Collect all changed root directories
id: changed-root-directories
uses: tj-actions/changed-files@v45
with:
dir_names: true
dir_names_max_depth: '1'
- name: Collect all changed services
id: changed-services
env:
all_changed_files: ${{ steps.changed-root-directories.outputs.all_changed_files }}
run: |
CHANGED_SERVICES=()
for file in ${all_changed_files}; do
if [ -e "$file/infra/Pulumi.yaml" ]; then
CHANGED_SERVICES+=("$file")
fi
done
if [ ${#CHANGED_SERVICES[@]} -eq 0 ]; then
echo "No services changed"
else
joined=$(printf ",\"%s\"" "${CHANGED_SERVICES[@]}")
echo "changed_services=[${joined:1}]"
echo "changed_services=[${joined:1}]" >> "$GITHUB_OUTPUT"
fi
outputs:
changed_services: ${{ steps.changed-services.outputs.changed_services }}
service-check-build:
if: needs.detect-changed-services.outputs.changed_services != ''
runs-on: ubuntu-24.04
strategy:
matrix:
service: ${{ fromJSON(needs.detect-changed-services.outputs.changed_services) }}
concurrency:
group: ${{ github.ref }}-${{ matrix.service }}-service-check-build
cancel-in-progress: true
needs: detect-changed-services
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3 # By default, cache is only saved on the 'master' branch
- name: Set up secrets
run: |
set -Eeuo pipefail
bash tools/scripts/secrets.sh
- name: Build service
run: |
set -Eeuo pipefail
if [ -e "${{ matrix.service }}/gradlew" ]; then
# Need to explicitly cd into each service, otherwise we get yarn cache clashes
cd ${{ matrix.service }}
./gradlew --no-daemon assemble
cd ..
else
echo "Skipping step as required file doesn't exist"
fi
- name: Build container images
run: |
set -Eeuo pipefail
if [ -e "tools/docker/${{ matrix.service }}-compose.yaml" ]; then
docker compose -f tools/docker/${{ matrix.service }}-compose.yaml build
else
echo "Skipping step as required file doesn't exist"
fi
- name: Preview infrastructure
uses: pulumi/actions@v5
with:
command: preview
stack-name: prod
work-dir: ${{ matrix.service }}/infra
edit-pr-comment: false
pulumi-version: ${{ env.PULUMI_VERSION }}
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
- name: Artifacts
uses: actions/upload-artifact@v4
if: always() # Ensure all artifacts are collected, even after errors
with:
name: Build (${{ matrix.service }})
path: |
**/build
${{ matrix.service }}/infra
service-check-test:
if: needs.detect-changed-services.outputs.changed_services != ''
runs-on: ubuntu-24.04
strategy:
matrix:
service: ${{ fromJSON(needs.detect-changed-services.outputs.changed_services) }}
concurrency:
group: ${{ github.ref }}-${{ matrix.service }}-service-check-test
cancel-in-progress: true
needs: detect-changed-services
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3 # By default, cache is only saved on the 'master' branch
- name: Set up secrets
run: |
set -Eeuo pipefail
bash tools/scripts/secrets.sh
- name: Test
run: |
set -Eeuo pipefail
if [ -e "${{ matrix.service }}/gradlew" ]; then
# Need to explicitly cd into each service, otherwise we get yarn cache clashes
cd ${{ matrix.service }}
./gradlew --no-daemon --continue jsTest
cd ..
else
echo "Skipping step as required file doesn't exist"
fi
- name: Generate test report
uses: mikepenz/action-junit-report@v4
if: always() # Ensure all test reports are collected, even after errors
with:
report_paths: |
**/TEST-*.xml
check_name: service-check-test-results (${{ matrix.service }})
- name: Artifacts
uses: actions/upload-artifact@v4
if: always() # Ensure all artifacts are collected, even after errors
with:
name: Tests (${{ matrix.service }})
path: |
**/TEST-*.xml