Build and Verify (Windows) #578
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow builds and tests the Windows installer for YTMusic Deleter. | |
name: Build and Verify (Windows) | |
on: | |
push: | |
branches: # prevent push on tags since that's handled by another workflow | |
- '**' | |
paths-ignore: | |
- '**.md' | |
- '.flake8' | |
- '.gitignore' | |
- '.pre-commit-comfig.yaml' | |
- '**/build-deb.yml' | |
- '**/build-dmg.yml' | |
- '**/pytest.yml' | |
- '**/release.yml' | |
pull_request: | |
workflow_dispatch: | |
workflow_call: | |
schedule: | |
- cron: '0 10 * * *' | |
concurrency: | |
group: build-exe | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build: | |
runs-on: windows-latest | |
outputs: | |
installer-version: ${{ steps.json-properties.outputs.version }} | |
cli-version: ${{ steps.run-cli.outputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: pdm-project/setup-pdm@v4 | |
- name: Download fbs | |
env: | |
FBS_URL_ID: ${{ secrets.FBS_URL_ID }} | |
run: | | |
curl -L https://drive.google.com/uc?id=$FBS_URL_ID --output fbs_pro-1.2.1.tar.gz | |
- name: Install dependencies | |
run: | | |
pdm install -dG gui --no-editable | |
- name: Run CLI from venv | |
id: run-cli | |
run: | | |
. .venv/Scripts/activate | |
ytmusic-deleter | |
echo "version=$(ytmusic-deleter --version)" >> $GITHUB_OUTPUT | |
- name: Run fbs app | |
run: | | |
# Store the version argument | |
version_str="${{ steps.run-cli.outputs.version }}" | |
# Makes app run headless | |
export QT_QPA_PLATFORM=offscreen | |
# Launch the fbs app and kill it after 10 seconds, saving the output. | |
# We don't want the timing out to fail the job. Normally using `timeout --preserve-status` would handle this but | |
# still getting exit code "241" which is an unknown code. Alternatively, running the entire step in a separate | |
# script file allows using just `timeout 10s pdm fbs run` but would rather not do that. | |
output=$(timeout 10s pdm fbs run || true) | |
# Check if the output contains the right CLI version | |
if grep -q "$version_str" <<< "$output"; then | |
echo "GUI is running the right CLI version: $version_str" | |
else | |
echo "$version_str" not found in output, which was the following: | |
echo $output | |
exit 1 | |
fi | |
- name: Freeze prep | |
run: | | |
pdm freeze-prep | |
- uses: nuget/setup-nuget@v2 | |
- name: Install C++ Redist | |
shell: pwsh | |
run: | | |
Install-Module -Name VcRedist -Force | |
New-Item -Path C:\Temp\VcRedist -ItemType Directory | |
$VcList = Get-VcList -Export All | Where-Object { $_.Release -in "2010","2012" -and $_.Architecture -eq "x64" } | |
Save-VcRedist -VcList $VcList -Path C:\Temp\VcRedist | |
Install-VcRedist -VcList $VcList -Silent | |
- name: Freeze exe | |
run: | | |
pdm fbs freeze | |
- name: Run frozen exe | |
run: | | |
# Store the version argument | |
version_str="${{ steps.run-cli.outputs.version }}" | |
# Makes app run headless | |
export QT_QPA_PLATFORM=offscreen | |
# Launch the fbs app and kill it after 10 seconds, saving the output. | |
output=$(timeout 10s ./gui/target/YTMusic_Deleter/YTMusic_Deleter.exe || true) | |
# Check if the output contains the right CLI version | |
if grep -q "$version_str" <<< "$output"; then | |
echo "GUI is running the right CLI version: $version_str" | |
else | |
echo "$version_str" not found in output, which was the following: | |
echo $output | |
exit 1 | |
fi | |
- name: Create installer | |
run: | | |
pdm fbs installer | |
- name: Get base.json file | |
id: json-properties | |
uses: zoexx/[email protected] | |
with: | |
file_path: gui/src/build/settings/base.json | |
- name: Save .exe as artifact | |
id: upload_exe | |
uses: actions/upload-artifact@v4 | |
with: | |
name: installer-exe | |
path: ./gui/target/YTMusic_Deleter-${{ steps.json-properties.outputs.version }}-Windows-Installer.exe | |
verify: | |
runs-on: windows-latest | |
needs: build | |
steps: | |
- name: Download Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: installer-exe | |
- name: Run installer | |
shell: cmd | |
run: | | |
.\YTMusic_Deleter-${{ needs.build.outputs.installer-version }}-Windows-Installer.exe /S | |
- name: Run application | |
uses: nick-fields/retry@v3 | |
with: | |
shell: bash | |
command: | | |
# Makes app run headless | |
export QT_QPA_PLATFORM=offscreen | |
logfile="$APPDATA\YTMusic_Deleter\ytmusic-deleter-gui_$(date +%Y-%m-%d).log" | |
timeout 10s /c/Program\ Files\ \(x86\)/YTMusic_Deleter/YTMusic_Deleter.exe || true | |
version_str="${{ needs.build.outputs.cli-version }}" | |
if grep -q "$version_str" $logfile; then | |
echo "GUI is running the right CLI version: $version_str" | |
else | |
echo "The string "$version_str" was not found in $logfile, contents below:" | |
cat $logfile | |
exit 1 | |
fi | |
max_attempts: 5 | |
timeout_minutes: 10 |