diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 811ef39e3..de4f999dd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/bin/environment.ps1 b/bin/environment.ps1 index 8374ea23a..e0b9fa60b 100644 --- a/bin/environment.ps1 +++ b/bin/environment.ps1 @@ -1,4 +1,4 @@ -echo "----- context -----" +powershell write-host -foregroundcolor Cyan "----- context -----" # get windows infos Get-ComputerInfo -Property WindowsProductName,WindowsVersion,OsHardwareAbstractionLayer diff --git a/bin/install_prerequisites_windows.ps1 b/bin/install_prerequisites_windows.ps1 index 2abf70686..d191cf30e 100644 --- a/bin/install_prerequisites_windows.ps1 +++ b/bin/install_prerequisites_windows.ps1 @@ -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 diff --git a/bin/release/create_windows64_installer.ps1 b/bin/release/create_windows64_installer.ps1 index 3952ef8e1..a901fa072 100644 --- a/bin/release/create_windows64_installer.ps1 +++ b/bin/release/create_windows64_installer.ps1 @@ -1,4 +1,4 @@ -echo "----- create windows64 installer -----" +powershell write-host -foregroundcolor Cyan "----- create windows64 installer -----" $actual_dir=(Get-Location).Path diff --git a/bin/release/create_windows64_zip_package.ps1 b/bin/release/create_windows64_zip_package.ps1 index df240f657..78d7142e4 100644 --- a/bin/release/create_windows64_zip_package.ps1 +++ b/bin/release/create_windows64_zip_package.ps1 @@ -1,4 +1,4 @@ -echo "----- create windows64 zip package -----" +powershell write-host -foregroundcolor Cyan "----- create windows64 zip package -----" $actual_dir=(Get-Location).Path diff --git a/bin/release/release.ps1 b/bin/release/release.ps1 index 00cd892ac..61c916705 100644 --- a/bin/release/release.ps1 +++ b/bin/release/release.ps1 @@ -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 diff --git a/bin/test/test.ps1 b/bin/test/test.ps1 new file mode 100644 index 000000000..bb86fe530 --- /dev/null +++ b/bin/test/test.ps1 @@ -0,0 +1,5 @@ +powershell write-host -foregroundcolor Cyan "----- tests -----" + +& $PSScriptRoot\test_prerequisites.ps1 +& $PSScriptRoot\test_unit.ps1 +& $PSScriptRoot\test_integ.ps1 diff --git a/bin/test/test.sh b/bin/test/test.sh index 37015033f..c328fb84f 100755 --- a/bin/test/test.sh +++ b/bin/test/test.sh @@ -1,5 +1,6 @@ #!/bin/sh set -e + "$(dirname "$0")"/test_prerequisites.sh "$(dirname "$0")"/test_unit.sh "$(dirname "$0")"/test_integ.sh diff --git a/bin/test/test_integ.ps1 b/bin/test/test_integ.ps1 index c74b5ebbc..b8b752cc2 100644 --- a/bin/test/test_integ.ps1 +++ b/bin/test/test_integ.ps1 @@ -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 diff --git a/bin/test/test_prerequisites.ps1 b/bin/test/test_prerequisites.ps1 index 476ee045a..0c7c1d5a4 100644 --- a/bin/test/test_prerequisites.ps1 +++ b/bin/test/test_prerequisites.ps1 @@ -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 + diff --git a/bin/test/test_unit.ps1 b/bin/test/test_unit.ps1 index fb84db078..7cd267514 100644 --- a/bin/test/test_unit.ps1 +++ b/bin/test/test_unit.ps1 @@ -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")