-
Notifications
You must be signed in to change notification settings - Fork 53
264 lines (263 loc) · 9.08 KB
/
native-build.yml
File metadata and controls
264 lines (263 loc) · 9.08 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
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
name: 'fprime-build-native-scala'
on:
workflow_call:
inputs:
working-directory:
description: "Working directory to use when running commands"
required: false
default: .
type: string
build:
description: "Build command for generating compiled JARs"
required: false
default: ./install
type: string
output-directory:
description: "Directory for output of the build"
required: false
default: ./bin
type: string
test:
description: "Test command used to generate tracing and prove output"
required: false
default: ./test
type: string
trace:
description: "Turn off tracing step"
required: false
default: true
type: boolean
trace-directory:
description: "Directory for tracing output"
required: false
default: trace/META-INF/native-image
type: string
extra-tools:
description: "Extra meta-package tools publish"
required: false
default: ""
type: string
jobs:
build-jars:
runs-on: "ubuntu-22.04"
name: "Build Standard JARs"
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
with:
submodules: recursive
- name: "Setup Native Image Tools"
uses: ./.github/actions/native-tools-setup
- name: "Building JAR files"
run: |
cd ${{ inputs.working-directory }}
${{ inputs.build }} ${{ inputs.output-directory }}
shell: bash
- name: "Archiving JARs package"
uses: actions/upload-artifact@v4
with:
name: build-jar
path: ${{ inputs.output-directory }}/fpp.jar
retention-days: 5
if-no-files-found: error
- if: ${{ inputs.trace }}
name: "Tracing JARs via Unit-Tests"
run: |
cd ${{ inputs.working-directory }}
mkdir -p "${{ inputs.trace-directory }}"
export TRACE_METADATA_DIRECTORY="$( pwd )/${{ inputs.trace-directory }}"
export PATH="${NATIVE_IMAGE_TOOLS_PATH}:${PATH}"
${{ inputs.test }}
echo -e "Trace output files:\n$( find ${{ inputs.trace-directory }} -name *.json )"
- if: ${{ inputs.trace }}
name: "Archiving Tracing"
uses: actions/upload-artifact@v4
with:
name: jar-traces
path: ${{ inputs.trace-directory }}/*.json
retention-days: 5
if-no-files-found: error
generate-run-matricies:
outputs:
native: ${{ steps.set-matrix.outputs.native }}
tags: ${{ steps.set-matrix.outputs.tags }}
runs-on: ubuntu-22.04
steps:
- id: set-matrix
shell: python
run: |
import os
import json
import sys
matrix = {
"run": [
{
"runner": "macos-14",
"tag": "macosx_14_0_arm64"
},
{
"runner": "macos-15-intel",
"tag": "macosx_15_0_x86_64"
},
{
"runner": "ubuntu-22.04",
"tag": "manylinux_2_28_x86_64",
"container": "quay.io/pypa/manylinux_2_28_x86_64"
},
{
"runner": "ubuntu-22.04-arm",
"tag": "manylinux_2_28_aarch64",
"container": "quay.io/pypa/manylinux_2_28_aarch64"
}
]
}
tags = {"tag": ["jar"] + [run["tag"] for run in matrix["run"]]}
with open(os.environ["GITHUB_OUTPUT"], "a") as file_handle:
for file_stream in [sys.stdout, file_handle]:
print(f"native={json.dumps(matrix)}", file=file_stream)
print(f"tags={json.dumps(tags)}", file=file_stream)
build-native-images:
needs: [build-jars, generate-run-matricies]
strategy:
matrix: ${{ fromJson(needs.generate-run-matricies.outputs.native) }}
runs-on: ${{ matrix.run.runner }}
container:
image: ${{ matrix.run.container || '' }}
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
with:
submodules: recursive
- name: "Download JARs"
uses: actions/download-artifact@v4
with:
name: build-jar
path: ${{ inputs.output-directory }}
- if: ${{ inputs.trace }}
name: "Download Tracing"
uses: actions/download-artifact@v4
with:
name: jar-traces
path: ${{ inputs.trace-directory }}
- name: "Setting up GraalVM/Java Environment"
uses: ./.github/actions/native-tools-setup
- name: "Build Native Images"
uses: ./.github/actions/build-native-images
with:
binary-directory: ${{ inputs.output-directory }}
trace-directory: ${{ inputs.trace-directory }}
- name: "Archive Native Images"
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.run.tag }}
path: ${{ inputs.output-directory }}/fpp
retention-days: 5
if-no-files-found: error
- name: "Testing Native Images via Unit-Tests"
run: |
# Generate wrappers for tools
tool_names=`cat ${{ inputs.working-directory }}/compiler/tools.txt`
for tool in $tool_names
do
tool_wrapper="${{ inputs.output-directory }}/fpp-$tool"
echo "Generating wrapper for fpp-$tool in $tool_wrapper"
echo '#!/bin/sh
"`dirname $0`/fpp" '$tool' "$@"' > $tool_wrapper
chmod +x $tool_wrapper
done
cd ${{ inputs.working-directory }}
${{ inputs.test }}
build-wheels:
needs: [build-jars, build-native-images, generate-run-matricies]
runs-on: ubuntu-22.04
strategy:
matrix: ${{ fromJson(needs.generate-run-matricies.outputs.tags) }}
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
with:
submodules: recursive
- name: "Make Output Directory"
run: mkdir -p ${{ inputs.output-directory }}
- name: "Download Package"
uses: actions/download-artifact@v4
with:
name: build-${{ matrix.tag }}
path: ${{ inputs.output-directory }}
- name: "Run Builder"
run: |
pip install build
# Place the native files in the python package and determine platform options
PLATFORM_OPTIONS=""
if [[ "${{ matrix.tag }}" != "jar" ]]; then
PLATFORM_OPTIONS="--config-setting=--build-option=--plat-name=${{ matrix.tag }}"
cp -vr ${{ inputs.output-directory }}/fpp python/fprime_fpp/
else
cp -vr ${{ inputs.output-directory }}/*.jar python/fprime_fpp/
fi
# Github archiving clears executable flag, so put it back
chmod +x python/fprime_fpp/fpp*
python3 -m build --wheel --outdir packages/dist $PLATFORM_OPTIONS .
shell: bash
- name: "Archiving Wheels"
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.tag }}
path: packages/dist/*
retention-days: 5
if-no-files-found: error
test-wheels:
needs: [build-wheels, generate-run-matricies]
strategy:
matrix: ${{ fromJson(needs.generate-run-matricies.outputs.native) }}
runs-on: ${{ matrix.run.runner }}
steps:
- name: "Setup Native Image Tools"
uses: fprime-community/native-images-action@unified-tool
- name: "Download Native Wheels"
uses: actions/download-artifact@v4
with:
name: wheels-${{ matrix.run.tag }}
path: ${{ inputs.output-directory }}/native
- name: "Download JAR Wheels"
uses: actions/download-artifact@v4
with:
name: wheels-jar
path: ${{ inputs.output-directory }}/jars
- name: "Test Packages"
run: |
for subdir in native jars
do
python3 -m venv ./test-${subdir}
. ./test-${subdir}/bin/activate
echo "[INFO] Testin ${subdir} Wheels"
$NATIVE_IMAGE_TOOLS_PATH/test-wheels "${{ inputs.output-directory }}/${subdir}" "${{ inputs.meta-package }}" || exit $?
done
shell: bash
publish-wheels:
if: ${{ github.event_name == 'release' }}
needs: [test-wheels, generate-run-matricies]
runs-on: ubuntu-22.04
strategy:
matrix: ${{ fromJson(needs.generate-run-matricies.outputs.tags) }}
steps:
- name: "Download Package"
uses: actions/download-artifact@v4
with:
name: wheels-${{ matrix.tag }}
path: dist
- name: "Install Builder"
run: pip install twine
shell: bash
- name: Publish distributions to TestPyPI
env:
TWINE_PASSWORD: ${{ secrets.TESTPYPI_CREDENTIAL }}
run: |
twine upload -r testpypi -u "__token__" dist/*
shell: bash
- name: Publish distributions to PyPI
env:
TWINE_PASSWORD: ${{ secrets.PYPI_CREDENTIAL }}
run: |
twine upload -u "__token__" dist/*
shell: bash