Homogenizes ci scripts

This commit is contained in:
lepapareil 2022-09-27 09:04:21 +02:00
parent 195af0e3fc
commit c6b38caeb3
No known key found for this signature in database
GPG Key ID: F4F06B068FB00692
11 changed files with 69 additions and 43 deletions

View File

@ -47,8 +47,6 @@ jobs:
run: bin/test/test_prerequisites.sh
- name: Run Tests units
run: bin/test/test_unit.sh
- name: Build
run: bin/release/release.sh
- name: Run Integration Tests
run: bin/test/test_integ.sh
- name: Archive production artifacts
@ -90,8 +88,6 @@ jobs:
run: bin/test/test_prerequisites.sh
- name: Run Tests units
run: bin/test/test_unit.sh
- name: Build
run: bin/release/release.sh
- name: Run Integration Tests
run: bin/test/test_integ.sh
- name: Archive production artifacts
@ -120,7 +116,6 @@ jobs:
bin/install_prerequisites_archlinux.sh
bin/install_rust_latest.sh
bin/test/test.sh
bin/release/release.sh
- name: Archive production artifacts
uses: actions/upload-artifact@v3
if: ${{ always() }}
@ -146,7 +141,6 @@ jobs:
bin/install_prerequisites_fedora.sh
bin/install_rust_latest.sh
bin/test/test.sh
bin/release/release.sh
- name: Archive production artifacts
uses: actions/upload-artifact@v3
if: ${{ always() }}
@ -172,7 +166,6 @@ jobs:
bin/install_prerequisites_alpine.sh
bin/install_rust_latest.sh
bin/test/test.sh
bin/release/release.sh
- name: Archive production artifacts
uses: actions/upload-artifact@v3
if: ${{ always() }}
@ -199,8 +192,6 @@ jobs:
run: bin/test/test_prerequisites.sh
- name: Run Tests units
run: bin/test/test_unit.sh
- name: Build
run: bin/release/release.sh
- name: Run Integration Tests
run: bin/test/test_integ.sh
- name: Archive production artifacts
@ -238,20 +229,17 @@ jobs:
override: true
profile: minimal
- name: Environment
run: |
.\bin\environment.ps1
run: .\bin\environment.ps1
- name: Install Prerequisites
run: .\bin\install_prerequisites_windows.ps1
- name: Build and test
run: |
.\bin\install_prerequisites_windows.ps1
.\bin\test\test_prerequisites.ps1
.\bin\test\test_unit.ps1
.\bin\release\release.ps1
.\bin\test\test_integ.ps1
run: .\bin\test\test.ps1
- name: Archive production artifacts
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: tests-win64-${{ matrix.rust }}-artifacts
path: |
integration/mitmdump.log
integration/server.log
integration/server-ssl.log

View File

@ -1,4 +1,4 @@
echo "----- context -----"
powershell write-host -foregroundcolor Cyan "----- context -----"
# get windows infos
Get-ComputerInfo -Property WindowsProductName,WindowsVersion,OsHardwareAbstractionLayer

View File

@ -1,4 +1,4 @@
echo "----- install system prerequisites -----"
powershell write-host -foregroundcolor Cyan "----- install system prerequisites -----"
# install libxml and libcurl
$vcpkg_dir=(Get-command vcpkg).Source

View File

@ -1,4 +1,4 @@
echo "----- create windows64 installer -----"
powershell write-host -foregroundcolor Cyan "----- create windows64 installer -----"
$actual_dir=(Get-Location).Path

View File

@ -1,4 +1,4 @@
echo "----- create windows64 zip package -----"
powershell write-host -foregroundcolor Cyan "----- create windows64 zip package -----"
$actual_dir=(Get-Location).Path

View File

@ -1,22 +1,28 @@
echo "----- build release -----"
powershell write-host -foregroundcolor Cyan "----- build release -----"
$actual_dir=(Get-Location).Path
$project_root_path=(Resolve-Path -LiteralPath $PSScriptRoot\..\..).path
# build
cargo build --release --verbose --locked
# create final package
New-Item -ItemType Directory -Name .\target\win-package
Get-ChildItem -Path '.\target\release' -Recurse -Include *.dll -File | Copy-Item -Destination '.\target\win-package'
Get-ChildItem -Path '.\target\release' -Recurse -Include hurl*.exe -File | Copy-Item -Destination '.\target\win-package'
((.\target\win-package\hurl.exe --version) -Split " ")[1] > .\target\win-package\version.txt
Get-Content .\target\win-package\version.txt
$release_dir="$project_root_path\target\release"
$package_dir="$project_root_path\target\win-package"
New-Item -ItemType Directory -Force -Path $package_dir
Get-ChildItem -Path "$release_dir" -Recurse -Include *.dll -File | Copy-Item -Destination "$package_dir"
Get-ChildItem -Path "$release_dir" -Recurse -Include hurl*.exe -File | Copy-Item -Destination "$package_dir"
((& $package_dir\hurl --version) -Split " ")[1] > $package_dir\version.txt
Get-Content $package_dir\version.txt
# add hurl to PATH
$hurl_dir=(Get-Location).path
$oldpath=(Get-ItemProperty -Path HKCU:\Environment -Name Path).Path
$newpath="$hurl_dir\target\win-package;$oldpath"
$newpath="$package_dir;$oldpath"
Set-ItemProperty -Path HKCU:\Environment -Name Path -Value $newpath
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","User") + ";" + [System.Environment]::GetEnvironmentVariable("Path","Machine")
(Get-Command hurl).Path
# test hurl execution
hurl --version
cd $actual_dir

