Skip to content

Commit

Permalink
Migrate to pdm and fix github actions (#4)
Browse files Browse the repository at this point in the history
* Increment version from v0.3.0 -> v0.3.1
* Migrate to using a pdm file
+ Add missing dependencies to github workflows
+ Add flake8 config
+ Add artifact compression to github workflow
+ Add GitHub release creation to github workflows
  • Loading branch information
mini-ninja-64 authored Apr 3, 2023
1 parent 9e79e29 commit 72961b5
Show file tree
Hide file tree
Showing 15 changed files with 981 additions and 224 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
exclude = .git,.venv
90 changes: 77 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,98 @@
name: build
name: Build and Release

on: workflow_dispatch
on:
workflow_dispatch: {}
push:
tags:
- '*'

jobs:

build:
name: build

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-20.04', 'macos-10.15', 'windows-latest']
os: [ 'ubuntu-22.04', 'macos-11', 'windows-latest' ]
# Currently this is a dummy variable to make the migration to
# multi-arch builds easier in the future
arch: [ 'x86_64' ]

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies

- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt --yes install qt6-base-dev libgl1-mesa-glx
- name: Install MacOS dependencies
if: runner.os == 'macOS'
run: |
echo "macOS setup"
- name: Install Windows dependencies
if: runner.os == 'Windows'
# Currently pyQt6-Qt6 does not ship with a correctly formatted
# path for RECORD on windows, to workaround this we can run pdm install twice
# and rely on the cached download.
# For more information: https://github.com/pdm-project/pdm/issues/1223
continue-on-error: true
run: |
pip install pdm
pdm install
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller
pip install -e .
pip install pdm
pdm install
- name: Run Pyinstaller
run: pdm run pyinstaller BeeRef.spec

- name: Compress artifact
shell: bash
env:
ARTIFACT_PATH: dist/BeeRef-${{ github.ref_name }}-${{ runner.os }}-${{ matrix.arch }}.tar.gz
run: |
pyinstaller BeeRef.spec
- name: Upload artifact
APPLICATION_FILE="BeeRef"
if [ "$RUNNER_OS" == "Linux" ]; then
APPLICATION_FILE="$APPLICATION_FILE"
elif [ "$RUNNER_OS" == "macOS" ]; then
APPLICATION_FILE="$APPLICATION_FILE.app"
elif [ "$RUNNER_OS" == "Windows" ]; then
APPLICATION_FILE="$APPLICATION_FILE.exe"
else
echo "Unsupported OS: '$RUNNER_OS'"
exit 1
fi
echo "Packaging '$APPLICATION_FILE' to '$ARTIFACT_PATH'"
tar --create --gzip --directory "dist" --file="$ARTIFACT_PATH" "$APPLICATION_FILE"
echo "ARTIFACT_PATH=$ARTIFACT_PATH" >> $GITHUB_ENV
- name: Upload temporary artifacts for branch builds
if: startsWith(github.ref, 'refs/heads/')
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.os }}
path: dist/*
retention-days: 5
path: ${{ env.ARTIFACT_PATH }}
retention-days: 1

- name: Upload release artifact
if: startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1
with:
allowUpdates: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true

generateReleaseNotes: true
name: "${{ github.ref_name }}"
artifacts: "${{ env.ARTIFACT_PATH }}"
8 changes: 4 additions & 4 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install pdm
pdm install
- name: Analysing the code with flake8
run: |
flake8 .
pdm run flake8 .
21 changes: 11 additions & 10 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.9', '3.10' ]
python-version: [ '3.10' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand All @@ -17,12 +16,14 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update
sudo apt install libgl1-mesa-glx libegl1 libglib2.0-0 libxcb-image0 libxkbcommon-x11-0 libxcb-icccm4 libxcb-keysyms1 xserver-xephyr libfontconfig1 libxkbcommon-dev libdbus-1-3 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0
sudo apt install xvfb
python -m pip install --upgrade pip
pip install .
pip install -r requirements/test.txt
- name: Run Unittests with pytest
sudo apt update
sudo apt --yes install libgl1-mesa-glx libegl1 libglib2.0-0 libxcb-image0 libxkbcommon-x11-0 libxcb-icccm4 libxcb-keysyms1 xserver-xephyr libfontconfig1 libxkbcommon-dev libdbus-1-3 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0
sudo apt --yes install xvfb
- name: Install Python dependencies
run: |
xvfb-run --auto-servernum --server-num=1 --server-args="-screen 1 1920x1200x24 -ac +extension GLX" coverage run --source=beeref -m pytest -v -s
pip install pdm
pdm install
- name: Run tests with pytest
run: >
xvfb-run --auto-servernum --server-num=1 --server-args="-screen 1 1920x1200x24 -ac +extension GLX"
pdm run coverage run --source=beeref -m pytest tests
31 changes: 17 additions & 14 deletions BeeRef.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@

import os
from os.path import join
import sys

from beeref import constants

import platform

block_cipher = None
appname = f'{constants.APPNAME}-{constants.VERSION}'

if sys.platform.startswith('win'):
icon = 'logo.ico'
else:
icon = 'logo.icns' # For OSX; param gets ignored on Linux


a = Analysis(
[join('beeref', '__main__.py')],
Expand All @@ -35,14 +25,26 @@ a = Analysis(

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

from beeref import constants

operating_system = platform.system()
architecture = platform.processor()

if operating_system.startswith('Win'):
icon = 'logo.ico'
else:
icon = 'logo.icns' # For OSX; param gets ignored on Linux

executable_name = f'{constants.APPNAME}'

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name=appname,
name=executable_name,
debug=False,
bootloader_ignore_signals=False,
strip=False,
Expand All @@ -56,10 +58,10 @@ exe = EXE(
entitlements_file=None ,
icon=join('beeref', 'assets', icon))

if sys.platform == 'darwin':
if operating_system == 'Darwin':
app = BUNDLE(
exe,
name=f'{constants.APPNAME}.app',
name=f'{executable_name}.app',
icon=join('beeref', 'assets', icon),
bundle_identifier='org.beeref.app',
version=f'{constants.VERSION}',
Expand All @@ -71,3 +73,4 @@ if sys.platform == 'darwin':
}
]
})

15 changes: 15 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
0.3.1 - 2023-04-03
====================

Changed
-------

* Migrate from using `pipenv`/`setuptools` to `pdm`
* Update some dependencies

Fixed
-----

* Fix GitHub build actions


0.3.0 - 2023-03-13
====================

Expand Down
12 changes: 0 additions & 12 deletions Pipfile

This file was deleted.

124 changes: 0 additions & 124 deletions Pipfile.lock

This file was deleted.

Loading

0 comments on commit 72961b5

Please sign in to comment.