-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
213 lines (191 loc) · 8.09 KB
/
action.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
name: Cross CI
description: |
Run cross-ci for rustic* crates
author: "rustic-rs maintainers"
inputs:
toolchain:
description: |
The rust toolchain to use
required: true
target:
description: |
The target to build for
required: true
use-cross:
description: |
Use cross to build the binary
required: true
os:
description: |
The operating system to build for
required: false
github-token:
description: |
The github token to use
required: false
all-features:
description: |
Build features with all features
required: false
default: "true"
feature:
description: |
The feature to build
required: false
project-cache-key:
default: "rustic"
description: |
The project to use, used for caching
required: false
extra-cargo-build-args:
description: |
Extra arguments to pass to the cargo build command
required: false
default: ""
runs:
using: "composite"
steps:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1
with:
toolchain: ${{ inputs.toolchain }}
targets: ${{ inputs.target }}
- name: install rust dependencies
uses: taiki-e/install-action@a22e1808bbd53573c0b897cc089c64643401af7d # v2
with:
tool: just,toml-cli,bindgen-cli
- name: Check if default dependencies just recipe exists
shell: bash
id: check-recipe
if: inputs.use-cross == 'false'
run: |
if ! just -f ${GITHUB_WORKSPACE:?}/build-dependencies.just -s install-default-${{ inputs.target }}; then
echo "Failed to install default dependencies, recipe doesn't exist"
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Install default dependencies
shell: bash
if: steps.check-recipe.outputs.exists != 'false' && inputs.use-cross == 'false'
run: |
just -f ${GITHUB_WORKSPACE:?}/build-dependencies.just install-default-${{ inputs.target }}
- name: Cache brew deps
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
id: brew-cache
if: inputs.target == 'x86_64-apple-darwin' && inputs.use-cross == 'false'
with:
# Paths to cache:
# /usr/local/Homebrew - installation folder of Homebrew
# /usr/local/Cellar - installation folder of Homebrew formulae
# /usr/local/Frameworks, /usr/local/bin, /usr/local/opt - contain (links to) binaries installed by Homebrew formulae
# /usr/local/lib/python3.9 - Python3 packages installation
path: |
/usr/local/Homebrew
/usr/local/Cellar
/usr/local/Frameworks
/usr/local/bin
key: zld-cache-${{ inputs.target }}
# FIXME: zld compilation is currently not working
# - name: install compiler on macos
# shell: bash
# if: inputs.target == 'x86_64-apple-darwin' && inputs.use-cross == 'false'
# run: |
# brew install michaeleisel/zld/zld
- name: install mold linker on linux gnu
if: inputs.target == 'x86_64-unknown-linux-gnu' && inputs.use-cross == 'false'
uses: rui314/setup-mold@b015f7e3f2938ad3a5ed6e5111a8c6c7c1d6db6e # v1
- uses: swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2
with:
key: ${{ inputs.target }}
# A cache key that is used instead of the automatic `job`-based key,
# and is stable over multiple jobs.
# shared-key: ${{ inputs.project-cache-key }}
- name: Get additional features specified in platform-settings.toml
shell: bash
id: additional-features
run: |
# Exit gracefully if the platform-settings.toml doesn't have additional features
if ! toml get ${GITHUB_WORKSPACE:?}/platform-settings.toml platforms.${{ inputs.target }}.additional-features; then
echo "features=false" >> $GITHUB_OUTPUT
exit 0
else
features=$(toml get ${GITHUB_WORKSPACE:?}/platform-settings.toml platforms.${{ inputs.target }}.additional-features | jq -r 'join(" ")')
echo "features=$features" >> $GITHUB_OUTPUT
fi
- name: Install feature dependencies with just command runner
shell: bash
if: steps.additional-features.outputs.features != 'false'
run: |
target=${{ inputs.target }}
features=${{ steps.additional-features.outputs.features }}
for feature in $features; do
# check if recipe is existing
if ! just -f ${GITHUB_WORKSPACE:?}/build-dependencies.just -s install-$feature-$target; then
echo "Failed to install $feature dependencies, recipe doesn't exist"
echo "Please make sure, that the recipe exists in the build-dependencies.just file"
exit 1
fi
just -f ${GITHUB_WORKSPACE:?}/build-dependencies.just install-$feature-$target
done
- name: Create .cargo folder if it doesn't exist
shell: bash
run: |
mkdir -p ${GITHUB_WORKSPACE:?}/.cargo
- name: Use win config
shell: bash
if: inputs.target == 'x86_64-pc-windows-msvc'
run: |
cp -T ${GITHUB_ACTION_PATH:?}/.config/config-win.toml ${GITHUB_WORKSPACE:?}/.cargo/config.toml
- name: Use linux config
shell: bash
if: inputs.target == 'x86_64-unknown-linux-gnu' && inputs.use-cross == 'false'
run: |
cp -T ${GITHUB_ACTION_PATH:?}/.config/config-linux.toml ${GITHUB_WORKSPACE:?}/.cargo/config.toml
- name: Use darwin config
shell: bash
if: inputs.target == 'x86_64-apple-darwin' && inputs.use-cross == 'false'
run: |
cp ${GITHUB_ACTION_PATH:?}/.config/config-darwin.toml ${GITHUB_WORKSPACE:?}/.cargo/config.toml
- name: Get default features specified in platform-settings.toml
shell: bash
id: default-features
run: |
# Exit gracefully if the platform-settings.toml doesn't have default features
if ! toml get ${GITHUB_WORKSPACE:?}/platform-settings.toml platforms.defaults.release-features; then
echo "features=false" >> $GITHUB_OUTPUT
exit 0
else
features=$(toml get ${GITHUB_WORKSPACE:?}/platform-settings.toml platforms.defaults.release-features | jq -r 'join(" ")')
echo "features=$features" >> $GITHUB_OUTPUT
fi
- name: Collect features for cargo build
shell: bash
id: collect-features
run: |
if [[ ${{ steps.default-features.outputs.features }} != 'false' ]]; then
# join the features with a comma
echo "default_features=-F $(echo ${{ steps.default-features.outputs.features }} | tr ' ' ',')" >> $GITHUB_OUTPUT
else
echo "default_features=" >> $GITHUB_OUTPUT
fi
if [[ ${{ steps.additional-features.outputs.features }} != 'false' ]]; then
# join the features with a comma
echo "additional_features=-F $(echo ${{ steps.additional-features.outputs.features }} | tr ' ' ',')" >> $GITHUB_OUTPUT
else
echo "additional_features=" >> $GITHUB_OUTPUT
fi
- name: Cargo check
uses: clechasseur/rs-cargo@8435b10f6e71c2e3d4d3b7573003a8ce4bfc6386 # v2 (attention: this should be double checked for security issues)
if: inputs.all-features == 'true'
with:
command: check
use-cross: ${{ inputs.use-cross }}
toolchain: ${{ inputs.toolchain }}
args: --all-features --target ${{ inputs.target }} --workspace ${{ steps.collect-features.outputs.default_features }} ${{ steps.collect-features.outputs.additional_features }} ${{ inputs.extra-cargo-build-args }}
- name: Cargo check
uses: clechasseur/rs-cargo@8435b10f6e71c2e3d4d3b7573003a8ce4bfc6386 # v2 (attention: this should be double checked for security issues)
if: inputs.all-features == 'false'
with:
command: check
use-cross: ${{ inputs.use-cross }}
toolchain: ${{ inputs.toolchain }}
args: --features ${{ inputs.feature }} --target ${{ inputs.target }} --workspace ${{ steps.collect-features.outputs.default_features }} ${{ steps.collect-features.outputs.additional_features }} ${{ inputs.extra-cargo-build-args }}