-
Notifications
You must be signed in to change notification settings - Fork 11
169 lines (156 loc) · 5.75 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
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
name: CI
on:
push:
paths-ignore:
- '**.md'
- 'Makefile.toml'
branches:
- master
pull_request:
paths-ignore:
- '**.md'
- 'Makefile.toml'
branches:
- master
jobs:
clippy:
name: "Lint with clippy (${{ matrix.os }})"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { os: windows-latest }
- { os: ubuntu-latest }
env:
RUSTFLAGS: -Dwarnings
steps:
- name: Ensure windows git checkout keeps \n line ending
run: |
git config --system core.autocrlf false
git config --system core.eol lf
if: matrix.os == 'windows-latest'
- uses: actions/checkout@v3
- name: Install Rust (clippy)
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
- uses: Swatinem/rust-cache@v2
with:
key: "ci-clippy-${{ matrix.os }}"
- name: Check Cargo availability
run: cargo --version
- name: Run clippy (all features)
run: cargo clippy --workspace --all-targets --verbose --all-features
rustfmt:
name: "Verify code formatting (${{ matrix.os }})"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { os: windows-latest }
- { os: ubuntu-latest }
steps:
- name: Ensure windows git checkout keeps \n line ending
run: |
git config --system core.autocrlf false
git config --system core.eol lf
if: matrix.os == 'windows-latest'
- uses: actions/checkout@v3
- name: Install Rust (rustfmt)
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt
- uses: Swatinem/rust-cache@v2
with:
key: "ci-rustfmt-${{ matrix.os }}"
- name: Check Cargo availability
run: cargo --version
- run: cargo fmt --all -- --check
tests:
name: "Test Rust ${{ matrix.rust }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
env:
RUSTFLAGS: --cfg ci
RUST_LOG: trace
strategy:
fail-fast: false
matrix:
include:
- { rust: stable, os: windows-latest, target: x86_64-pc-windows-msvc }
- { rust: stable, os: macos-latest }
- { rust: stable, os: ubuntu-latest }
- { rust: 1.70.0, os: ubuntu-latest }
steps:
- uses: actions/checkout@v3
- name: Install Rust ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
- uses: taiki-e/install-action@v1
with:
tool: cargo-nextest@0.9.45
- uses: Swatinem/rust-cache@v2
with:
key: "ci-tests-${{ matrix.os }}-${{ matrix.rust }}-${{ matrix.target }}"
- name: Check Cargo availability
run: cargo --version
- uses: nick-fields/retry@v2
name: Install OpenSSH on Windows
if: matrix.os == 'windows-latest'
with:
timeout_minutes: 10
max_attempts: 3
shell: pwsh
command: |
# From https://gist.github.com/inevity/a0d7b9f1c5ba5a813917b92736122797
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
{
param([string]$zipfile, [string]$outpath)
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}
$url = 'https://github.com/PowerShell/Win32-OpenSSH/releases/latest/'
$request = [System.Net.WebRequest]::Create($url)
$request.AllowAutoRedirect=$false
$response=$request.GetResponse()
$file = $([String]$response.GetResponseHeader("Location")).Replace('tag','download') + '/OpenSSH-Win64.zip'
$client = new-object system.Net.Webclient;
$client.DownloadFile($file ,"c:\\OpenSSH-Win64.zip")
Unzip "c:\\OpenSSH-Win64.zip" "C:\Program Files\"
mv "c:\\Program Files\OpenSSH-Win64" "C:\Program Files\OpenSSH\"
powershell.exe -ExecutionPolicy Bypass -File "C:\Program Files\OpenSSH\install-sshd.ps1"
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22,49152-65535
net start sshd
Set-Service sshd -StartupType Automatic
Set-Service ssh-agent -StartupType Automatic
cd "C:\Program Files\OpenSSH\"
Powershell.exe -ExecutionPolicy Bypass -Command '. .\FixHostFilePermissions.ps1 -Confirm:$false'
$registryPath = "HKLM:\SOFTWARE\OpenSSH\"
$Name = "DefaultShell"
$value = "C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe"
IF(!(Test-Path $registryPath))
{
New-Item -Path $registryPath -Force
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force
} ELSE {
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force
}
- name: Extend Windows retry count to be more resilient
run: echo "NEXTEST_RETRIES=9" >> $GITHUB_ENV
shell: bash
if: matrix.os == 'windows-latest'
- name: Ensure /run/sshd exists on Unix
run: mkdir -p /run/sshd
if: matrix.os == 'ubuntu-latest'
- name: Run all workspace tests (all features)
run: cargo nextest run --profile ci --release --all-features --workspace
- name: Run all doc tests (all features)
run: cargo test --release --all-features --workspace --doc