-
Notifications
You must be signed in to change notification settings - Fork 4
201 lines (183 loc) · 7.1 KB
/
Copy pathbuild-binary.yml
File metadata and controls
201 lines (183 loc) · 7.1 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
name: Build Binary
# Manual-only workflow: builds OMFrontend with PackageCompiler. Two targets
# are supported, selected by the `target` input:
#
# sysimage Per-platform Julia sysimage (.so / .dylib / .dll). End users
# start it with `julia --sysimage=<file> --project=<env>`.
# app Self-contained executable directory built via create_app.
# Entry point is OMFrontend.julia_main (a small CLI defined in
# src/cli.jl). Run as `bin/OMFrontend [command] [options]`.
# both Build both artifacts in the same job.
#
# Trigger from the Actions UI ("Run workflow").
on:
workflow_dispatch:
inputs:
julia-version:
description: 'Julia version to use for the build'
required: false
default: '1.13'
target:
description: 'What to build: sysimage, app, or both'
required: false
default: 'app'
type: choice
options:
- sysimage
- app
- both
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: ${{ inputs.target }} - ${{ matrix.label }}
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
arch: x64
ext: so
label: linux-x64
- os: macos-latest
arch: aarch64
ext: dylib
label: macos-aarch64
- os: windows-latest
arch: x64
ext: dll
label: windows-x64
steps:
- name: Checkout OMFrontend.jl
uses: actions/checkout@v4
with:
path: OMFrontend.jl
# Same sibling layout as ci.yml: Project.toml [sources] points at
# ../<name>.jl working copies, so we Pkg.develop them from disk.
# The shared action checks the siblings out at the branch that matches
# this change (the PR branch if the sibling has it, else the PR base
# branch, e.g. 1.13, else master) from the OpenModelica repositories.
- name: Checkout sibling OM*.jl packages
uses: JKRT/OM.jl/.github/actions/checkout-siblings@master
with:
packages: Absyn ArrayUtil DAE DoubleEnded ImmutableList ListUtil MetaModelica OMParser OMRuntimeExternalC SCode
- name: Setup Julia ${{ inputs.julia-version }}-${{ matrix.arch }}
uses: julia-actions/setup-julia@v2
with:
version: ${{ inputs.julia-version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v2
with:
cache-registries: 'true'
- name: Resolve project (develop siblings)
shell: bash
working-directory: OMFrontend.jl
run: |
julia --color=yes --project -e '
import Pkg
Pkg.Registry.add("General")
Pkg.Registry.add(Pkg.RegistrySpec(url = "https://github.com/OpenModelica/OpenModelicaRegistry.git"))
siblings = [
"../Absyn.jl",
"../ArrayUtil.jl",
"../DAE.jl",
"../DoubleEnded.jl",
"../ImmutableList.jl",
"../ListUtil.jl",
"../MetaModelica.jl",
"../OMParser.jl",
"../OMRuntimeExternalC.jl",
"../SCode.jl",
]
Pkg.develop([Pkg.PackageSpec(path = p) for p in siblings])
Pkg.build(; verbose = true)
Pkg.resolve()
Pkg.instantiate()
'
- name: Install PackageCompiler in the default environment
# The stacked default @v#.# environment is on LOAD_PATH alongside the
# active project, so PackageCompiler is importable from inside
# `julia --project=OMFrontend.jl` without polluting OMFrontend's
# Project.toml or Manifest.toml.
shell: bash
run: |
julia --color=yes -e 'import Pkg; Pkg.add("PackageCompiler")'
- name: Build sysimage
if: ${{ inputs.target == 'sysimage' || inputs.target == 'both' }}
shell: bash
working-directory: OMFrontend.jl
env:
OMFRONTEND_SYSIMAGE_EXT: ${{ matrix.ext }}
run: |
julia --color=yes --project bin/build_sysimage.jl
- name: Smoke-test sysimage
if: ${{ inputs.target == 'sysimage' || inputs.target == 'both' }}
shell: bash
working-directory: OMFrontend.jl
run: |
julia --color=yes --project --sysimage=OMFrontend-sysimage.${{ matrix.ext }} -e '
using OMFrontend
pkgRoot = dirname(dirname(realpath(Base.find_package("OMFrontend"))))
mo = joinpath(pkgRoot, "test", "Models", "HelloWorld.mo")
p = OMFrontend.parseFile(mo, 1)
s = OMFrontend.translateToSCode(p)
OMFrontend.instantiateSCodeToDAE("HelloWorld", s)
println("Sysimage smoke test OK")
'
- name: Upload sysimage artifact
if: ${{ inputs.target == 'sysimage' || inputs.target == 'both' }}
uses: actions/upload-artifact@v4
with:
name: OMFrontend-sysimage-${{ matrix.label }}
path: OMFrontend.jl/OMFrontend-sysimage.${{ matrix.ext }}
if-no-files-found: error
retention-days: 14
- name: Build app
if: ${{ inputs.target == 'app' || inputs.target == 'both' }}
shell: bash
working-directory: OMFrontend.jl
run: |
julia --color=yes --project bin/build_app.jl
- name: Smoke-test app (--help / --version / parse)
if: ${{ inputs.target == 'app' || inputs.target == 'both' }}
shell: bash
working-directory: OMFrontend.jl
run: |
set -euxo pipefail
if [[ "${{ runner.os }}" == "Windows" ]]; then
BIN=OMFrontend-app/bin/OMFrontend.exe
else
BIN=OMFrontend-app/bin/OMFrontend
fi
"$BIN" --version
"$BIN" help
"$BIN" help flatten
"$BIN" parse test/Models/HelloWorld.mo
echo "App smoke test OK"
- name: Package app for upload
if: ${{ inputs.target == 'app' || inputs.target == 'both' }}
shell: bash
working-directory: OMFrontend.jl
run: |
# Compress the app directory so symlinks and exec bits survive.
# actions/upload-artifact@v4 uses zip internally, which loses both
# on POSIX runners; we tar.gz on Linux/macOS and zip on Windows.
if [[ "${{ runner.os }}" == "Windows" ]]; then
powershell -NoProfile -Command \
"Compress-Archive -Path OMFrontend-app -DestinationPath OMFrontend-app-${{ matrix.label }}.zip -Force"
else
tar -czf OMFrontend-app-${{ matrix.label }}.tar.gz OMFrontend-app
fi
- name: Upload app artifact
if: ${{ inputs.target == 'app' || inputs.target == 'both' }}
uses: actions/upload-artifact@v4
with:
name: OMFrontend-app-${{ matrix.label }}
path: |
OMFrontend.jl/OMFrontend-app-${{ matrix.label }}.tar.gz
OMFrontend.jl/OMFrontend-app-${{ matrix.label }}.zip
if-no-files-found: error
retention-days: 14