diff --git a/.github/workflows/test-update-cycle.yml b/.github/workflows/test-update-cycle.yml index dfaeb64..2a1639e 100644 --- a/.github/workflows/test-update-cycle.yml +++ b/.github/workflows/test-update-cycle.yml @@ -10,13 +10,20 @@ on: [push] jobs: build: - runs-on: windows-latest strategy: fail-fast: false matrix: + os: [macos-latest, windows-latest] # for supported versions see https://devguide.python.org/versions/ python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + runs-on: ${{ matrix.os }} + + defaults: + run: + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell + shell: pwsh # use PowerShell Core, also on macOS + steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -32,51 +39,60 @@ jobs: run: ruff --output-format=github . - name: identify powershell version run: $PSVersionTable # or $PSVersionTable.PSEdition - - name: add src to python path - run: Add-Content -Path $Env:GITHUB_ENV -Value "PYTHONPATH=$Env:PYTHONPATH;.\src" - - run: $Env:PYTHONPATH + # https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context + - name: specify app directories for Windows + if: runner.os == 'Windows' + run: | + # make directories accessible as environment variables in subsequent steps + Add-Content -Path $Env:GITHUB_ENV -Value "MYAPP_INSTALL_DIR=$env:LOCALAPPDATA/Programs/my_app" + Add-Content -Path $Env:GITHUB_ENV -Value "MYAPP_TARGETS_DIR=$env:LOCALAPPDATA/my_app/update_cache/targets" + # add src directory to python path + Add-Content -Path $Env:GITHUB_ENV -Value "PYTHONPATH=$Env:PYTHONPATH;./src" + - name: specify app directories for macOS + if: runner.os == 'macOS' + run: | + # make directories accessible as environment variables in subsequent steps + Add-Content -Path $Env:GITHUB_ENV -Value "MYAPP_INSTALL_DIR=$HOME/Applications/my_app" + Add-Content -Path $Env:GITHUB_ENV -Value "MYAPP_TARGETS_DIR=$HOME/Library/my_app/update_cache/targets" + # add src directory to python path + Add-Content -Path $Env:GITHUB_ENV -Value "PYTHONPATH=$Env:PYTHONPATH:./src" - name: initialize tufup repository run: python repo_init.py - name: create my_app v1.0 bundle using pyinstaller - run: cmd.exe /c .\create_pyinstaller_bundle_win.bat + run: pyinstaller "main.spec" --clean -y --distpath "temp_my_app/dist" --workpath "temp_my_app/build" - name: add my_app v1.0 to tufup repository run: python repo_add_bundle.py - name: mock install my_app v1.0 run: | - $myapp_v1_archive = ".\temp_my_app\repository\targets\my_app-1.0.tar.gz" - $myapp_install_dir = "$env:LOCALAPPDATA\Programs\my_app" - $myapp_targets_dir = "$env:LOCALAPPDATA\my_app\update_cache\targets" - # make install dir accessible as environment variable in subsequent steps - Add-Content -Path $Env:GITHUB_ENV -Value "MYAPP_INSTALL_DIR=$myapp_install_dir" + $myapp_v1_archive = "./temp_my_app/repository/targets/my_app-1.0.tar.gz" # create install dir and extract archive into it - New-Item -Path $myapp_install_dir -ItemType "directory" - tar -xf $myapp_v1_archive --directory=$myapp_install_dir - dir $myapp_install_dir + New-Item -Path $Env:MYAPP_INSTALL_DIR -ItemType "directory" + tar -xf $myapp_v1_archive --directory=$Env:MYAPP_INSTALL_DIR + dir $Env:MYAPP_INSTALL_DIR # create targets dir and copy the archive into it (this enables patch updates) - New-Item -Path $myapp_targets_dir -ItemType "directory" -Force - Copy-Item $myapp_v1_archive -Destination $myapp_targets_dir + New-Item -Path $Env:MYAPP_TARGETS_DIR -ItemType "directory" -Force + Copy-Item $myapp_v1_archive -Destination $Env:MYAPP_TARGETS_DIR - name: mock develop my_app v2.0 shell: python run: | import pathlib - settings_path = pathlib.Path('.\src\myapp\settings.py') + settings_path = pathlib.Path('./src/myapp/settings.py') settings_text = settings_path.read_text().replace('1.0', '2.0') settings_path.write_text(settings_text) -# - run: cat .\src\myapp\settings.py - name: create my_app v2.0 bundle using pyinstaller - run: cmd.exe /c .\create_pyinstaller_bundle_win.bat + run: pyinstaller "main.spec" --clean -y --distpath "temp_my_app/dist" --workpath "temp_my_app/build" - name: add my_app v2.0 to tufup repository run: python repo_add_bundle.py - name: run update server and update my_app from v1 to v2 run: | - python -m http.server -d .\temp_my_app\repository & + python -m http.server -d ./temp_my_app/repository & sleep 5 - Invoke-Expression "$Env:MYAPP_INSTALL_DIR\main.exe skip" + Invoke-Expression "$Env:MYAPP_INSTALL_DIR/main skip" - name: proof of the pudding (i.e. verify that install dir contains my_app v2.0) run: | - python -m http.server -d .\temp_my_app\repository & + python -m http.server -d ./temp_my_app/repository & sleep 5 - $output = Invoke-Expression "$Env:MYAPP_INSTALL_DIR\main.exe skip" + $output = Invoke-Expression "$Env:MYAPP_INSTALL_DIR/main skip" $pattern = "my_app 2.0" if ( $output -match $pattern ) { Write-Output "success: $pattern found"