Skip to content

Commit

Permalink
Add Github Actions builds
Browse files Browse the repository at this point in the history
  • Loading branch information
nohal committed Jun 30, 2024
1 parent 03a09e8 commit d9d01ff
Show file tree
Hide file tree
Showing 4 changed files with 299 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
# yamllint disable rule:line-length
name: Linux build

on:
push:
branches:
- master
- ci_update
paths-ignore:
- 'manual/**'
pull_request:
branches:
- master
paths-ignore:
- 'manual/**'

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
runs-on: ${{ matrix.runner }}
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- name: Ubuntu latest wxGTK 3
runner: ubuntu-latest
cmake_generator: Unix Makefiles

env:
wxGTK_VERSION: ${{ matrix.gtk_version && matrix.gtk_version || 3 }}

# Use bash as the shell, even under MSW where the default is PowerShell.
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Before build
run: |
./ci/github-pre-build.sh
env:
USE_HOMEBREW: ${{ matrix.use_homebrew && matrix.use_homebrew || 0 }}

- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{ matrix.cmake_defines }}

- name: Build
run: cmake --build build --config ${{env.BUILD_TYPE}}

- name: Test
if: runner.os != 'Linux'
# TODO: The tests do not work in headless Linux containers (GTK crashes) with wxWidgets 3.0 available in Ubuntu
# They seem to be fine with wx 3.1 though, so we will just remove the condition "later" when wx3.2 time comes
# On Windows, we would need opencpn.exe in the worjing directory to run the tests (and wxWidgets libs in the path)
working-directory: build
run: ctest -C ${{env.BUILD_TYPE}}
...
99 changes: 99 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
# yamllint disable rule:line-length
name: macOS build

on:
push:
branches:
- '*'
paths-ignore:
- 'manual/**'
tags:
- '*'
pull_request:
branches:
- '*'
paths-ignore:
- 'manual/**'

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
runs-on: ${{ matrix.runner }}
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- name: macOS 'latest' Homebrew wxOSX
runner: macos-latest
cmake_generator: Xcode
cmake_defines: -DCMAKE_CXX_STANDARD=17
use_homebrew: 1
push_cloudsmith: 0
- name: macOS 14 Homebrew wxOSX
runner: macos-14
cmake_generator: Ninja
cmake_defines: -DCMAKE_CXX_STANDARD=17
use_homebrew: 1
push_cloudsmith: 0
- name: macOS 13 Homebrew wxOSX
runner: macos-13
cmake_generator: Ninja
cmake_defines: -DCMAKE_CXX_STANDARD=17
use_homebrew: 1
push_cloudsmith: 0
#- name: macOS 11 wxOSX
# runner: macos-11
# cmake_generator: Xcode
# cmake_defines: -DCMAKE_CXX_STANDARD=11 -DwxWidgets_CONFIG_EXECUTABLE=/tmp/wx322-2_opencpn50_macos1010/bin/wx-config -DwxWidgets_CONFIG_OPTIONS="--prefix=/tmp/wx322-2_opencpn50_macos1010"
# push_cloudsmith: 1
#- name: macOS 10.15 wxOSX
# runner: macos-10.15
# cmake_generator: Xcode
# cmake_defines: -DCMAKE_CXX_STANDARD=11 -DwxWidgets_CONFIG_EXECUTABLE=/tmp/wx322-2_opencpn50_macos1010/bin/wx-config -DwxWidgets_CONFIG_OPTIONS="--prefix=/tmp/wx322-2_opencpn50_macos1010"

env:
wxGTK_VERSION: ${{ matrix.gtk_version && matrix.gtk_version || 3 }}
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}

# Use bash as the shell, even under MSW where the default is PowerShell.
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Before build
run: |
./ci/github-pre-build.sh
env:
USE_HOMEBREW: ${{ matrix.use_homebrew && matrix.use_homebrew || 0 }}

- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{ matrix.cmake_defines }}

- name: Build
run: cmake --build build --config ${{env.BUILD_TYPE}}