5
bin/test/test.ps1 Normal file
View File

@ -0,0 +1,5 @@
powershell write-host -foregroundcolor Cyan "----- tests -----"
& $PSScriptRoot\test_prerequisites.ps1
& $PSScriptRoot\test_unit.ps1
& $PSScriptRoot\test_integ.ps1

View File

@ -1,5 +1,6 @@
#!/bin/sh
set -e
"$(dirname "$0")"/test_prerequisites.sh
"$(dirname "$0")"/test_unit.sh
"$(dirname "$0")"/test_integ.sh

View File

@ -1,9 +1,16 @@
echo "----- integration tests -----"
powershell write-host -foregroundcolor Cyan "----- integration tests -----"
$actual_dir=(Get-Location).Path
$project_root_path=(Resolve-Path -LiteralPath $PSScriptRoot\..\..).path
# hurl infos
(Get-Command hurl).Path
(Get-Command hurlfmt).Path
hurl --version
hurlfmt --version
# run integration tests
cd $PSScriptRoot\..\..\integration
python ./integration.py
cd $project_root_path\integration
python integration.py
cd $actual_dir

View File

@ -1,17 +1,22 @@
echo "----- install tests prerequisites -----"
powershell write-host -foregroundcolor Cyan "----- install tests prerequisites -----"
$actual_dir=(Get-Location).Path
$project_root_path=(Resolve-Path -LiteralPath $PSScriptRoot\..\..).path
# install python libs
pip3 install --requirement bin\requirements-frozen.txt
pip3 install --requirement $project_root_path\bin\requirements-frozen.txt
# start mock servers
cd $PSScriptRoot\..\..\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 $project_root_path\integration
Start-Process powershell -WindowStyle Hidden { mitmdump --listen-port 8888 --modify-header "/From-Proxy/Hello" 2>&1 > mitmdump.log }
sleep 5
if (netstat -ano | Select-String LISTENING | Select-string 0.0.0.0:8888) {powershell write-host -foregroundcolor Green "mitmdump is up"} else {powershell write-host -foregroundcolor Red "mitmdump is down" ; exit 1}
Start-Process powershell -WindowStyle Hidden { python server.py 2>&1 > server.log }
sleep 5
if (netstat -ano | Select-String LISTENING | Select-string 127.0.0.1:8000) {powershell write-host -foregroundcolor Green "server is up"} else {powershell write-host -foregroundcolor Red "server is down" ; exit 1}
Start-Process powershell -WindowStyle Hidden { python ssl/server.py 2>&1 > server-ssl.log }
sleep 5
if (netstat -ano | Select-String LISTENING | Select-string 127.0.0.1:8001) {powershell write-host -foregroundcolor Green "server-ssl up"} else {powershell write-host -foregroundcolor Red "server-ssl is down" ; exit 1}
cd $actual_dir

View File

@ -1,4 +1,18 @@
echo "----- unit tests -----"
powershell write-host -foregroundcolor Cyan "----- unit tests -----"
# run test units
cargo test --release --features strict --tests
# create test package
$project_root_path=(Resolve-Path -LiteralPath $PSScriptRoot\..\..).path
$release_dir="$project_root_path\target\release"
$package_dir="$project_root_path\target\test-package"
New-Item -ItemType Directory -Force -Path "$package_dir"
Get-ChildItem -Path $release_dir -Recurse -Include *.dll -File | Copy-Item -Destination $package_dir
Get-ChildItem -Path $release_dir -Recurse -Include hurl*.exe -File | Copy-Item -Destination $package_dir
# add hurl to PATH
$oldpath=(Get-ItemProperty -Path HKCU:\Environment -Name Path).Path
$newpath="$package_dir;$oldpath"
Set-ItemProperty -Path HKCU:\Environment -Name Path -Value $newpath
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","User") + ";" + [System.Environment]::GetEnvironmentVariable("Path","Machine")