Skip to content

Issue 11: Add script for local testing of update cycle described in r… #49

Issue 11: Add script for local testing of update cycle described in r…

Issue 11: Add script for local testing of update cycle described in r… #49

# This workflow will install Python dependencies, lint with a variety of Python versions
# Based on github's default "Python package" workflow.
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# And https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#using-ruff-to-lint-code
name: Test update cycle
on: [push]
jobs:
build:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
# for supported versions see https://devguide.python.org/versions/
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt --upgrade
pip install -r requirements.txt --upgrade
- name: lint with ruff
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
- 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
- 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"
Add-Content -Path $Env:GITHUB_ENV -Value "MYAPP_INSTALL_DIR=$myapp_install_dir"
New-Item -Path $myapp_install_dir -ItemType "directory"
tar -xf $myapp_v1_archive --directory=$myapp_install_dir
dir $myapp_install_dir
- name: mock develop my_app v2.0
shell: python
run: |
import pathlib
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
- 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 &
sleep 5
Invoke-Expression "$Env:MYAPP_INSTALL_DIR\main.exe 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 &
sleep 5
$output = Invoke-Expression "$Env:MYAPP_INSTALL_DIR\main.exe skip"
$pattern = "my_app 2.0"
if ( $output -match $pattern ) {
Write-Output "success: $pattern found"
} else {
Write-Output "fail: $pattern not found in:`n$output"
exit 1
}