-
Notifications
You must be signed in to change notification settings - Fork 21
134 lines (125 loc) · 4.69 KB
/
ci.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
name: CI (Build)
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- run-test: true
- static-linked: true
- triple: x86_64-unknown-linux-musl
on: ubuntu-latest
setup: |
sudo apt update && sudo apt install -y lld
sudo ln -s "/usr/bin/ld.lld" /usr/local/x86_64-linux-musl/bin/ld.lld
/usr/local/x86_64-linux-musl/bin/ld.lld --version
rustflags: "-C link-arg=-fuse-ld=lld -C target-feature=+crt-static"
- triple: aarch64-unknown-linux-musl
on: ubuntu-latest
setup: |
sudo apt update && sudo apt install -y lld
sudo ln -s "/usr/bin/ld.lld" /usr/local/aarch64-linux-musl/bin/ld.lld
/usr/local/aarch64-linux-musl/bin/ld.lld --version
rustflags: "-C link-arg=-fuse-ld=lld -C default-linker-libraries=y -C target-feature=+crt-static"
- triple: x86_64-unknown-linux-gnu
on: ubuntu-latest
setup: |
sudo apt update && sudo apt install -y lld
ld.lld --version
rustflags: "-C link-arg=-fuse-ld=lld"
static-linked: false
- triple: aarch64-unknown-linux-gnu
on: ubuntu-latest
setup: |
sudo apt update && sudo apt install -y lld
sudo ln -s "/usr/bin/ld.lld" /usr/aarch64-linux-gnu/bin/ld.lld
/usr/aarch64-linux-gnu/bin/ld.lld --version
rustflags: "-C link-arg=-fuse-ld=lld"
static-linked: false
- triple: x86_64-pc-windows-msvc
on: windows-latest
rustflags: "-C target-feature=+crt-static"
- triple: aarch64-pc-windows-msvc
on: windows-latest
rustflags: "-C target-feature=+crt-static"
run-test: false
- triple: x86_64-apple-darwin
on: macos-latest
# Arm64 runner on macOS is not available for open source repositories with macos-14!
# https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/
- triple: aarch64-apple-darwin
on: macos-14
triple:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc
- x86_64-apple-darwin
- aarch64-apple-darwin
runs-on: ${{ matrix.on }}
env:
RUSTFLAGS: ${{ matrix.rustflags }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.triple }}
- name: Install cross-compilation tools
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.triple }}
- uses: Swatinem/rust-cache@v2
with:
key: ci-build-${{ matrix.triple }}
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.2xx
- name: Setup
run: ${{ matrix.setup }}
- name: add commit hash to version name
shell: bash
run: |
cp vrc-get/Cargo.toml vrc-get/Cargo.toml.bak
sed -E "/^version = \"[^0]/s/\"$/+$(git rev-parse --short HEAD)\"/" < vrc-get/Cargo.toml.bak > vrc-get/Cargo.toml
- name: Build
run: cargo build --verbose --target ${{ matrix.triple }}
- name: Upload built binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.triple }}
path: |
target/${{ matrix.triple }}/debug/vrc-get*
target/${{ matrix.triple }}/debug/libvrc-get*
- name: Build tests
run: cargo build --tests --target ${{ matrix.triple }}
- name: Run tests
if: ${{ matrix.run-test }}
run: cargo test --verbose --target ${{ matrix.triple }}
- name: Check binary is statically linked
shell: bash
if: ${{ matrix.static-linked }}
run: |
# https://github.com/taiki-e/setup-cross-toolchain-action/issues/18
unset CARGO_BUILD_TARGET
cargo run -p build-check-static-link target/${{ matrix.triple }}/debug/vrc-get*
conclude:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [ build ]
steps:
- name: Conclude Tests
env: { NEEDS: "${{ toJSON(needs) }}" }
run: |
echo "$NEEDS" | jq -c '. | to_entries[] | [.key, .value.result]'
echo "$NEEDS" | jq -e '. | all(.result == "success")' > /dev/null