-
Notifications
You must be signed in to change notification settings - Fork 103
200 lines (187 loc) · 6.8 KB
/
build-docker.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: Build Engine (Docker)
on:
workflow_dispatch:
inputs:
strip-symbols:
description: Strip Debug Symbols
required: true
default: 'true'
use-caches:
description: Use Caches (Docker/ccache)
required: true
default: 'true'
archtune-flags:
description: Arch/Tune Flags
required: false
default: ''
buildtype:
type: choice
description: Build Type
required: false
options:
- RELWITHDEBINFO
- DEBUG
- RELEASE
- PROFILE
default: 'RELWITHDEBINFO'
buildtype-flags:
description: Build Type Compilation Flags Override
required: false
default: ''
compilation-flags:
description: Extra Compilation Flags
required: false
default: ''
clean-ccache:
description: Reset ccache before build
required: false
default: 'false'
debug-tmate:
description: Debug with tmate (either "pre" or "post" Docker run)
required: false
default: 'false'
debug-ccache:
description: Generate ccache Debug Artifacts
required: false
default: 'false'
docker-image:
description: 'Docker Image to use (Docker Hub name or "*" to used embedded image)'
required: false
default: '*'
#default: 'verybadsoldier/springrts-build:dbg'
jobs:
build_engine:
name: ${{ matrix.config.os }}
runs-on: ${{ matrix.config.runs-on }}
strategy:
fail-fast: true
matrix:
config:
- {
os: 'windows-64',
runs-on: 'ubuntu-latest'
}
- {
os: 'linux-64',
runs-on: 'ubuntu-latest'
}
steps:
- name: Install pigz
run: |
sudo apt-get update
sudo apt-get install pigz
- name: Extract Branch Name
#https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions/58034787
id: extract-branch
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
shell: bash
- name: Print Build Info
run: |
echo "Build info:"
echo "Git commit hash: ${{ github.sha }}"
echo "Repository: ${{ github.repository }}"
df -h
shell: bash
- name: Checkout Source Repository
uses: actions/checkout@v3
- name: Get Random Number
id: get-random-number
run: |
number=$(head /dev/random -c 32 | sha1sum | awk '{ print $1 }')
echo "Generated random number: $number"
echo "number=${number}" >> "$GITHUB_OUTPUT"
shell: bash
- name: Download ccache Data
if: github.event.inputs.use-caches == 'true'
id: cache-dl
uses: actions/cache@v3
with:
path: /tmp/ccache_archive
key: ccache-${{ matrix.config.os }}-${{ steps.get-random-number.outputs.number }}
restore-keys: |
ccache-${{ matrix.config.os }}-
- name: Check and unpack ccache Data
id: cache
run: |
CACHE_FILENAME="/tmp/ccache_archive/${{ matrix.config.os }}.tgz"
echo "cache-filename=${CACHE_FILENAME}" >> "$GITHUB_OUTPUT"
if [ -f "${CACHE_FILENAME}" ]; then
echo "Found build ccache: ${CACHE_FILENAME}"
if [ "${{ github.event.inputs.clean-ccache }}" == "true" ]; then
echo "Deleting ccache: ${CACHE_FILENAME}"
rm -rf "${CACHE_FILENAME}"
else
echo "cache-hit=true" >> "$GITHUB_OUTPUT"
echo "Extracting..."
mkdir -p /tmp/ccache
tar -I pigz -xf "${CACHE_FILENAME}" -C /tmp/ccache
fi
else
echo "Not found ccache data"
echo "cache-hit=false" >> "$GITHUB_OUTPUT"
fi
df -h
shell: bash
- name: Build engine via docker
uses: ./docker-build
id: run-docker-build
with:
archtune-flags: "${{ github.event.inputs.archtune-flags }}"
buildtype: "${{ github.event.inputs.buildtype }}"
buildtype-flags: "${{ github.event.inputs.buildtype-flags }}"
compilation-flags: "${{ github.event.inputs.compilation-flags }}"
use-cache: "${{ github.event.inputs.use-caches }}"
platform: "${{ matrix.config.os }}"
branch: "${{ env.BRANCH_NAME }}"
repository-url: "https://github.com/${{ github.repository }}"
debug-tmate: "${{ github.event.inputs.debug-tmate }}"
debug-ccache: "${{ github.event.inputs.debug-ccache }}"
docker-image: "${{ github.event.inputs.docker-image }}"
- name: Upload Bin as Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.run-docker-build.outputs.bin_name }}
path: ${{ github.workspace }}/artifacts/${{ steps.run-docker-build.outputs.bin_name }}
if-no-files-found: error
- name: Upload Dbg Artifacts
if: github.event.inputs.strip-symbols == 'true'
uses: actions/upload-artifact@v3
with:
name: ${{ steps.run-docker-build.outputs.dbg_name }}
path: ${{ github.workspace }}/artifacts/${{ steps.run-docker-build.outputs.dbg_name }}
if-no-files-found: error
- name: Upload Build Options Artifact
uses: actions/upload-artifact@v3
with:
name: buildoptions_${{ matrix.config.os }}.txt
path: ${{ github.workspace }}/artifacts/buildoptions_${{ matrix.config.os }}.txt
if-no-files-found: error
- name: Pack ccache Data
if: github.event.inputs.use-caches == 'true'
run: |
CACHE_FILENAME="${{ steps.cache.outputs.cache-filename }}"
echo "Creating cache file: ${CACHE_FILENAME}"
mkdir -p /tmp/ccache_archive
rm -rf /tmp/ccache_archive/*
tar cvf - -C /tmp/ccache . 2> /dev/null | pigz -1 > "${CACHE_FILENAME}"
echo "Raw ccache size: $(du -sch /tmp/ccache | tail -n1 | cut -f1)"
echo "Archived ccache size: $(du -h "${CACHE_FILENAME}" | cut -f1)"
- name: Upload ccache Debug Data
uses: actions/upload-artifact@v3
if: github.event.inputs.debug-ccache == 'true'
with:
name: ccache_debug_${{ matrix.config.os }}.tgz
path: ${{ github.workspace }}/artifacts/${{ steps.run-docker-build.outputs.ccache_dbg }}
if-no-files-found: error
- name: Free Filesystem Space
id: freefsspace
run: |
echo "Filesystem before cleanup:"
df -h
docker system df
echo "Pruning docker images..."
docker image prune -a -f
echo "Filesystem after cleanup:"
df -h
docker system df
shell: bash