Build and Verify (Linux) #464
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 Linux installer for YTMusic Deleterr. | |
name: Build and Verify (Linux) | |
on: | |
push: | |
branches: # prevent push on tags since that's handled by another workflow | |
- '**' | |
paths-ignore: | |
- '**.md' | |
- '.flake8' | |
- '.gitignore' | |
- '.pre-commit-comfig.yaml' | |
- '**/build-exe.yml' | |
- '**/pytest.yml' | |
- '**/release.yml' | |
pull_request: | |
workflow_dispatch: | |
workflow_call: | |
schedule: | |
- cron: '0 10 * * *' | |
concurrency: | |
group: build-deb | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build: | |
runs-on: ubuntu-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: | | |
sudo apt update && sudo apt install -y libegl1 libegl1-mesa | |
pdm install -dG gui --no-editable | |
- name: Run CLI from venv | |
id: run-cli | |
run: | | |
. .venv/bin/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 | |
- 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 || 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 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ruby | |
- name: Install fpm | |
run: | | |
sudo gem install fpm | |
- name: Create installer | |
run: | | |
pdm fbs installer | |
- name: Get base.json file | |
id: json-properties | |
uses: zoexx/github-action-json-file-properties@1.0.6 | |
with: | |
file_path: gui/src/build/settings/base.json | |
- name: Save .deb as artifact | |
id: upload_deb | |
uses: actions/upload-artifact@v4 | |
with: | |
name: installer-deb | |
path: ./gui/target/YTMusic_Deleter-${{ steps.json-properties.outputs.version }}-Linux-Installer.deb | |
verify: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: installer-deb | |
- name: Run installer | |
run: | | |
sudo dpkg -i ./YTMusic_Deleter-${{ needs.build.outputs.installer-version }}-Linux-Installer.deb | |
- name: Install dependencies | |
run: | | |
sudo apt update && sudo apt install -y libegl1 libegl1-mesa | |
- name: Run application | |
run: | | |
# Makes app run headless | |
export QT_QPA_PLATFORM=offscreen | |
logfile="$HOME/YTMusic_Deleter/ytmusic-deleter-gui*.log" | |
timeout 10s /opt/YTMusic_Deleter/YTMusic_Deleter || 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 |