From d13186ae7dff7b8cdedb64e2d73288e9ea0f8f53 Mon Sep 17 00:00:00 2001 From: Hummeltech <6109326+hummeltech@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:31:53 -0700 Subject: [PATCH] FreeBSD via Vagrant allows reuse of existing actions (#339) Currently, there is a lot of duplicate CI config for FreeBSD jobs, this removes that redundancy. --- .github/actions/cmake/test/action.yml | 8 +-- .../actions/dependencies/install/action.yml | 22 +++++++- .../dependencies/install/pkg/action.yml | 15 +++++ .github/actions/freebsd/action.yml | 40 ------------- .github/workflows/build-and-test.yml | 56 ++++++++++++++++--- docs/build/building_on_freebsd.md | 6 +- tests/CMakeLists.txt | 14 +++++ 7 files changed, 103 insertions(+), 58 deletions(-) create mode 100644 .github/actions/dependencies/install/pkg/action.yml delete mode 100644 .github/actions/freebsd/action.yml diff --git a/.github/actions/cmake/test/action.yml b/.github/actions/cmake/test/action.yml index d580d9fc..095e6ef8 100644 --- a/.github/actions/cmake/test/action.yml +++ b/.github/actions/cmake/test/action.yml @@ -10,16 +10,16 @@ runs: shell: bash --noprofile --norc -euxo pipefail {0} - name: Test `mod_tile` - run: ctest --exclude-regex 'clear_dirs|remove_tile' --output-on-failure + run: ctest --exclude-regex 'clear_dirs|remove_tiles' --output-on-failure shell: bash --noprofile --norc -euxo pipefail {0} working-directory: build - name: Archive test artifacts on failure if: failure() run: | - TAR_FILENAME=${{ matrix.image || matrix.os }}-${{ matrix.compiler }}.tar.gz + TAR_FILENAME=${{ matrix.image || matrix.os || github.job }}-${{ matrix.compiler }}.tar.gz TAR_FILENAME=$(echo "${TAR_FILENAME}" | sed 's/:/-/g') - tar -zcf /tmp/${TAR_FILENAME} tests + tar -zcf ${{ runner.temp }}/${TAR_FILENAME} tests shell: bash --noprofile --norc -euxo pipefail {0} working-directory: build @@ -28,4 +28,4 @@ runs: uses: actions/upload-artifact@v3 with: name: Test Artifacts - path: /tmp/*.tar.gz + path: ${{ runner.temp }}/*.tar.gz diff --git a/.github/actions/dependencies/install/action.yml b/.github/actions/dependencies/install/action.yml index 10e4ebc8..2d18a84e 100644 --- a/.github/actions/dependencies/install/action.yml +++ b/.github/actions/dependencies/install/action.yml @@ -45,6 +45,17 @@ inputs: fedora-test-dependencies: default: >- httpd + freebsd-build-dependencies: + default: >- + apache24 + cairo + coreutils + curl + glib + iniparser + libmemcached + mapnik + pkgconf macos-build-dependencies: default: >- apr @@ -166,6 +177,15 @@ runs: ${{ matrix.compiler == 'LLVM' && 'clang' || 'gcc gcc-c++' }} if: startsWith(matrix.image, 'fedora:') + - name: Install Dependencies (FreeBSD) + uses: ./.github/actions/dependencies/install/pkg + with: + packages: >- + ${{ inputs.freebsd-build-dependencies }} + ${{ matrix.build_system == 'CMake' && 'cmake' || 'autoconf automake' }} + ${{ matrix.compiler == 'GNU' && 'gcc' || 'llvm' }} + if: github.job == 'FreeBSD' + - name: Install Dependencies (macOS) uses: ./.github/actions/dependencies/install/brew with: @@ -174,7 +194,7 @@ runs: ${{ inputs.macos-test-dependencies }} ${{ matrix.build_system == 'CMake' && 'cmake' || 'autoconf automake' }} ${{ matrix.compiler == 'GNU' && 'gcc' || '' }} - if: runner.os == 'macOS' + if: github.job == 'macOS' - name: Install Dependencies (Ubuntu) uses: ./.github/actions/dependencies/install/apt-get diff --git a/.github/actions/dependencies/install/pkg/action.yml b/.github/actions/dependencies/install/pkg/action.yml new file mode 100644 index 00000000..b57d6abb --- /dev/null +++ b/.github/actions/dependencies/install/pkg/action.yml @@ -0,0 +1,15 @@ +--- +inputs: + packages: + description: List of package(s) to install + required: true + options: + default: --yes + description: Option(s) to pass + +runs: + using: composite + steps: + - name: Install package(s) + run: ${{ !matrix.image && 'sudo' || '' }} pkg install ${{ inputs.options }} ${{ inputs.packages }} + shell: bash --noprofile --norc -euxo pipefail {0} diff --git a/.github/actions/freebsd/action.yml b/.github/actions/freebsd/action.yml deleted file mode 100644 index 44eec60c..00000000 --- a/.github/actions/freebsd/action.yml +++ /dev/null @@ -1,40 +0,0 @@ ---- -inputs: - build-dependencies: - default: >- - apache24 - cairo - cmake - coreutils - curl - glib - iniparser - mapnik - pkgconf - description: List of build dependency package(s) to install - -runs: - using: composite - steps: - - name: Install dependencies, Build, Test & Install `mod_tile` - uses: vmactions/freebsd-vm@v0.3.0 - with: - mem: 4096 - prepare: | - mkdir -p /usr/local/etc/pkg/repos - sed 's#/quarterly#/latest#g' /etc/pkg/FreeBSD.conf > /usr/local/etc/pkg/repos/FreeBSD.conf - pkg upgrade --yes - pkg install --yes ${{ inputs.build-dependencies }} - release: 13.1 - run: | - export CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.ncpu) - export LIBRARY_PATH=/usr/local/lib - cmake -B build -S . \ - -LA \ - -DCMAKE_BUILD_TYPE:STRING=${BUILD_TYPE:-Release} \ - -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PREFIX:-/usr/local} \ - -DENABLE_TESTS:BOOL=ON - cmake --build build - ctest --test-dir build - cmake --install build - usesh: true diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 1d6169cd..6f771ed5 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -59,9 +59,7 @@ jobs: container: env: CC: ${{ matrix.compiler == 'LLVM' && 'clang' || 'gcc' }} - CFLAGS: ${{ (matrix.build_system == 'CMake' && matrix.compiler == 'GNU') && '--coverage' || '' }} CXX: ${{ matrix.compiler == 'LLVM' && 'clang++' || 'g++' }} - CXXFLAGS: ${{ (matrix.build_system == 'CMake' && matrix.compiler == 'GNU') && '--coverage' || '' }} image: ${{ matrix.image }} steps: - name: Install `git` (Amazon Linux 2) @@ -88,7 +86,10 @@ jobs: CFLAGS: -Wno-implicit-function-declaration LDFLAGS: -undefined dynamic_lookup LIBRARY_PATH: /usr/local/lib - name: ${{ matrix.os }} (${{ matrix.build_system }}) (${{ matrix.compiler }}) + name: >- + ${{ matrix.os }} + (${{ matrix.build_system }}) + (${{ matrix.compiler }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -132,12 +133,51 @@ jobs: uses: ./.github/actions/install FreeBSD: - if: contains(github.ref, 'master') || contains(github.ref, 'develop') - name: FreeBSD (CMake) (LLVM) - runs-on: macos-12 + env: + BUILD_PARALLEL_LEVEL: 4 + LIBRARY_PATH: /usr/local/lib + TMPDIR: /tmp + name: >- + ${{ matrix.box_generic }} + (${{ matrix.build_system }}) + (${{ matrix.compiler }}) + runs-on: macos-latest + strategy: + matrix: + box_generic: + - freebsd12 + build_system: + - CMake + compiler: + - LLVM + on_default_branch: + - ${{ contains(github.ref, 'master') || contains(github.ref, 'develop') }} + include: + - box_generic: freebsd13 + build_system: CMake + compiler: LLVM + exclude: + - on_default_branch: false + fail-fast: false steps: - name: Checkout code uses: actions/checkout@v3 - - name: Install dependencies, Build, Test & Install `mod_tile` - uses: ./.github/actions/freebsd + - name: Provision VM + uses: hummeltech/freebsd-vagrant-action@v1.3 + with: + box: generic/${{ matrix.box_generic }} + cpus: ${{ env.BUILD_PARALLEL_LEVEL }} + memory: 4096 + + - 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: Install `mod_tile` + uses: ./.github/actions/install diff --git a/docs/build/building_on_freebsd.md b/docs/build/building_on_freebsd.md index 6c3bc6ff..88dc1cec 100644 --- a/docs/build/building_on_freebsd.md +++ b/docs/build/building_on_freebsd.md @@ -4,14 +4,10 @@ This document provides users with step-by-step instructions on how to compile an Please see our [Continuous Integration script](/.github/workflows/build-and-test.yml) for more details. -## FreeBSD 13.0/13.1/13.2 +## FreeBSD 12/13 ```shell #!/usr/bin/env sh -# Mapnik & GDAL w/ working GPKG support are not in the `quarterly` repository (2023.05.04) -sudo mkdir -p /usr/local/etc/pkg/repos -sudo sed 's#/quarterly#/latest#g' /etc/pkg/FreeBSD.conf > /usr/local/etc/pkg/repos/FreeBSD.conf - # Update installed packages sudo pkg upgrade --yes diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 976b8653..7d11464f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -83,6 +83,7 @@ add_test( add_test( NAME create_dirs COMMAND ${MKDIR_EXECUTABLE} -p -v logs run tiles + WORKING_DIRECTORY tests ) add_test( NAME start_renderd @@ -94,14 +95,17 @@ add_test( echo 'exit 0' >> ${PROJECT_BINARY_DIR}/tests/renderd_start.sh ${BASH} ${PROJECT_BINARY_DIR}/tests/renderd_start.sh " + WORKING_DIRECTORY tests ) add_test( NAME start_httpd COMMAND ${HTTPD_EXECUTABLE} -e debug -f ${PROJECT_BINARY_DIR}/tests/conf/httpd.conf -k start + WORKING_DIRECTORY tests ) add_test( NAME render_speedtest COMMAND render_speedtest --map ${MAP_NAME} --max-zoom 10 --socket ${PROJECT_BINARY_DIR}/tests/run/renderd.sock + WORKING_DIRECTORY tests ) add_test( NAME render_expired @@ -114,6 +118,7 @@ add_test( --socket ${PROJECT_BINARY_DIR}/tests/run/renderd.sock \ --tile-dir ${PROJECT_BINARY_DIR}/tests/tiles " + WORKING_DIRECTORY tests ) add_test( NAME render_list @@ -128,6 +133,7 @@ add_test( --socket ${PROJECT_BINARY_DIR}/tests/run/renderd.sock \ --tile-dir ${PROJECT_BINARY_DIR}/tests/tiles " + WORKING_DIRECTORY tests ) add_test( NAME render_old @@ -142,6 +148,7 @@ add_test( --socket ${PROJECT_BINARY_DIR}/tests/run/renderd.sock \ --tile-dir ${PROJECT_BINARY_DIR}/tests/tiles " + WORKING_DIRECTORY tests ) add_test( NAME download_tiles @@ -167,6 +174,7 @@ add_test( sleep 1; done " + WORKING_DIRECTORY tests ) add_test( NAME check_tiles @@ -177,6 +185,7 @@ add_test( (echo '${TILE_PNG32_SHA256SUM} tile.png32' | ${SHA256SUM_EXECUTABLE} -c) && \ ((echo '${TILE_WEBP_SHA256SUM_7} tile.webp' | ${SHA256SUM_EXECUTABLE} -c) || (echo '${TILE_WEBP_SHA256SUM_6} tile.webp' | ${SHA256SUM_EXECUTABLE} -c) || (echo '${TILE_WEBP_SHA256SUM_4} tile.webp' | ${SHA256SUM_EXECUTABLE} -c)) " + WORKING_DIRECTORY tests ) add_test( NAME dirty_tile @@ -193,10 +202,12 @@ add_test( sleep 1; done " + WORKING_DIRECTORY tests ) add_test( NAME remove_tiles COMMAND ${RM} -v tile.png tile.jpg tile.png256 tile.png32 tile.webp + WORKING_DIRECTORY tests ) add_test( NAME stop_renderd @@ -204,18 +215,21 @@ add_test( ${KILL_EXECUTABLE} $(${CAT_EXECUTABLE} run/renderd1.pid) && ${RM} run/renderd1.pid ${KILL_EXECUTABLE} $(${CAT_EXECUTABLE} run/renderd.pid) && ${RM} run/renderd.pid " + WORKING_DIRECTORY tests ) add_test( NAME stop_httpd COMMAND ${BASH} -c " ${KILL_EXECUTABLE} $(${CAT_EXECUTABLE} run/httpd.pid) && ${RM} run/httpd.pid " + WORKING_DIRECTORY tests ) add_test( NAME clear_dirs COMMAND ${BASH} -c " ${RM} -f -r -v logs/* run/* tiles/* " + WORKING_DIRECTORY tests )