Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI for BSD #167

Draft
wants to merge 32 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/bsd_tox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: VM Python package

on:
- push
- pull_request

jobs:
bsd:
runs-on: ${{ matrix.platform.host }}

strategy:
fail-fast: false
matrix:
platform:
- name: freebsd
version: '13.2'
host: macos-latest

# Issues:
# > pkg_add: no pkg found for 'autoconf', sorry.
# > pkg_add: no pkg found for 'devel/autoconf', sorry.
#
#- name: netbsd
# version: '9.3'
# host: ubuntu-latest

# Issues:
# > bash: line 11: python: command not found
# > configure: error: HIDAPI is not supported on your operating system yet
#- name: openbsd
# version: '7.4'
# host: macos-latest

system-hidapi: ["", "--with-system-hidapi"]

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Run in VM
uses: cross-platform-actions/[email protected]
env:
HIDAPI_SYSTEM_HIDAPI: ${{ matrix.system-hidapi == '--with-system-hidapi' && '1' || '0' }}
with:
environment_variables: HIDAPI_SYSTEM_HIDAPI
operating_system: ${{ matrix.platform.name }}
version: ${{ matrix.platform.version }}
shell: bash
sync_files: runner-to-vm
run: |
set -e

pwd && ls -l1

export PLATFORM_VERSION=${{ matrix.platform.version }}
${{ matrix.platform.name == 'freebsd' && 'sudo pkg install -y autoconf automake libtool gmake libiconv pkgconf lang/python3 lang/python devel/py-pip' || '' }}
${{ matrix.platform.name == 'netbsd' && 'export PATH=$PATH:/usr/sbin/; sudo pkg_add devel/autoconf devel/automake devel/libtool devel/gmake devel/pkgconf devel/libusb1 converters/libiconv devel/py-pip' || '' }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe /usr/pkg/bin is missing in path for python to be found - haven't checked yet

Copy link
Contributor Author

@Youw Youw Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe need a symling for python3.9->python - haven't checked either

${{ matrix.platform.name == 'openbsd' && 'export AUTOCONF_VERSION=2.71; export AUTOMAKE_VERSION=1.15; sudo pkg_add autoconf-2.71 automake-1.15.1 libtool gmake pkgconf libusb1-- libiconv python3 py3-pip' || '' }}
${{ matrix.system-hidapi == '--with-system-hidapi' && './build_install_hidapi_autotools.sh' || '' }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have to use autotools build here due to bug in CMake build: libusb/hidapi#638


python -m pip install --upgrade pip
python -m pip install setuptools tox tox-gh-actions
pip install -r requirements.txt --upgrade

pip install .
python -m tox
9 changes: 3 additions & 6 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Python package
name: Native Python package

on:
- push
Expand Down Expand Up @@ -33,17 +33,14 @@ jobs:

- name: Install Ubuntu dependencies
if: matrix.platform == 'ubuntu-latest'
run: sudo apt install libudev-dev libusb-1.0-0-dev
run: sudo apt install libudev-dev libusb-1.0-0-dev ninja-build

- name: Install Ubuntu HIDAPI
if: ${{ (matrix.platform == 'ubuntu-latest') && (matrix.system-hidapi == '--with-system-hidapi') }}
# the default apt version of libhidapi-dev is too old, need to build the one we know would work
run: |
sudo apt install cmake
mkdir hidapi_build && cd hidapi_build
cmake -B . -S ../hidapi -DCMAKE_INSTALL_PREFIX=/usr
make
sudo make install
./build_install_hidapi.sh

- name: Install macOS HIDAPI
if: ${{ (matrix.platform == 'macos-latest') && (matrix.system-hidapi == '--with-system-hidapi') }}
Expand Down
12 changes: 12 additions & 0 deletions build_install_hidapi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -e
set +x

rm -rf hidapi_build
mkdir -p hidapi_build
pushd hidapi_build
cmake -GNinja -B . -S ../hidapi
ninja
sudo ninja install
popd
11 changes: 11 additions & 0 deletions build_install_hidapi_autotools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -e
set +x

pushd hidapi
./bootstrap
./configure
make
sudo make install
popd