-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
562 lines (504 loc) · 24.8 KB
/
action.yml
File metadata and controls
562 lines (504 loc) · 24.8 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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
name: "Build Optimized Rust Binary"
description:
"Builds a min sized Rust binary or library. With self-built std, abort on panic, PGO and cross-compilation support."
branding:
icon: "check"
color: "red"
inputs:
# ============================================================================
# Commonly Used
# ============================================================================
rust-project-path:
description: "Path to the Rust project"
required: false
default: "."
workspace-path:
description: "Path to the workspace root. Defaults to rust-project-path if not specified."
required: false
default: ""
build-library:
description: 'Build a library instead of a binary. Requires `crate-type = ["cdylib", "staticlib"]` in Cargo.toml.'
required: false
default: "false"
crate-name:
description:
"Name of the Rust crate/package. Used for cache key and artifact directory. Legacy: also used for artifact naming
if artifact-prefix not set (deprecated)."
required: false
default: ""
target:
description: "The target platform for the Rust compiler"
required: true
features:
description: "Comma-separated list of features to include in the build"
required: false
default: ""
run-tests-and-coverage:
description: "Run tests and coverage using the `devops-rust-test-and-coverage` action."
required: false
default: "false"
use-cache:
description: "Enable or disable the build cache using Swatinem/rust-cache."
required: false
default: "true"
# ============================================================================
# Build Configuration
# ============================================================================
no-default-features:
description: "Do not include default features in the build"
required: false
default: "false"
rust-toolchain:
description:
"The Rust toolchain to use for building. Can be nightly or a specific nightly version (nightly-2025-09-18). Note:
stable and beta are not supported due to required nightly features."
required: false
default: "nightly"
use-cross:
description: "Use cross-rs for building. If false, use cargo."
required: false
default: "false"
# ============================================================================
# Optimization Options
# ============================================================================
use-pgo:
description: "Use Profile-Guided Optimization [PGO] to build the artifact."
required: false
default: "false"
pgo-project-path:
description: "Path to the Rust project used for gathering PGO data. Can be same or separate project."
required: false
default: "."
pgo-benchmark-name:
description: "Benchmark name to use with PGO."
required: false
default: "my_benchmark"
abort-on-panic:
description: "Abort immediately on panic. If false, the default panic handler is used."
required: false
default: "true"
size-optimized-std:
description: "Enable size optimization for std by adding `optimize_for_size` to build-std-features."
required: false
default: "false"
# ============================================================================
# Artifact & Output Settings
# ============================================================================
upload-artifacts:
description: "Upload the built artifacts as a GitHub Actions artifact"
required: false
default: "true"
upload-symbols-separately:
description:
"Upload debug symbol files (.pdb, .dwp, .dSYM) as separate artifacts instead of bundling with main artifacts"
required: false
default: "true"
use-friendly-target-names:
description:
"Transform target triples to user-friendly names (e.g., x86_64-unknown-linux-gnu -> linux-x64) in artifact names"
required: false
default: "true"
artifact-prefix:
description:
"Prefix for artifact names. Combined with target/features to form final artifact name (e.g., 'MyApp' ->
'MyApp-linux-x64'). If empty, no prefix is used."
required: false
default: ""
artifact-name-exclude-features:
description: "Comma-separated list of features to exclude from artifact names. Set to empty string to include all."
required: false
default: "c-exports,bench,nightly"
# ============================================================================
# Advanced / Low-Level
# ============================================================================
additional-rustflags:
description: "Additional RUSTFLAGS to pass to the Rust compiler"
required: false
default: ""
additional-rustc-args:
description: "Additional arguments to pass directly to rustc"
required: false
default: ""
additional-std-features:
description: "Additional build-std features to include (comma-separated)."
required: false
default: ""
# ============================================================================
# Parameters Passed Through to devops-rust-test-and-coverage
# (Only used when run-tests-and-coverage is enabled)
# ============================================================================
upload-coverage-to-codecov:
description: "Uploads coverage to codecov if `run-tests-and-coverage` is enabled."
required: false
default: "true"
codecov-token:
description: "Codecov token for uploading coverage"
required: false
use-tarpaulin:
description: "Use tarpaulin for code coverage. If false, code coverage will be disabled."
required: false
default: "true"
use-binstall:
description:
"Whether to use cargo-binstall in the test-and-coverage action for installing tools like tarpaulin. This parameter
is passed through to the devops-rust-test-and-coverage action."
required: false
default: "true"
install-binstall:
description:
"Whether to install cargo-binstall to make it available for the test-and-coverage action. If false, assumes it is
already available in the environment."
required: false
default: "true"
additional-test-args:
description:
"Additional arguments passed directly to the cargo test command (e.g., '--ignored --test-threads=1 --lib')"
required: false
default: ""
additional-tarpaulin-args:
description: "Additional arguments to pass to the cargo tarpaulin command"
required: false
default: ""
packages:
description: "Packages to test (multi-line list). Passed through to devops-rust-test-and-coverage. Selects packages for testing; does not influence the build."
required: false
default: ""
codecov-flags:
description: "Flags to pass to Codecov for organizing coverage reports"
required: false
default: "unittests"
codecov-name:
description: "Custom defined name for the coverage upload"
required: false
default: "codecov-umbrella"
runs:
using: "composite"
steps:
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
matcher: false
cache: false
toolchain: ${{ inputs.rust-toolchain }}
components: "clippy,rustfmt"
- name: Determine workspace path
shell: bash
run: |
WORKSPACE_PATH="${{ inputs.workspace-path }}"
if [ -z "$WORKSPACE_PATH" ]; then
WORKSPACE_PATH="${{ inputs.rust-project-path }}"
fi
echo "WORKSPACE_PATH=${WORKSPACE_PATH}" >> $GITHUB_ENV
- name: Sanitize cache key variables
shell: bash
run: |
# Sanitize features string to be filesystem/cache-key safe
# - tr -dc '[:alnum:],_-': delete all chars except alphanumeric, comma, underscore, hyphen
# - tr ',' '-': replace commas with hyphens
SAFE_FEATURES=$(echo "${{ inputs.features }}" | tr -dc '[:alnum:],_-' | tr ',' '-')
if [ -z "$SAFE_FEATURES" ]; then
SAFE_FEATURES="no-features"
fi
# Sanitize additional-std-features string for GitHub Actions cache key
SAFE_ADDITIONAL_STD_FEATURES=$(echo "${{ inputs.additional-std-features }}" | tr -dc '[:alnum:],_-' | tr ',' '-')
if [ -z "$SAFE_ADDITIONAL_STD_FEATURES" ]; then
SAFE_ADDITIONAL_STD_FEATURES="no-std-features"
fi
# Sanitize additional-rustc-args string for GitHub Actions cache key
SAFE_ADDITIONAL_RUSTC_ARGS=$(echo "${{ inputs.additional-rustc-args }}" | tr -dc '[:alnum:],_-' | tr ',' '-')
if [ -z "$SAFE_ADDITIONAL_RUSTC_ARGS" ]; then
SAFE_ADDITIONAL_RUSTC_ARGS="no-rustc-args"
fi
echo "SAFE_FEATURES=${SAFE_FEATURES}" >> $GITHUB_ENV
echo "SAFE_ADDITIONAL_STD_FEATURES=${SAFE_ADDITIONAL_STD_FEATURES}" >> $GITHUB_ENV
echo "SAFE_ADDITIONAL_RUSTC_ARGS=${SAFE_ADDITIONAL_RUSTC_ARGS}" >> $GITHUB_ENV
- name: Setup artifact directory
shell: bash
run: |
# Sanitize workspace path - convert '.' to empty string
WORKSPACE_PATH=$(echo "${{ env.WORKSPACE_PATH }}" | sed 's/^\.$//')
# Construct base path, adding slash only if WORKSPACE_PATH is not empty
if [ -n "$WORKSPACE_PATH" ]; then
BASE_PATH="${GITHUB_WORKSPACE}/${WORKSPACE_PATH}/"
else
BASE_PATH="${GITHUB_WORKSPACE}/"
fi
# Note: This directory has been crafted to be unique, and within 'target' for caching.
# Unique such that different project builds within the same workspace generate valid artifacts
CRATE_NAME_FOR_DIR="${{ inputs.crate-name }}"
if [ -z "$CRATE_NAME_FOR_DIR" ]; then
# Fall back to artifact-prefix to ensure unique directories when action is called multiple times
CRATE_NAME_FOR_DIR="${{ inputs.artifact-prefix }}"
fi
if [ -z "$CRATE_NAME_FOR_DIR" ]; then
CRATE_NAME_FOR_DIR="default"
fi
ARTIFACT_OUT_DIR="${BASE_PATH}artifact-out/${CRATE_NAME_FOR_DIR}/${{ inputs.target }}/${{ env.SAFE_FEATURES }}"
mkdir -p "$ARTIFACT_OUT_DIR"
echo "ARTIFACT_OUT_DIR=${ARTIFACT_OUT_DIR}" >> $GITHUB_ENV
- name: Generate artifact names
shell: bash
run: |
ARTIFACT_SCRIPT="$GITHUB_ACTION_PATH/scripts/get-artifact-name.sh"
# Emit deprecation warning when crate-name is used for artifact naming (without artifact-prefix)
if [ -n "${{ inputs.crate-name }}" ] && [ -z "${{ inputs.artifact-prefix }}" ]; then
echo "::warning::Using 'crate-name' for artifact naming is deprecated. Please use 'artifact-prefix' instead. See https://github.com/Reloaded-Project/devops-rust-lightweight-binary for migration guide."
fi
# Build features argument conditionally to avoid passing empty --features ""
FEATURES_ARG=""
if [ -n "${{ inputs.features }}" ]; then
FEATURES_ARG="--features ${{ inputs.features }}"
fi
# Build crate-name argument conditionally
CRATE_NAME_ARG=""
if [ -n "${{ inputs.crate-name }}" ]; then
CRATE_NAME_ARG="--crate-name ${{ inputs.crate-name }}"
fi
BINARY_ARTIFACT_NAME=$("$ARTIFACT_SCRIPT" --artifact-prefix "${{ inputs.artifact-prefix }}" $CRATE_NAME_ARG --target "${{ inputs.target }}" $FEATURES_ARG --use-friendly-target-names "${{ inputs.use-friendly-target-names }}" --exclude-features "${{ inputs.artifact-name-exclude-features }}" --artifact-type binary)
BINARY_SYMBOLS_ARTIFACT_NAME=$("$ARTIFACT_SCRIPT" --artifact-prefix "${{ inputs.artifact-prefix }}" $CRATE_NAME_ARG --target "${{ inputs.target }}" $FEATURES_ARG --use-friendly-target-names "${{ inputs.use-friendly-target-names }}" --exclude-features "${{ inputs.artifact-name-exclude-features }}" --artifact-type binary-symbols)
LIBRARY_ARTIFACT_NAME=$("$ARTIFACT_SCRIPT" --artifact-prefix "${{ inputs.artifact-prefix }}" $CRATE_NAME_ARG --target "${{ inputs.target }}" $FEATURES_ARG --use-friendly-target-names "${{ inputs.use-friendly-target-names }}" --exclude-features "${{ inputs.artifact-name-exclude-features }}" --artifact-type library)
LIBRARY_SYMBOLS_ARTIFACT_NAME=$("$ARTIFACT_SCRIPT" --artifact-prefix "${{ inputs.artifact-prefix }}" $CRATE_NAME_ARG --target "${{ inputs.target }}" $FEATURES_ARG --use-friendly-target-names "${{ inputs.use-friendly-target-names }}" --exclude-features "${{ inputs.artifact-name-exclude-features }}" --artifact-type library-symbols)
echo "BINARY_ARTIFACT_NAME=${BINARY_ARTIFACT_NAME}" >> $GITHUB_ENV
echo "BINARY_SYMBOLS_ARTIFACT_NAME=${BINARY_SYMBOLS_ARTIFACT_NAME}" >> $GITHUB_ENV
echo "LIBRARY_ARTIFACT_NAME=${LIBRARY_ARTIFACT_NAME}" >> $GITHUB_ENV
echo "LIBRARY_SYMBOLS_ARTIFACT_NAME=${LIBRARY_SYMBOLS_ARTIFACT_NAME}" >> $GITHUB_ENV
- name: Setup Rust Caching
if: inputs.use-cache == 'true'
uses: Swatinem/rust-cache@v2
with:
key: ${{ inputs.build-library == 'true' && env.LIBRARY_ARTIFACT_NAME || env.BINARY_ARTIFACT_NAME }}
cache-on-failure: true
cache-all-crates: true
workspaces: |
${{ env.WORKSPACE_PATH }} -> target
- name: Install gcc-multilib (if on Ubuntu based System, and Target is not Host)
if: inputs.use-cross == 'false' && runner.os == 'Linux'
shell: bash
run: |
# Get host triple
HOST_TARGET=$(rustc -vV | sed -n 's|host: ||p')
echo "Host target: $HOST_TARGET"
echo "Target: ${{ inputs.target }}"
if [ "$HOST_TARGET" != "${{ inputs.target }}" ]; then
echo "Target is different from host. Installing gcc-multilib..."
sudo apt-get update || true
sudo apt-get install -y gcc-multilib || true
else
echo "Target is the same as host. Skipping gcc-multilib installation."
fi
- name: Setup Rust Toolchain
shell: bash
working-directory: ${{ env.WORKSPACE_PATH }}
run: |
rustup target add ${{ inputs.target }} --toolchain ${{ inputs.rust-toolchain }}
rustup component add rust-src --toolchain ${{ inputs.rust-toolchain }}
if [ "${{ inputs.use-cross }}" != "true" ]; then
# Install native toolchain to build with, otherwise it's provided by cross.
rustup toolchain install ${{ inputs.rust-toolchain }}-${{ inputs.target }} --force-non-host
fi
# Install cross-rs if needed
if [ "${{ inputs.use-cross }}" == "true" ]; then
RUSTFLAGS="" cargo install cross --git https://github.com/cross-rs/cross
fi
- name: Build Rust Project
shell: bash
run: |
# Setup build variables
BUILD_CMD="cargo"
if [ "${{ inputs.use-cross }}" == "true" ]; then
BUILD_CMD="cross"
fi
BUILD_FEATURES_ARGS="${{ inputs.features }}"
ADDITIONAL_RUSTC_ARGS="${{ inputs.additional-rustc-args }}"
NO_DEFAULT_FEATURES=""
if [ "${{ inputs.no-default-features }}" == "true" ]; then
NO_DEFAULT_FEATURES="--no-default-features"
fi
CRATE_TYPES=""
if [ "${{ inputs.build-library }}" == "true" ]; then
CRATE_TYPES="--crate-type cdylib --crate-type staticlib"
fi
# Initialize RUSTFLAGS
export RUSTFLAGS="${{ inputs.additional-rustflags }} -Zlocation-detail=none -C lto=fat"
# Initialize build-std and build-std-features
BUILD_STD_ARGS="-Z build-std=std"
BUILD_STD_FEATURES=()
if [ "${{ inputs.size-optimized-std }}" == "true" ]; then
BUILD_STD_FEATURES+=("optimize_for_size")
fi
# Build build-std-features string.
if [ "${{ inputs.additional-std-features }}" != "" ]; then
IFS=',' read -ra ADDITIONAL_FEATURES <<< "${{ inputs.additional-std-features }}"
for feature in "${ADDITIONAL_FEATURES[@]}"; do
BUILD_STD_FEATURES+=("$feature")
done
fi
# Handle PGO
if [ "${{ inputs.use-pgo }}" == "true" ]; then
rustup component add llvm-tools-preview
# Normalize pgo-project-path for PGO, because it doesn't handle double slashes
# (user error) well.
PGO_PROJECT_PATH="${{ inputs.pgo-project-path }}"
PGO_PROJECT_PATH="${PGO_PROJECT_PATH%/}" # Remove trailing forward slash
PGO_PROJECT_PATH="${PGO_PROJECT_PATH%\\}" # Remove trailing backslash
# Generate PGO profiling data
RUSTFLAGS_BACKUP="$RUSTFLAGS"
PGO_PROFILES_FOLDER="${GITHUB_WORKSPACE}/${PGO_PROJECT_PATH}/target/pgo-profiles"
export RUSTFLAGS="$RUSTFLAGS -Cprofile-generate=$PGO_PROFILES_FOLDER"
cd "${GITHUB_WORKSPACE}/${PGO_PROJECT_PATH}"
echo "Flags: $RUSTFLAGS"
echo "$BUILD_CMD +${{ inputs.rust-toolchain }} test --bench ${{ inputs.pgo-benchmark-name }} --release --target ${{ inputs.target }} --features \"$BUILD_FEATURES_ARGS,pgo\" $NO_DEFAULT_FEATURES"
$BUILD_CMD +${{ inputs.rust-toolchain }} test --bench ${{ inputs.pgo-benchmark-name }} --release --target ${{ inputs.target }} --features "$BUILD_FEATURES_ARGS,pgo" $NO_DEFAULT_FEATURES
# Check if .profraw files were created
echo "Profiles Folder: $PGO_PROFILES_FOLDER"
ls "$PGO_PROFILES_FOLDER"
if [ ! -f "$PGO_PROFILES_FOLDER/"*.profraw ]; then
echo "::error::No .profraw files were created during the PGO run. PGO data generation failed."
exit 1
fi
# Merge the PGO profiles
# This is tricky, llvm-profdata isn't in $PATH, so we need to find it ourselves.
target_libdir=$(rustc --print target-libdir)
bin_dir=$(dirname "$target_libdir")/bin
llvm_profdata_path=$(find "$bin_dir" -name "llvm-profdata*" | head -n 1)
MERGED_PGO_PROFILE=$PGO_PROFILES_FOLDER/merged.profdata
$llvm_profdata_path merge -o "$MERGED_PGO_PROFILE" "$PGO_PROFILES_FOLDER"
# Assert merged.profdata is not empty
echo "Merged Profiles Folder: $PGO_PROFILES_FOLDER"
ls "$PGO_PROFILES_FOLDER"
if [ ! -s "$MERGED_PGO_PROFILE" ]; then
# Note: RUSTFLAGS can't handle spaces, so we're kinda screwed if the path up to here
# has spaces in it.
echo "::error::merged.profdata is empty. PGO data generation failed."
exit 1
fi
# Use the generated PGO profiling data to perform an optimized build
export RUSTFLAGS="$RUSTFLAGS_BACKUP -C llvm-args=-pgo-warn-missing-function -C profile-use=$MERGED_PGO_PROFILE"
fi
# Build the final project
cd "${GITHUB_WORKSPACE}/${{ inputs.rust-project-path }}"
# Add panic configuration only for final build
if [ "${{ inputs.abort-on-panic }}" == "true" ]; then
# Get Rust version to determine panic strategy
RUST_VERSION=$(rustc +${{ inputs.rust-toolchain }} --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
echo "Detected Rust version: $RUST_VERSION"
# Function to compare version numbers (returns 0 if $1 >= $2)
version_ge() {
local v1=$1 v2=$2
# Split versions into arrays
IFS='.' read -ra v1_parts <<< "$v1"
IFS='.' read -ra v2_parts <<< "$v2"
# Compare major, minor, patch versions
for i in {0..2}; do
local part1=${v1_parts[i]:-0}
local part2=${v2_parts[i]:-0}
if [ "$part1" -gt "$part2" ]; then
return 0 # v1 > v2
elif [ "$part1" -lt "$part2" ]; then
return 1 # v1 < v2
fi
done
return 0 # v1 == v2
}
if version_ge "$RUST_VERSION" "1.92.0"; then
# Rust version >= 1.92.0, use immediate-abort
echo "Using -Cpanic=immediate-abort for Rust $RUST_VERSION"
export RUSTFLAGS="$RUSTFLAGS -Zunstable-options -Cpanic=immediate-abort"
else
# Rust version < 1.92.0, use panic_immediate_abort feature and -C panic=abort
echo "Using panic_immediate_abort feature and -C panic=abort for Rust $RUST_VERSION"
export RUSTFLAGS="$RUSTFLAGS -C panic=abort"
BUILD_STD_ARGS="$BUILD_STD_ARGS,panic_abort"
BUILD_STD_FEATURES+=("panic_immediate_abort")
fi
fi
if [ ${#BUILD_STD_FEATURES[@]} -gt 0 ]; then
BUILD_STD_ARGS="$BUILD_STD_ARGS -Z build-std-features=$(IFS=, ; echo "${BUILD_STD_FEATURES[*]}")"
fi
## Create Reference File for Date Comparison
mkdir -p "${{ env.ARTIFACT_OUT_DIR }}"
touch "${{ env.ARTIFACT_OUT_DIR }}/build_start"
## Build
echo "Flags: $RUSTFLAGS"
echo "$BUILD_CMD +${{ inputs.rust-toolchain }} rustc --release $BUILD_STD_ARGS --target ${{ inputs.target }} $CRATE_TYPES --features \"$BUILD_FEATURES_ARGS\" $NO_DEFAULT_FEATURES $ADDITIONAL_RUSTC_ARGS"
$BUILD_CMD +${{ inputs.rust-toolchain }} rustc --release $BUILD_STD_ARGS --target ${{ inputs.target }} $CRATE_TYPES --features "$BUILD_FEATURES_ARGS" $NO_DEFAULT_FEATURES $ADDITIONAL_RUSTC_ARGS
echo "Build directory contents:"
ls "${GITHUB_WORKSPACE}/${{ env.WORKSPACE_PATH }}/target/${{ inputs.target }}/release"
## Move all new files (no directories) from release dir to artifact dir
RELEASE_DIR="${GITHUB_WORKSPACE}/${{ env.WORKSPACE_PATH }}/target/${{ inputs.target }}/release"
find "$RELEASE_DIR" -type f -newer "${{ env.ARTIFACT_OUT_DIR }}/build_start" -maxdepth 1 -exec mv {} "${{ env.ARTIFACT_OUT_DIR }}/" \;
## Move directories matching patterns (e.g., .dSYM for macOS debug symbols) from release dir to artifact dir
INCLUDE_DIRS=("*.dSYM")
for pattern in "${INCLUDE_DIRS[@]}"; do
for dir in "$RELEASE_DIR"/$pattern; do
# mv doesn't work here on macOS for some reason.
[ -d "$dir" ] && cp -r "$dir" "$ARTIFACT_OUT_DIR/"
done
done
rm "${{ env.ARTIFACT_OUT_DIR }}/build_start"
echo "Artifacts directory contents:"
ls "${{ env.ARTIFACT_OUT_DIR }}"
- name: Upload binary artifacts
if: inputs.upload-artifacts == 'true' && inputs.build-library != 'true'
uses: actions/upload-artifact@v7
with:
name: ${{ env.BINARY_ARTIFACT_NAME }}
path: |
${{ env.ARTIFACT_OUT_DIR }}
!${{ env.ARTIFACT_OUT_DIR }}/*.d
${{ inputs.upload-symbols-separately == 'true' && format('!{0}/*.pdb', env.ARTIFACT_OUT_DIR) || '' }}
${{ inputs.upload-symbols-separately == 'true' && format('!{0}/*.dwp', env.ARTIFACT_OUT_DIR) || '' }}
${{ inputs.upload-symbols-separately == 'true' && format('!{0}/*.dSYM', env.ARTIFACT_OUT_DIR) || '' }}
- name: Upload binary symbol artifacts
if:
inputs.upload-artifacts == 'true' && inputs.build-library != 'true' && inputs.upload-symbols-separately ==
'true'
uses: actions/upload-artifact@v7
with:
name: ${{ env.BINARY_SYMBOLS_ARTIFACT_NAME }}
path: |
${{ env.ARTIFACT_OUT_DIR }}/*.pdb
${{ env.ARTIFACT_OUT_DIR }}/*.dwp
${{ env.ARTIFACT_OUT_DIR }}/*.dSYM
- name: Upload library artifacts
if: inputs.upload-artifacts == 'true' && inputs.build-library == 'true'
uses: actions/upload-artifact@v7
with:
name: ${{ env.LIBRARY_ARTIFACT_NAME }}
path: |
${{ env.ARTIFACT_OUT_DIR }}
${{ inputs.upload-symbols-separately == 'true' && format('!{0}/*.pdb', env.ARTIFACT_OUT_DIR) || '' }}
${{ inputs.upload-symbols-separately == 'true' && format('!{0}/*.dwp', env.ARTIFACT_OUT_DIR) || '' }}
${{ inputs.upload-symbols-separately == 'true' && format('!{0}/*.dSYM', env.ARTIFACT_OUT_DIR) || '' }}
- name: Upload library symbol artifacts
if:
inputs.upload-artifacts == 'true' && inputs.build-library == 'true' && inputs.upload-symbols-separately ==
'true'
uses: actions/upload-artifact@v7
with:
name: ${{ env.LIBRARY_SYMBOLS_ARTIFACT_NAME }}
path: |
${{ env.ARTIFACT_OUT_DIR }}/*.pdb
${{ env.ARTIFACT_OUT_DIR }}/*.dwp
${{ env.ARTIFACT_OUT_DIR }}/*.dSYM
- name: Run Tests and Coverage
if: inputs.run-tests-and-coverage == 'true'
uses: Reloaded-Project/devops-rust-test-and-coverage@v1
with:
rust-project-path: ${{ env.WORKSPACE_PATH }}
rust-toolchain: ${{ inputs.rust-toolchain }}
target: ${{ inputs.target }}
install-rust-toolchain: false
setup-rust-cache: false
upload-coverage: ${{ inputs.upload-coverage-to-codecov }}
codecov-token: ${{ inputs.codecov-token }}
features: ${{ inputs.features }}
no-default-features: ${{ inputs.no-default-features }}
use-cross: ${{ inputs.use-cross }}
use-tarpaulin: ${{ inputs.use-tarpaulin }}
use-binstall: ${{ inputs.use-binstall }}
install-binstall: ${{ inputs.install-binstall }}
additional-test-args: ${{ inputs.additional-test-args }}
codecov-flags: ${{ inputs.codecov-flags }}
codecov-name: ${{ inputs.codecov-name }}
additional-tarpaulin-args: ${{ inputs.additional-tarpaulin-args }}
packages: ${{ inputs.packages }}