- name: Upload to Cloudsmith
if: matrix.push_cloudsmith == 1
run: |
./upload.sh
working-directory: build
env:
UPLOAD_CLOUDSMITH: ${{ matrix.push_cloudsmith }}

- name: Test
# TODO: The tests do not work in headless Linux containers (GTK crashes) with wxWidgets 3.0 available in Ubuntu
# They seem to be fine with wx 3.1 though, so we will just remove the condition "later" when wx3.2 time comes
# On Windows, we would need opencpn.exe in the worjing directory to run the tests (and wxWidgets libs in the path)
working-directory: build
run: ctest -C ${{env.BUILD_TYPE}}
...
74 changes: 74 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
# yamllint disable rule:line-length
name: Windows 32bit build

on:
push:
branches:
- master
- ci_update
paths-ignore:
- 'manual/**'
tags:
- '*'
pull_request:
branches:
- master
paths-ignore:
- 'manual/**'

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}


jobs:
build:
runs-on: ${{ matrix.runner }}
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- name: Windows MSVC
runner: windows-latest
no_sudo: 1
# TODO: Tests don't link on Windows, investigate and fix later
cmake_defines: -T v143 -DCMAKE_GENERATOR_PLATFORM=win32 -DWITH_TESTS=OFF -DCMAKE_CXX_STANDARD=17

env:
wxGTK_VERSION: ${{ matrix.gtk_version && matrix.gtk_version || 3 }}

# Use bash as the shell, even under MSW where the default is PowerShell.
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

# required for CMake to find Ninja
- name: "[Windows] Set up MSVC Developer Command Prompt"
if: runner.os == 'Windows'
uses: seanmiddleditch/gha-setup-vsdevenv@v3
with:
host_arch: x86
arch: win32

- name: "[Windows] Dependencies, configure, build"
if: runner.os == 'Windows'
run: |
call buildwin/win_deps.bat
cmake -A win32 -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{ matrix.cmake_defines }}
cmake --build build --config ${{env.BUILD_TYPE}}
shell: cmd
- name: "[Windows] Publish to Cloudsmith"
if: runner.os == 'Windows'
run: |
cd build
.\upload.bat
shell: cmd
...
60 changes: 60 additions & 0 deletions ci/github-pre-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/sh
#
# This script is used by GitHub to install the dependencies
# before building wxWidgets but can also be run by hand if necessary (but
# currently it only works for Ubuntu versions used by the CI builds).

set -e -x

SUDO=sudo

case $(uname -s) in
Linux)
if [ -f /etc/apt/sources.list ]; then
# Show information about the repositories and priorities used.
echo 'APT sources used:'
$SUDO grep --no-messages '^[^#]' /etc/apt/sources.list /etc/apt/sources.list.d/* || true
echo '--- End of APT files dump ---'

run_apt() {
echo "-> Running apt-get $@"

# Disable some (but not all) output.
$SUDO apt-get -q -o=Dpkg::Use-Pty=0 "$@"

rc=$?
echo "-> Done with $rc"

return $rc
}

run_apt update || echo 'Failed to update packages, but continuing nevertheless.'

sudo apt-get -qq install devscripts equivs software-properties-common

sudo mk-build-deps -ir build-deps/control
sudo apt-get -q --allow-unauthenticated install -f
fi
;;

Darwin)
# Install packaged dependencies
here=$(cd "$(dirname "$0")"; pwd)
for pkg in $(sed '/#/d' < $here/../build-deps/macos-deps); do
brew list --versions $pkg || brew install $pkg || brew install $pkg || :
brew link --overwrite $pkg || brew install $pkg
done

pipx install cloudsmith-cli

if [ ${USE_HOMEBREW:-0} -ne 1 ]; then
# Install the pre-built wxWidgets package
wget -q https://dl.cloudsmith.io/public/nohal/opencpn-plugins/raw/files/macos_deps_universal.tar.xz \
-O /tmp/macos_deps_universal.tar.xz
sudo tar -C /usr/local -xJf /tmp/macos_deps_universal.tar.xz
else
brew update
brew install wxwidgets
fi
;;
esac

0 comments on commit d9d01ff

Please sign in to comment.