-
Notifications
You must be signed in to change notification settings - Fork 32
261 lines (261 loc) · 8.8 KB
/
native-build.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
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
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
meta-package:
description: "Meta-package name to publish"
required: false
default: ""
type: string
extra-tools:
description: "Extra meta-package tools publish"
required: false
default: ""
type: string
fast-hack:
description: "Publish fast (deprecated) packages"
required: false
default: false
type: boolean
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: fprime-community/native-images-action@main
- 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 }}/*
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 )"
- 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-13",
"tag": "macosx_13_0_universal2"
},
{
"runner": "ubuntu-22.04",
"tag": "manylinux_2_28_x86_64",
"container": "quay.io/pypa/manylinux_2_28_x86_64"
}
]
}
if "${{ github.event_name }}" == 'release':
matrix["run"].append(
{
"runner": "odroid",
"tag": "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: "Setup Native Image Tools"
uses: fprime-community/native-images-action@main
- 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: "Build Native Images"
run: |
export CLASSPATH="`cd ${{ inputs.trace-directory }}/../..; pwd`:${CLASSPATH}"
cd ${{ inputs.working-directory }}
$NATIVE_IMAGE_TOOLS_PATH/native-images ${{ inputs.output-directory }} ${{ inputs.tools }}
shell: bash
- name: "Archive Native Images"
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.run.tag }}
path: ${{ inputs.output-directory }}/*
retention-days: 5
if-no-files-found: error
- name: "Testing Native Images via Unit-Tests"
run: |
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: "Download Package"
uses: actions/download-artifact@v4
with:
name: build-${{ matrix.tag }}
path: ${{ inputs.output-directory }}
- name: "Install Builder"
run: pip install fprime-native-images
shell: bash
- name: "Run Builder"
run: |
FLAGS="--package-tag ${{ matrix.tag }} --extra-tools ${{ inputs.extra-tools }}"
if [[ "${{ matrix.tag }}" == "jar" ]] && [[ "${{ inputs.meta-package }}" != "" ]]
then
echo "[INFO] Generating Meta-Package: ${{ inputs.meta-package }}"
FLAGS="${FLAGS} --meta-package ${{ inputs.meta-package }}"
elif [[ "${{ inputs.fast-hack }}" == "true" ]]
then
echo "[INFO] Generating fast-hack packages"
FLAGS="${FLAGS} --fast-hack"
fi
fprime-native-packager ${{ inputs.output-directory }} ${FLAGS}
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@main
- 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