-
Notifications
You must be signed in to change notification settings - Fork 39
126 lines (105 loc) · 3.75 KB
/
build_and_test.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
name: Build and test
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint
run: |
rustup component add rustfmt
cargo fmt -- --check || (echo "Please reformat your code with 'cargo
fmt' (version $(cargo fmt --version))"; false)
tests:
needs: [lint]
name: Tests ${{ matrix.target }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
os:
- ubuntu-latest
steps:
- uses: actions/checkout@v4
# - name: Set environment variables
# run: |
# .github/env.sh ${{ matrix.target }} >> $GITHUB_ENV
# - name: Install qemu-user-static
# if: ${{ matrix.target != 'x86_64-unknown-linux-gnu' }}
# run: |
# sudo apt update
# sudo apt install qemu-user-static
# - uses: ryankurte/[email protected]
# if: ${{ matrix.target != 'x86_64-unknown-linux-gnu' }}
# with:
# arch: ${{ env.MULTILIB_ARCH }}
# packages: "libssl-dev:${{ env.MULTILIB_ARCH }}"
- name: Rustup setup
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
target: ${{ matrix.target }}
- name: Unit tests
run: |
cargo test --locked
build:
needs: [lint]
name: Build ${{ matrix.target }}-${{ matrix.rust }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- riscv64gc-unknown-linux-gnu
rust:
- stable
- 1.70.0
os:
- ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Rustup setup
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
default: true
target: ${{ matrix.target }}
- name: Set environment variables
run: |
.github/env.sh ${{ matrix.target }} >> $GITHUB_ENV
- name: Install libssl (native)
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }}
run: |
sudo apt update
sudo apt install libssl-dev
# - name: Install libssl (cross)
# uses: ryankurte/[email protected]
# if: ${{ matrix.target != 'x86_64-unknown-linux-gnu' }}
# with:
# arch: ${{ env.MULTILIB_ARCH }}
# packages: "${{ env.UBUNTU_CROSS_PKG_LIST }} libssl-dev:${{ env.MULTILIB_ARCH }}"
- name: Install libssl (cross)
if: ${{ matrix.target != 'x86_64-unknown-linux-gnu' }}
run: |
sudo dpkg --add-architecture ${{ env.MULTILIB_ARCH }}
sudo sed -i'' -E 's/^(deb|deb-src) /\1 [arch=amd64,i386] /' /etc/apt/sources.list
echo "deb [arch=${{ env.MULTILIB_ARCH }}] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs) main restricted universe" | sudo tee /etc/apt/sources.list.d/${{ env.MULTILIB_ARCH }}.list
echo "deb [arch=${{ env.MULTILIB_ARCH }}] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-updates main restricted universe" | sudo tee -a /etc/apt/sources.list.d/${{ env.MULTILIB_ARCH }}.list
echo "deb [arch=${{ env.MULTILIB_ARCH }}] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-security main restricted universe" | sudo tee -a /etc/apt/sources.list.d/${{ env.MULTILIB_ARCH }}.list
sudo apt update
sudo apt install ${{ env.UBUNTU_CROSS_PKG_LIST }} libssl-dev:${{ env.MULTILIB_ARCH }}
#- name: Setup tmate session
#uses: mxschmitt/action-tmate@v3
- name: Check
run: cargo check --locked --target ${{ matrix.target }}
- name: Build
run: cargo build --locked --target ${{ matrix.target }}