Skip to content

Commit

Permalink
Add OpenBSD builds
Browse files Browse the repository at this point in the history
  • Loading branch information
hummeltech committed Aug 3, 2024
1 parent f617702 commit cccdc0e
Show file tree
Hide file tree
Showing 15 changed files with 158 additions and 60 deletions.
27 changes: 26 additions & 1 deletion .github/actions/dependencies/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ inputs:
jq
lcov
memcached
openbsd-build-dependencies:
default: >-
apache-httpd
cairo
coreutils
curl
glib2
iniparser
libmemcached
mapnik
pkgconf
openbsd-test-dependencies:
default: >-
jq
memcached--
opensuse-build-dependencies:
default: >-
apache2-devel
Expand Down Expand Up @@ -251,6 +266,16 @@ runs:
${{ matrix.compiler == 'GNU' && 'gcc' || '' }}
if: github.job == 'macOS'

- name: Install Dependencies (OpenBSD)
uses: ./.github/actions/dependencies/install/pkg_add-openbsd
with:
packages: >-
${{ inputs.openbsd-build-dependencies }}
${{ inputs.openbsd-test-dependencies }}
${{ matrix.build_system == 'CMake' && 'cmake' || 'autoconf automake' }}
${{ matrix.compiler == 'GNU' && 'gcc' || '' }}
if: github.job == 'OpenBSD'

- name: Install Dependencies (openSUSE)
uses: ./.github/actions/dependencies/install/zypper
with:
Expand All @@ -274,7 +299,7 @@ runs:
${{ matrix.compiler == 'LLVM' && 'clang' || 'g++ gcc' }}
if: |
startsWith(matrix.image, 'ubuntu:') ||
(!matrix.image && github.job != 'FreeBSD' && runner.os == 'Linux')
(!matrix.image && github.job != 'FreeBSD' && github.job != 'OpenBSD' && runner.os == 'Linux')
- name: Link `gcc`/`g++` (openSUSE)
run: |
Expand Down
15 changes: 15 additions & 0 deletions .github/actions/dependencies/install/pkg_add-openbsd/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
inputs:
packages:
description: List of package(s) to install
required: true
options:
default: -Iv
description: Option(s) to pass

runs:
using: composite
steps:
- name: Install package(s)
run: ${{ !matrix.image && 'sudo' || '' }} pkg_add ${{ inputs.options }} ${{ inputs.packages }}
shell: bash --noprofile --norc -euxo pipefail {0}
102 changes: 80 additions & 22 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,78 @@ jobs:
- name: Install `mod_tile`
uses: ./.github/actions/install

FreeBSD:
env:
CFLAGS: --coverage
CTEST_CLIENT_HOST: ::1
CTEST_SERVER_HOST: localhost
CXXFLAGS: --coverage
INSTALL_PREFIX: /usr/local
LIBRARY_PATH: /usr/local/lib
TMPDIR: /tmp
name: >-
${{ matrix.box_generic }}
(${{ matrix.build_system }})
(${{ matrix.compiler }})
runs-on: ubuntu-latest
strategy:
matrix:
box_generic:
- freebsd13
build_system:
- CMake
compiler:
- LLVM
on_default_branch:
- ${{ contains(github.ref, 'master') || contains(github.ref, 'develop') || contains(github.ref, 'CI') }}
include:
- box_generic: freebsd14
build_system: CMake
compiler: LLVM
exclude:
- on_default_branch: false
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set `BUILD_PARALLEL_LEVEL` & `TEST_PARALLEL_LEVEL`
run: |
echo "BUILD_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV}
echo "TEST_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV}
- name: Provision VM
uses: hummeltech/[email protected]
with:
box: generic/${{ matrix.box_generic }}
cpus: ${{ env.BUILD_PARALLEL_LEVEL }}
memory: 4096

# Mapnik is not in the `quarterly` repository (2023.10.12)
- name: Use "latest" repository
run: |
sudo mkdir -p /usr/local/etc/pkg/repos
sed 's#/quarterly#/latest#g' /etc/pkg/FreeBSD.conf | sudo tee /usr/local/etc/pkg/repos/FreeBSD.conf
sudo pkg upgrade
- name: Install dependencies
uses: ./.github/actions/dependencies/install

- name: Build `mod_tile`
uses: ./.github/actions/build

