hurl/.github/workflows/test.yml
2021-11-25 11:21:10 +01:00

355 lines
11 KiB
YAML

name: test
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
rustfmt:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt
- name: Check formatting
run: |
cargo fmt --all -- --check
clippy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: clippy
- name: Run Clippy
run: |
cargo clippy -- -D warnings
dependency-age:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Run dependency_age
run: |
./ci/dependency_age.sh
benchsuite:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
- name: Environment
run: |
uname -a
cargo --version
- name: Build
run: |
# Install libcurl dev so that hurl can be built dynamically with libcurl
sudo apt update
sudo apt install libcurl4-openssl-dev
ci/release.sh
- name: Test Prequisites
run: |
pip3 install Flask
cd bench
python3 server.py >server.log 2>&1 &
sleep 2
netstat -an | grep 8000
- name: Run Bench Suite
run: |
export PATH="$PWD/target/release:$PATH"
cd bench
./run.sh
- name: Archive artifacts
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: tests-bench-artifacts
path: |
bench/server.log
test-ubuntu-x64:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
profile: minimal
- name: Environment
run: |
uname -a
cargo --version
- name: Build
run: |
cargo build --verbose
- name: Test Prequisites
run: |
sudo apt update
sudo apt install libxml2-utils
pip3 install Flask
cd integration
python3 server.py >server.log 2>&1 &
python3 ssl/server.py >server-ssl.log 2>&1 &
wget https://snapshots.mitmproxy.org/5.2/mitmproxy-5.2-linux.tar.gz -O - | tar -xz && ./mitmdump -p 8888 --modify-header "/From-Proxy/Hello" &
- name: Run Tests units
run: |
cargo test --features strict
- name: Run Integration Tests
run: |
export PATH="$PWD/target/debug:$PATH"
cd integration
pip install lxml bs4
./integration.py
./test_curl_commands.sh tests/*.curl
./test_html_output.py tests/*.html
xmllint --noout tests/*.html
./report.sh
- name: Archive production artifacts
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: tests-ubuntu-${{ matrix.rust }}-artifacts
path: |
integration/server.log
integration/server-ssl.log
integration/report/tests.json
integration/report/tests.xml
test-docker-archlinux-x64:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Build, Test units and Integration tests
uses: addnab/docker-run-action@v3
with:
image: archlinux
options: --volume ${{ github.workspace }}:/work --workdir /work --privileged --env CARGO_TERM_COLOR=always
run: |
set -eu
uname -a
uname -m
echo "----- install build prerequisites -----"
pacman -Syy --noconfirm
pacman -Sy --noconfirm curl icu base-devel libxml2 python3 python-pip
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
rustc --version
cargo --version
echo "----- build -----"
cargo build --verbose
echo "----- install servers prerequisites -----"
python3 -m pip install --upgrade pip --quiet
pip3 install lxml bs4 Flask mitmproxy
export PATH="$PWD/target/debug:$PATH"
echo "----- start servers -----"
cd integration
python3 server.py >server.log 2>&1 &
python3 ssl/server.py >server-ssl.log 2>&1 &
mitmdump -p 8888 --modify-header "/From-Proxy/Hello" >mitmdump.log 2>&1 &
ps auxww | grep -v grep | grep -E "server.py|mitmdump"
echo "----- tests units -----"
cargo test --features strict
echo "----- integration tests -----"
./integration.py
- name: Archive production artifacts
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: tests-archlinux-x64-artifacts
path: |
integration/mitmdump.log
integration/server.log
integration/server-ssl.log
test-docker-fedora-x64:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Build, Test units and Integration tests
uses: addnab/docker-run-action@v3
with:
image: fedora
options: --volume ${{ github.workspace }}:/work --workdir /work --privileged --env CARGO_TERM_COLOR=always
run: |
set -eu
uname -a
uname -m
echo "----- install build prerequisites -----"
yum install -y procps gcc libxml2-devel openssl-devel libcurl-devel
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
rustc --version
cargo --version
echo "----- build -----"
cargo build --verbose
echo "----- install servers prerequisites -----"
yum install -y python3-devel python3-pip
python3 -m pip install --upgrade pip --quiet
pip3 install lxml bs4 Flask mitmproxy
export PATH="$PWD/target/debug:$PATH"
echo "----- start servers -----"
cd integration
python3 server.py >server.log 2>&1 &
python3 ssl/server.py >server-ssl.log 2>&1 &
mitmdump -p 8888 --modify-header "/From-Proxy/Hello" >mitmdump.log 2>&1 &
ps auxww | grep -v grep | grep -E "server.py|mitmdump"
echo "----- tests units -----"
cargo test --features strict
echo "----- integration tests -----"
./integration.py
- name: Archive production artifacts
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: tests-fedora-x64-artifacts
path: |
integration/mitmdump.log
integration/server.log
integration/server-ssl.log
test-osx-x64:
runs-on: macos-latest
strategy:
matrix:
rust: [stable]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
profile: minimal
- name: Environment
run: |
uname -a
cargo --version
- name: Build
run: |
cargo build --verbose
- name: Test Prequisites
run: |
pip3 install Flask
cd integration
python3 server.py >server.log 2>&1 &
python3 ssl/server.py >server-ssl.log 2>&1 &
wget https://snapshots.mitmproxy.org/5.2/mitmproxy-5.2-osx.tar.gz -O - | tar -xz && ./mitmdump -p 8888 --modify-header "/From-Proxy/Hello" &
- name: Run Tests units
run: |
cargo test
- name: Run Integration Tests
run: |
export PATH="$PWD/target/debug:$PATH"
cd integration
./integration.py
- name: Archive production artifacts
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: tests-osx-${{ matrix.rust }}-artifacts
path: |
integration/server.log
integration/server-ssl.log
test-windows-x64:
runs-on: windows-latest
strategy:
matrix:
rust: [stable]
env:
VCPKGRS_DYNAMIC: 1
steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
- name: Environment
run: |
$Properties = 'Caption', 'CSName', 'Version', 'BuildType', 'OSArchitecture'
Get-CimInstance Win32_OperatingSystem | Select-Object $Properties | Format-Table -AutoSize
cargo --version
$PsVersionTable
- name: Install build and tests prequisites
run: |
# vcpkg build prequisites
(Get-Command vcpkg).Path
Expand-Archive -PassThru -Force -LiteralPath .\ci\windows\vcpkg_installed.zip -DestinationPath C:\vcpkg\
Get-ChildItem C:\vcpkg\installed
vcpkg integrate install
# fix known win build bugs
(Get-Content .\packages\hurl\src\runner\hurl_file.rs).replace('```', '') | Set-Content .\packages\hurl\src\runner\hurl_file.rs
# install proxy and server
pip3 install Flask mitmproxy
- name: Run Tests units
run: |
cd .\integration
Start-Job -Name mitmdump -ScriptBlock { mitmdump --listen-port 8888 --modify-header "/From-Proxy/Hello" }
Start-Job -Name server -ScriptBlock { python server.py > server.log }
Start-Job -Name server -ScriptBlock { python ssl/server.py > server-ssl.log }
Get-Job -Name server
Get-Job -Name mitmdump
Start-Sleep 5
cd ..
cargo test --verbose
- name: Run Integration tests
run: |
cargo build --release --verbose
$execdir=[System.Environment]::SystemDirectory
Get-ChildItem -Path ".\target\release" -Recurse -Include *.dll -File | Copy-Item -Destination "${execdir}"
Get-ChildItem -Path ".\target\release" -Recurse -Include hurl*.exe -File | Copy-Item -Destination "${execdir}"
cd .\integration
Start-Job -Name mitmdump -ScriptBlock { mitmdump --listen-port 8888 --modify-header "/From-Proxy/Hello" }
Start-Job -Name server -ScriptBlock { python server.py > server.log }
Start-Job -Name server -ScriptBlock { python ssl/server.py > server-ssl.log }
Get-Job -Name server
Get-Job -Name mitmdump
Start-Sleep 5
hurlfmt --no-format tests\assert_base64.hurl
python integration.py
- name: Archive production artifacts
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: tests-win64-${{ matrix.rust }}-artifacts
path: |
integration/server.log
integration/server-ssl.log