-
Notifications
You must be signed in to change notification settings - Fork 71
152 lines (136 loc) · 4.23 KB
/
build.yml
File metadata and controls
152 lines (136 loc) · 4.23 KB
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
name: build
on:
push:
branches: [ develop, 'feature/**' ]
pull_request:
branches: [ develop, 'feature/**' ]
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 25 ]
steps:
- name: Checkout GitHub sources
uses: actions/checkout@v6
- name: Setup JDK ${{ matrix.java }}
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: ${{ matrix.java }}
- name: Cache Maven packages
uses: actions/cache@v5
with:
path: |
~/.m2/repository
!~/.m2/repository/io/aklivity/zilla
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: ./mvnw -B -U -nsu -ntp -Ddocker.logStdout -Dfailsafe.skipAfterFailureCount=1 -Ddocker.verbose install jacoco:report-aggregate
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ github.token }}
- name: Save Docker image
if: success()
run: |
mkdir -p ~/docker-cache
docker save -o ~/docker-cache/docker.tar $(docker images --format "{{.Repository}}" | grep "zilla")
- name: Cache Docker image
uses: actions/cache@v5
if: success()
with:
path: ~/docker-cache/docker.tar
key: zilla-develop-SNAPSHOT-${{ github.run_id }}
- name: Conditional Artifact Upload
uses: actions/upload-artifact@v6
if: failure()
with:
name: zilla-build-${{ matrix.java }}-${{ github.event.number }}
path: |
**/hs_err_pid*.log
**/target/surefire-reports/
**/target/zilla-itests/
**/target/failsafe-reports/
setup-examples:
runs-on: ubuntu-latest
needs:
- build
outputs:
all_directories: ${{ steps.all-files.outputs.folders_no_base_path }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get examples dirs
id: all-files
uses: Drafteame/list-folders-action@main
with:
paths: |
examples
omit: |
^\.github$
^\.assets$
^\.git$
^\.vscode$
^tcp.reflect$
^ws.proxy$
^ws.reflect$
^http.echo$
^grpc.kafka.proxy$
testing:
strategy:
matrix:
dir: ${{ fromJson(needs.setup-examples.outputs.all_directories) }}
fail-fast: false
needs:
- setup-examples
runs-on: ubuntu-latest
env:
ZILLA_VERSION: develop-SNAPSHOT
steps:
- name: Checkout
uses: actions/checkout@v6
with:
sparse-checkout: examples/${{ matrix.dir }}
- name: Restore cached Docker images
uses: actions/cache@v5
with:
path: ~/docker-cache/docker.tar
key: zilla-develop-SNAPSHOT-${{ github.run_id }}
- name: Load cached Docker image
run: |
docker load -i ~/docker-cache/docker.tar
- name: Cache Docker images
if: ${{ hashFiles(format('examples/{0}/compose.yaml', matrix.dir)) != '' }}
uses: ScribeMD/docker-cache@0.5.0
with:
key: docker-${{ runner.os }}-${{ matrix.dir }}-${{ hashFiles(format('examples/{0}/compose.yaml', matrix.dir)) }}
- name: Start Zilla and wait for it to be healthy
working-directory: examples/${{ matrix.dir }}
run: docker compose up -d --wait
- name: Execute Test
working-directory: examples/${{ matrix.dir }}
run: |
set -o pipefail
./.github/test.sh | tee $GITHUB_STEP_SUMMARY
- name: Collect docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2
with:
dest: "./logs"
- name: Tar logs
if: failure()
run: tar cvzf ./logs.tgz ./logs
- name: Upload logs to GitHub
if: failure()
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.dir }}_logs.tgz
path: ./logs.tgz
- name: Teardown
if: ${{ always() && hashFiles(format('examples/{0}/teardown.sh', matrix.dir)) != '' }}
working-directory: examples/${{ matrix.dir }}
run: docker compose down --remove-orphans