- name: Test `mod_tile`
uses: ./.github/actions/test

- name: Process & Report `mod_tile` coverage results
uses: ./.github/actions/coverage

- name: Package `mod_tile`
uses: ./.github/actions/cmake/package

- name: Install `mod_tile`
uses: ./.github/actions/install

macOS:
env:
CFLAGS: --coverage
Expand Down Expand Up @@ -208,12 +280,10 @@ jobs:
- name: Install `mod_tile`
uses: ./.github/actions/install

FreeBSD:
OpenBSD:
env:
CFLAGS: --coverage
CTEST_CLIENT_HOST: ::1
CTEST_SERVER_HOST: localhost
CXXFLAGS: --coverage
INSTALL_PREFIX: /usr/local
LIBRARY_PATH: /usr/local/lib
TMPDIR: /tmp
Expand All @@ -225,19 +295,11 @@ jobs:
strategy:
matrix:
box_generic:
- freebsd13
- openbsd7
build_system:
- CMake
compiler:
- LLVM
on_default_branch:
- ${{ contains(github.ref, 'master') || contains(github.ref, 'develop') || contains(github.ref, 'CI') }}
include:
- box_generic: freebsd14
build_system: CMake
compiler: LLVM
exclude:
- on_default_branch: false
fail-fast: false
steps:
- name: Checkout code
Expand All @@ -249,18 +311,17 @@ jobs:
echo "TEST_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV}
- name: Provision VM
uses: hummeltech/freebsd-vagrant-action@v1.4
uses: hummeltech/openbsd-vagrant-action@v2
with:
box: generic/${{ matrix.box_generic }}
cpus: ${{ env.BUILD_PARALLEL_LEVEL }}
memory: 4096
memory: 8192

