From b024695d6375008d1cd5694054879a61aaaa2bc8 Mon Sep 17 00:00:00 2001 From: Momoko Kono Date: Thu, 18 Jul 2024 12:54:18 -0700 Subject: [PATCH] adding linux workflow --- .../{develop-Windows.yml => develop.yml} | 49 ++++++-- installer/tools/installer-WinUSB.ps1 | 119 ------------------ installer/tools/installer.ps1 | 2 +- 3 files changed, 43 insertions(+), 127 deletions(-) rename .github/workflows/{develop-Windows.yml => develop.yml} (86%) delete mode 100644 installer/tools/installer-WinUSB.ps1 diff --git a/.github/workflows/develop-Windows.yml b/.github/workflows/develop.yml similarity index 86% rename from .github/workflows/develop-Windows.yml rename to .github/workflows/develop.yml index ee013404..2879ca23 100644 --- a/.github/workflows/develop-Windows.yml +++ b/.github/workflows/develop.yml @@ -1,7 +1,7 @@ name: Generate Windows Config and test installation with script # This workflow generate and copy -# 1. config_Windows.json based on the current latest config & release tag +# 1. config_Windows.json & config_Linux.json based on the current latest config & release tag # 2. installer.ps1 # to artifact # @@ -61,24 +61,25 @@ jobs: with: python-version: "3.11.4" - - name: Create config for Windows + - name: Create config for both Windows and Linux run: | cd installer mkdir build && cd build python -m pip install --upgrade pip pip install -r ${{ github.workspace }}/installer/src/requirements.txt - python ${{ github.workspace }}/installer/src/generate_config.py -p Windows + python ${{ github.workspace }}/installer/src/generate_config.py - name: Upload a Build Artifact uses: actions/upload-artifact@v4 with: name: install-test-for-windows path: | - ${{ github.workspace }}/build/config_Windows.json + ${{ github.workspace }}/build/ ${{ github.workspace }}/installer/tools/installer.ps1 + ${{ github.workspace }}/installer/tools/setup.sh ${{ github.workspace }}/installer/testcases - test_installation: + windows_cpp: runs-on: ${{ matrix.os }} needs: [set_env, generate_config] @@ -188,7 +189,7 @@ jobs: - test_python: + windows_python: runs-on: ${{ matrix.os }} needs: [set_env, generate_config] strategy: @@ -239,7 +240,41 @@ jobs: cd ${{ github.workspace }}/download/installer/testcases/python python opencv_test.py - + linux_test_cpp: + runs-on: ${{ matrix.os }} + needs: [set_env, generate_config] + + strategy: + matrix: + os: [ubuntu-22.04] + install_option : ["--version ${{ needs.set_env.outputs.LATEST_RELEASED_SDK }}", "-configPath config_Linux.json"] + with_openCV : ["", "--InstallOpenCV"] + + steps: + - name: Download All Artifacts + uses: actions/download-artifact@v4 + with: + name: install-test-for-windows + path: download + + - name: Set all items under test directory + run: | + mkdir -p ${{ github.workspace }}/test + mv ${{ github.workspace }}/download/build/config_Linux.json ${{ github.workspace }}/test + mv ${{ github.workspace }}/download/installer/tools/setup.sh ${{ github.workspace }}/test + + - name: Install with the script from Artifacts + run: | + cd ${{ github.workspace }}/test + chmod +x setup.sh + sudo bash setup.sh ${{ matrix.install_option }} ${{ matrix.with_openCV }} + + - name: Check if version_info.json exists + id: check_files + uses: andstor/file-existence-action@v3 + with: + files: "/opt/sensing-dev/version_info.json" + fail: true diff --git a/installer/tools/installer-WinUSB.ps1 b/installer/tools/installer-WinUSB.ps1 deleted file mode 100644 index 99699d7c..00000000 --- a/installer/tools/installer-WinUSB.ps1 +++ /dev/null @@ -1,119 +0,0 @@ - -<# -.SYNOPSIS - Install USB device driver using WinUSB and run a driver installer. - -.DESCRIPTION - This PowerShell script downloads and installs a USB device driver using WinUSB and then runs a driver installer. It also deletes temporary files after the installation. - -.NOTES - File Name : installer-WinUSB.ps1 - Prerequisite : PowerShell 5.0 or later - -.EXAMPLE - .\installer-WinUSB.ps1 - - This example downloads and runs the script to install a USB device driver . - -#> -$installPath = "$env:TEMP" -Write-Verbose "installPath = $installPath" -# Download win_usb installer - -$installerName = "WinUSB-installer-generator" - - -$repoUrl = "https://api.github.com/repos/Sensing-Dev/$installerName/releases/latest" -# $repoUrl = "https://api.github.com/repos/Sensing-Dev/WinUSB-installer-generator/releases/latest" -$response = Invoke-RestMethod -Uri $repoUrl -$version = $response.tag_name -$version -Write-Verbose "Latest version: $version" - -if ($version -match 'v(\d+\.\d+\.\d+)(-\w+)?') { - $versionNum = $matches[1] - Write-Output "Installing version: $version" -} - -$Url = "https://github.com/Sensing-Dev/$installerName/releases/download/${version}/${installerName}-${versionNum}.zip" - -$Url - -if ($Url.EndsWith("zip")) { - # Download ZIP to a temp location - - $tempZipPath = "${env:TEMP}\${installerName}.zip" - Invoke-WebRequest -Uri $Url -OutFile $tempZipPath -Verbose - - Add-Type -AssemblyName System.IO.Compression.FileSystem - - $tempExtractionPath = "$installPath\_tempWinUSBExtraction" - # Create the temporary extraction directory if it doesn't exist - if (Test-Path $tempExtractionPath) { - Remove-Item -Path $tempExtractionPath -Force -Recurse -Confirm:$false - } - New-Item -Path $tempExtractionPath -ItemType Directory - - # Attempt to extract to the temporary extraction directory - try { - Expand-Archive -Path $tempZipPath -DestinationPath $tempExtractionPath - Get-ChildItem $tempExtractionPath - } - catch { - Write-Error "Extraction failed...." - } - Remove-Item -Path $tempZipPath -Force -} - -if (Test-Path $tempExtractionPath) { - - # Run Winusb installer - Write-Host "This may take a few minutes. Starting the installation..." - - Write-Verbose "Start winUsb installer" - $TempDir = "$tempExtractionPath/temp" - - New-item -Path "$TempDir" -ItemType Directory - $winUSBOptions = @{ - FilePath = "${tempExtractionPath}/${installerName}-${versionNum}/winusb_installer.exe" - ArgumentList = "054c" - WorkingDirectory = "$TempDir" - Wait = $true - Verb = "RunAs" # This attempts to run the process as an administrator - } - # Start winusb_installer.exe process - Start-Process @winUSBOptions - - Write-Verbose "End winUsb installer" -} - -# Run Driver installer -Write-Verbose "Start Driver installer" - -$infPath = "$TempDir/target_device.inf" -if (-not (Test-Path -Path $infPath -PathType Leaf) ){ - Write-Error "$infPath does not exist." -} -else{ - $pnputilOptions = @{ - FilePath = "PNPUtil" - ArgumentList = "-i -a ./target_device.inf" - WorkingDirectory = "$TempDir" - Wait = $true - Verb = "RunAs" # This attempts to run the process as an administrator - } - try { - # Start Pnputil process - Start-Process @pnputilOptions - Write-Host "Sucessfully installed winUSB driver" - } - catch { - Write-Error "An error occurred while running pnputil: $_" - } -} - -# delete temp files - -Start-Process powershell -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"Remove-Item -Path '$tempExtractionPath' -Recurse -Force -Confirm:`$false`"" - -Write-Verbose "End Driver installer" diff --git a/installer/tools/installer.ps1 b/installer/tools/installer.ps1 index 16be53fe..8dde2ee4 100644 --- a/installer/tools/installer.ps1 +++ b/installer/tools/installer.ps1 @@ -362,7 +362,7 @@ function Invoke-Script { $version_from_config = $content.sensing_dev.version if ($version){ - Write-Host "Set vertion ($version) and config version ($version_from_config) have a conflict." + Write-Host "Version is also set = $version" if (-not ($version_from_config -eq $version)){ Write-Error "Set vertion ($version) and config version ($version_from_config) have a conflict." exit 1