-
Notifications
You must be signed in to change notification settings - Fork 4
147 lines (128 loc) · 4.17 KB
/
rust.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
name: Rust
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
env:
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
on:
merge_group:
push:
branches:
- main
paths-ignore:
- "README.md"
- "LICENSE"
- ".gitignore"
pull_request:
paths-ignore:
- "README.md"
- "LICENSE"
- ".gitignore"
jobs:
os-check:
runs-on: ubuntu-latest
name: os check on ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
include:
- {
target: x86_64-pc-windows-msvc,
args: "--exclude-features openssh",
}
- { target: x86_64-apple-darwin }
- { target: x86_64-unknown-linux-gnu }
steps:
- uses: actions/checkout@v4
- name: Install toolchain
run: |
rustup toolchain install stable --no-self-update --profile minimal --target ${{ matrix.target }}
- uses: taiki-e/install-action@v2
with:
tool: cargo-hack
- name: Create Cargo.lock for caching
run: cargo update
- uses: Swatinem/rust-cache@v2
- run: |
cargo hack check --feature-powerset --target ${{ matrix.target }} ${{ matrix.args }}
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install toolchain
run: |
rustup toolchain install stable --component rustfmt,clippy --no-self-update --profile minimal
rustup toolchain install nightly --no-self-update --profile minimal
- name: Create Cargo.lock for caching
run: cargo update
- uses: Swatinem/rust-cache@v2
- run: ./check.sh
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install toolchain
run: rustup toolchain install stable --no-self-update --profile minimal
- name: Create Cargo.lock for caching
run: cargo update
- uses: Swatinem/rust-cache@v2
- name: Compile tests
run: cargo test --all-features --workspace --no-run
- name: Test ssh connectivity
run: |
# Wait for startup of openssh-server
timeout 15 ./wait_for_sshd_start_up.sh
chmod 600 .test-key
mkdir /tmp/openssh-rs
ssh -i .test-key -v -p 2222 -l test-user 127.0.0.1 -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/tmp/openssh-rs/known_hosts whoami
- name: Set up ssh-agent
run: |
eval $(ssh-agent)
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV
echo "SSH_AGENT_PID=$SSH_AGENT_PID" >> $GITHUB_ENV
cat .test-key | ssh-add -
- name: Run tests
run: ./run_tests.sh
env:
XDG_RUNTIME_DIR: /tmp
- name: ssh container log
run: docker logs $(docker ps | grep openssh-server | awk '{print $1}')
if: ${{ failure() }}
- run: docker exec $(docker ps | grep openssh-server | awk '{print $1}') ls -R /config/logs/
if: ${{ failure() }}
- run: docker exec $(docker ps | grep openssh-server | awk '{print $1}') cat /config/logs/openssh/current
name: ssh server log
if: ${{ failure() }}
services:
openssh:
image: linuxserver/openssh-server:amd64-latest
ports:
- 2222:2222
env:
USER_NAME: test-user
PUBLIC_KEY: |-
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGzHvK2pKtSlZXP9tPYOOBb/xn0IiC9iLMS355AYUPC7
DOCKER_MODS: linuxserver/mods:openssh-server-ssh-tunnel
# Dummy job to have a stable name for the "all tests pass" requirement
tests-pass:
name: Tests pass
needs:
- os-check
- check
- build
if: always() # always run even if dependencies fail
runs-on: ubuntu-latest
steps:
# fail if ANY dependency has failed or cancelled
- if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')"
run: exit 1
- run: exit 0