# Mapnik is not in the `quarterly` repository (2023.10.12)
- name: Use "latest" repository
- name: Install X Windows
run: |
sudo mkdir -p /usr/local/etc/pkg/repos
sed 's#/quarterly#/latest#g' /etc/pkg/FreeBSD.conf | sudo tee /usr/local/etc/pkg/repos/FreeBSD.conf
sudo pkg upgrade
curl -L https://cdn.openbsd.org/pub/OpenBSD/$(uname -r)/amd64/xbase$(uname -r | sed 's/\.//').tgz | sudo tar -C / -xzvf -
curl -L https://cdn.openbsd.org/pub/OpenBSD/$(uname -r)/amd64/xfont$(uname -r | sed 's/\.//').tgz | sudo tar -C / -xzvf -
sudo ldconfig /usr/*/lib
- name: Install dependencies
uses: ./.github/actions/dependencies/install
Expand All @@ -271,9 +332,6 @@ jobs:
- name: Test `mod_tile`
uses: ./.github/actions/test

- name: Process & Report `mod_tile` coverage results
uses: ./.github/actions/coverage

- name: Package `mod_tile`
uses: ./.github/actions/cmake/package

Expand Down
6 changes: 4 additions & 2 deletions src/mod_tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ module AP_MODULE_DECLARE_DATA tile_module;

APLOG_USE_MODULE(tile);

#if (defined(__FreeBSD__) || defined(__MACH__)) && !defined(s6_addr32)
#define s6_addr32 __u6_addr.__u6_addr32
#if defined(AF_INET6) && !defined(s6_addr32)
# if defined(__APPLE__)|| defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# define s6_addr32 __u6_addr.__u6_addr32
# endif
#endif

apr_shm_t *stats_shm;
Expand Down
32 changes: 16 additions & 16 deletions src/render_expired.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,22 +305,6 @@ int main(int argc, char **argv)
}
}

// initialise arrays for tile markings

tile_requested = (unsigned int **)malloc((max_zoom - excess_zoomlevels + 1) * sizeof(unsigned int *));

for (int i = 0; i <= max_zoom - excess_zoomlevels; i++) {
// initialize twopow array
twopow[i] = (i == 0) ? 1 : twopow[i - 1] * 2;
unsigned long long fourpow = twopow[i] * twopow[i];
tile_requested[i] = (unsigned int *)calloc((fourpow / METATILE) + 1, 1);

if (NULL == tile_requested[i]) {
g_logger(G_LOG_LEVEL_CRITICAL, "not enough memory available");
return 1;
}
}

store = init_storage_backend(tile_dir);

if (store == NULL) {
Expand Down Expand Up @@ -364,6 +348,22 @@ int main(int argc, char **argv)
doRender = 1;
}

// initialise arrays for tile markings

tile_requested = (unsigned int **)malloc((max_zoom - excess_zoomlevels + 1) * sizeof(unsigned int *));

for (int i = 0; i <= max_zoom - excess_zoomlevels; i++) {
// initialize twopow array
twopow[i] = (i == 0) ? 1 : twopow[i - 1] * 2;
unsigned long long fourpow = twopow[i] * twopow[i];
tile_requested[i] = (unsigned int *)calloc((fourpow / METATILE) + 1, 1);

if (NULL == tile_requested[i]) {
g_logger(G_LOG_LEVEL_CRITICAL, "not enough memory available");
return 1;
}
}

gettimeofday(&start, NULL);

while (!feof(stdin)) {
Expand Down
11 changes: 8 additions & 3 deletions src/render_submit_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,12 @@ int make_connection(const char *spath)
if (!hostname_len) {
hostname = strdup(RENDERD_HOST);
} else {
hostname = malloc(hostname_len + sizeof('\0'));
assert(hostname != NULL);
strncpy(hostname, spath, hostname_len);
hostname = strndup(spath, hostname_len);
}

if (!hostname) {
g_logger(G_LOG_LEVEL_CRITICAL, "Error duplicating hostname: %s", strerror(errno));
exit(2);
}

if (d) {
Expand Down Expand Up @@ -348,6 +351,8 @@ int make_connection(const char *spath)
g_logger(G_LOG_LEVEL_CRITICAL, "cannot connect to any address for %s", hostname);
exit(2);
}

free(hostname);
}

return fd;
Expand Down
2 changes: 1 addition & 1 deletion src/renderd.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ int main(int argc, char **argv)

unlink(config.socketname);
free_map_sections(maps);
free_renderd_sections(config_slaves);
free_renderd_section(config_slaves[active_renderd_section_num]);
close(fd);
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ find_program(ID_EXECUTABLE NAMES id REQUIRED)
find_program(JQ_EXECUTABLE NAMES jq)
find_program(KILL_EXECUTABLE NAMES kill REQUIRED)
find_program(MEMCACHED_EXECUTABLE NAMES memcached)
find_program(MKDIR_EXECUTABLE NAMES mkdir REQUIRED)
find_program(MKDIR_EXECUTABLE NAMES gmkdir mkdir REQUIRED)
find_program(PS_EXECUTABLE NAMES ps REQUIRED)
find_program(SHA256SUM_EXECUTABLE NAMES gsha256sum sha256sum REQUIRED)
find_program(SLEEP_EXECUTABLE NAMES sleep REQUIRED)
Expand Down
9 changes: 1 addition & 8 deletions tests/gen_tile_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,7 @@ void *addition_thread(void *arg)
{
struct request_queue *queue = (struct request_queue *)arg;
struct item *item;
uint64_t threadid;
#ifdef __MACH__ // Mac OS X does not support SYS_gettid
pthread_threadid_np(NULL, &threadid);
#elif __FreeBSD__ // FreeBSD does not support SYS_getid either
threadid = (uint64_t)pthread_self();
#else
threadid = syscall(SYS_gettid);
#endif
uint64_t threadid = (uint64_t)pthread_self();

// Requests need to be unique across threads to avoid being discarded as duplicates,
// thereby ensuring the queue counts can be compared correctly.
Expand Down
2 changes: 1 addition & 1 deletion tests/render_expired_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "config.h"
#include "render_config.h"

#ifdef __FreeBSD__
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/wait.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion tests/render_list_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "config.h"
#include "render_config.h"

#ifdef __FreeBSD__
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/wait.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion tests/render_old_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "config.h"
#include "render_config.h"

#ifdef __FreeBSD__
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/wait.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion tests/render_speedtest_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "config.h"
#include "render_config.h"

#ifdef __FreeBSD__
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/wait.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion tests/renderd_config_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "render_config.h"
#include "renderd.h"

#ifdef __FreeBSD__
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/wait.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion tests/renderd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "catch_test_common.hpp"
#include "config.h"

#ifdef __FreeBSD__
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/wait.h>
#endif

Expand Down

0 comments on commit cccdc0e

Please sign in to comment.