mirror of
https://github.com/chipsenkbeil/distant.git
synced 2024-11-11 01:10:30 +00:00
211 lines
7.5 KiB
YAML
211 lines
7.5 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
paths-ignore:
|
|
- '**.md'
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
paths-ignore:
|
|
- '**.md'
|
|
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
|
|
- name: Check Cargo availability
|
|
run: cargo --version
|
|
- name: distant-net (all features)
|
|
run: cargo clippy -p distant-net --all-targets --verbose --all-features
|
|
- name: distant-core (all features)
|
|
run: cargo clippy -p distant-core --all-targets --verbose --all-features
|
|
- name: distant-ssh2 (all features)
|
|
run: cargo clippy -p distant-ssh2 --all-targets --verbose --all-features
|
|
- name: distant (all features)
|
|
run: cargo clippy --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
|
|
- 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.64.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
|
|
- 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
|
|
if: matrix.os == 'windows-latest'
|
|
run: echo "NEXTEST_RETRIES=9" >> $GITHUB_ENV
|
|
shell: bash
|
|
- name: Run net tests (default features)
|
|
run: cargo nextest run --profile ci --release -p distant-net
|
|
- name: Build core (default features)
|
|
run: cargo build --release -p distant-core
|
|
- name: Run core tests (all features)
|
|
run: cargo nextest run --profile ci --release --all-features -p distant-core
|
|
- name: Ensure /run/sshd exists on Unix
|
|
run: mkdir -p /run/sshd
|
|
if: matrix.os == 'ubuntu-latest'
|
|
- name: Build ssh2 (default features)
|
|
run: cargo build --release -p distant-ssh2
|
|
- name: Run ssh2 client tests (all features)
|
|
run: cargo nextest run --profile ci --release --all-features -p distant-ssh2 ssh2::client
|
|
- name: Build CLI (no default features)
|
|
run: cargo build --release --no-default-features
|
|
- name: Build CLI (default features)
|
|
run: cargo build --release
|
|
- name: Run CLI tests (all features)
|
|
run: cargo nextest run --profile ci --release --all-features
|
|
ssh-launch-tests:
|
|
name: "Test ssh launch using 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: macos-latest }
|
|
- { rust: stable, os: ubuntu-latest }
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Install Rust ${{ matrix.rust }}
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: ${{ matrix.rust }}
|
|
- uses: taiki-e/install-action@v1
|
|
with:
|
|
tool: cargo-nextest@0.9.45
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: Check Cargo availability
|
|
run: cargo --version
|
|
- name: Install distant cli for use in launch tests
|
|
run: |
|
|
cargo install --path .
|
|
echo "DISTANT_PATH=$HOME/.cargo/bin/distant" >> $GITHUB_ENV
|
|
- name: Run ssh2 launch tests (all features)
|
|
run: cargo nextest run --profile ci --release --all-features -p distant-ssh2 ssh2::launched
|