-
Notifications
You must be signed in to change notification settings - Fork 11
207 lines (182 loc) · 6.75 KB
/
Copy pathjulia-test.yml
File metadata and controls
207 lines (182 loc) · 6.75 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
# Copyright 2025 The PECOS Developers
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
name: Julia test
permissions:
contents: read
env:
TRIGGER_ON_PR_PUSH: true # Set to true to enable triggers on PR pushes
RUSTFLAGS: -C debuginfo=0
RUST_BACKTRACE: 1
on:
push:
branches: [ "main", "master", "development", "dev" ]
paths:
- 'julia/**'
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'scripts/ci/**'
pull_request:
branches: [ "main", "master", "development", "dev" ]
paths:
- 'julia/**'
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'scripts/ci/**'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
julia-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-2022, macOS-latest]
julia-version: ["1"] # Latest stable (experimental bindings)
steps:
- name: Harden the runner (egress audit)
if: runner.os == 'Linux'
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Set up Julia ${{ matrix.julia-version }}
uses: julia-actions/setup-julia@fa02766e078afaaf09b14210362cee14137e6a32 # v3
with:
version: ${{ matrix.julia-version }}
- name: Set up Rust
run: rustup show
# NOTE: LLVM is not currently needed for Julia FFI since we use pecos with default-features = false
# Keeping this commented out in case we need to re-enable LLVM features in the future.
#
# - name: Install LLVM 21.1 using pecos (Unix)
# if: runner.os != 'Windows'
# run: |
# echo "Installing LLVM using pecos..."
# cargo run -p pecos-cli --release -- install llvm
#
# echo "Setting LLVM environment variables..."
# export PECOS_LLVM=$(cargo run -p pecos-cli --release -- llvm find 2>/dev/null)
# export LLVM_SYS_211_PREFIX="$PECOS_LLVM"
#
# echo "PECOS_LLVM=$PECOS_LLVM" >> $GITHUB_ENV
# echo "LLVM_SYS_211_PREFIX=$LLVM_SYS_211_PREFIX" >> $GITHUB_ENV
#
# echo "Verifying LLVM installation..."
# cargo run -p pecos-cli --release -- llvm check
#
# - name: Install LLVM 21.1 using pecos (Windows)
# if: runner.os == 'Windows'
# shell: pwsh
# run: |
# Write-Host "Installing LLVM using pecos..."
# cargo run -p pecos-cli --release -- install llvm
#
# Write-Host "Setting LLVM environment variables..."
# $env:PECOS_LLVM = (cargo run -p pecos-cli --release -- llvm find 2>$null)
# $env:LLVM_SYS_211_PREFIX = $env:PECOS_LLVM
#
# "PECOS_LLVM=$env:PECOS_LLVM" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# "LLVM_SYS_211_PREFIX=$env:LLVM_SYS_211_PREFIX" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
#
# Write-Host "Verifying LLVM installation..."
# cargo run -p pecos-cli --release -- llvm check
- name: Cache Rust
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
cache-bin: false
prefix-key: v1-rust-no-bin
save-if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || github.ref_name == 'development' || github.ref_name == 'dev') }}
workspaces: julia/pecos-julia-ffi
- name: Bootstrap MSVC for the Cargo build path (Windows)
if: runner.os == 'Windows'
shell: pwsh
# Single mechanism: writes linker + LIB/INCLUDE into .cargo/config.toml,
# which the `cargo build` below (run from julia/pecos-julia-ffi) picks up
# via the parent-dir config search -- same as a local Windows build.
run: ./scripts/win-msvc-bootstrap.ps1
- name: Build Rust FFI library (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cd julia/pecos-julia-ffi
cargo build --locked --release
- name: Build Rust FFI library (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
# On macOS, prevent Homebrew library paths from being used during linking
if [[ "${{ runner.os }}" == "macOS" ]]; then
# CRITICAL: Prevent Homebrew library paths from being used during linking
# This fixes the "@rpath/libunwind.1.dylib" runtime error on macOS
# Reference: https://github.com/rust-lang/rust/issues/135372
unset LIBRARY_PATH
unset LD_LIBRARY_PATH
unset DYLD_LIBRARY_PATH
unset DYLD_FALLBACK_LIBRARY_PATH
unset PKG_CONFIG_PATH
export LIBRARY_PATH=/usr/lib
echo "RUSTFLAGS: $RUSTFLAGS"
fi
cd julia/pecos-julia-ffi
cargo build --locked --release
- name: Run Julia tests
run: |
cd julia/PECOS.jl
julia --project=. -e 'using Pkg; Pkg.instantiate(); include("test/runtests.jl")'
- name: Run examples
run: |
cd julia/PECOS.jl
# Run demo
julia --project=. examples/demo.jl
# Run basic usage
julia --project=. examples/basic_usage.jl
- name: Check package loadable
run: |
cd julia/PECOS.jl
julia --project=. -e 'using PECOS; println(pecos_version())'
- name: Run Julia formatter check
run: |
cd julia/PECOS.jl
julia -e '
using Pkg
Pkg.add("JuliaFormatter")
using JuliaFormatter
if !format("."; verbose=false, overwrite=false)
println("Formatting issues found. Please run JuliaFormatter.")
exit(1)
end'
- name: Run Julia linting with Aqua.jl
run: |
# Aqua needs the library to be built to load the module
cd julia/PECOS.jl
julia --project=. -e '
using Pkg
Pkg.add("Aqua")
using PECOS, Aqua
Aqua.test_all(PECOS;
ambiguities=false,
unbound_args=true,
undefined_exports=true,
project_extras=true,
stale_deps=false,
deps_compat=true,
piracies=true,
persistent_tasks=false
)'