Add CPack packaging to GitHub Actions (#406)

This commit is contained in:
Hummeltech
2024-03-12 22:58:15 -07:00
committed by GitHub
parent 0aa7607d7b
commit d9dbf82524
13 changed files with 119 additions and 103 deletions

View File

@ -0,0 +1,43 @@
---
runs:
using: composite
steps:
- name: Set `CPACK_PACKAGE_FILE_NAME`
run: |
echo "CPACK_PACKAGE_FILE_NAME=mod_tile-${GITHUB_SHA}-$(echo ${{ matrix.image || matrix.os || matrix.box_generic || github.job }}-${{ matrix.compiler }} | sed 's/[^0-9a-zA-Z-]/_/g')" >> ${GITHUB_ENV}
shell: bash --noprofile --norc -euxo pipefail {0}
- name: Set `CPACK_OPTIONS`
run: |
if command -v dpkg; then
echo "CPACK_OPTIONS= -G DEB" >> ${GITHUB_ENV}
elif command -v rpm; then
echo "CPACK_OPTIONS=-G RPM" >> ${GITHUB_ENV}
elif [ -f /etc/os-release ]; then
source /etc/os-release
if [ "$ID" = "freebsd" ]; then
echo "CPACK_OPTIONS=-D CPACK_FREEBSD_PACKAGE_LICENSE=GPLv2 -D CPACK_SET_DESTDIR=1 -G FREEBSD" >> ${GITHUB_ENV}
fi
elif [[ ${OSTYPE} == 'darwin'* ]]; then
echo "CPACK_OPTIONS=-D CPACK_SET_DESTDIR=1 -G DragNDrop" >> ${GITHUB_ENV}
else
echo "CPACK_OPTIONS=-D CPACK_SET_DESTDIR=1 -G TGZ" >> ${GITHUB_ENV}
fi
shell: bash --noprofile --norc -euxo pipefail {0}
- name: Package `mod_tile`
run: |
${{ !matrix.image && 'sudo' || '' }} cpack ${CPACK_OPTIONS} \
-D CPACK_PACKAGE_CONTACT="GitHub Actions" \
-D CPACK_PACKAGE_FILE_NAME="${CPACK_PACKAGE_FILE_NAME}" || true
shell: bash --noprofile --norc -euxo pipefail {0}
working-directory: build
- name: Upload `mod_tile` package artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: ignore
name: Package Artifacts - ${{ env.CPACK_PACKAGE_FILE_NAME }}${{ matrix.mapnik_latest && ' (Latest Mapnik)' || '' }}
path: |
build/${{ env.CPACK_PACKAGE_FILE_NAME }}.*
retention-days: 14

View File

@ -15,11 +15,11 @@ runs:
- name: Set `TEST_ARTIFACT_NAME`
run: |
echo "TEST_ARTIFACT_NAME=$(echo ${{ matrix.image || matrix.os || github.job }}-${{ matrix.compiler }} | sed 's/[^0-9a-zA-Z-]/_/g')" >> "$GITHUB_ENV"
echo "TEST_ARTIFACT_NAME=$(echo ${{ matrix.image || matrix.os || matrix.box_generic || github.job }}-${{ matrix.compiler }} | sed 's/[^0-9a-zA-Z-]/_/g')" >> ${GITHUB_ENV}
shell: bash --noprofile --norc -euxo pipefail {0}
if: failure()
- name: Upload test artifacts on failure
- name: Upload `mod_tile` test artifacts on failure
uses: actions/upload-artifact@v4
with:
name: Test Artifacts - ${{ env.TEST_ARTIFACT_NAME }}

View File

@ -1,5 +1,7 @@
---
inputs:
genhtml-extra-options:
default: ""
lcov-extra-options:
default: ""
@ -19,10 +21,39 @@ runs:
"${GITHUB_WORKSPACE}/includes/*" \
"${GITHUB_WORKSPACE}/tests/*" \
"/usr/*"
working-directory: build
shell: bash --noprofile --norc -euxo pipefail {0}
working-directory: build
- name: Report `mod_tile` coverage results to `codecov.io`
uses: codecov/codecov-action@v3.1.5
with:
files: build/coverage.info
- name: Write `mod_tile` coverage summary to `$GITHUB_STEP_SUMMARY`
run: |
lcov ${{ inputs.lcov-extra-options }} \
--summary \
coverage.info | sed 's/^ /* /g' >> ${GITHUB_STEP_SUMMARY}
shell: bash --noprofile --norc -euxo pipefail {0}
working-directory: build
- name: Generate `mod_tile` coverage artifacts
run: |
genhtml ${{ inputs.genhtml-extra-options }} \
--output-directory coverage \
coverage.info
shell: bash --noprofile --norc -euxo pipefail {0}
working-directory: build
- name: Set `COVERAGE_ARTIFACT_NAME`
run: |
echo "COVERAGE_ARTIFACT_NAME=$(echo ${{ matrix.image || matrix.os || matrix.box_generic || github.job }}-${{ matrix.compiler }} | sed 's/[^0-9a-zA-Z-]/_/g')" >> ${GITHUB_ENV}
shell: bash --noprofile --norc -euxo pipefail {0}
- name: Upload `mod_tile` coverage artifacts
uses: actions/upload-artifact@v4
with:
name: Coverage Artifacts - ${{ env.COVERAGE_ARTIFACT_NAME }}${{ matrix.mapnik_latest && ' (Latest Mapnik)' || '' }}
path: |
build/coverage
build/coverage.info

View File

@ -9,7 +9,7 @@ runs:
path: |
mapnik-build
mapnik-src
key: ${{ matrix.image || matrix.os || github.job }}-${{ matrix.compiler }}-mapnik-latest
key: ${{ matrix.image || matrix.os || matrix.box_generic || github.job }}-${{ matrix.compiler }}-mapnik-latest
- name: Checkout `Mapnik`
uses: actions/checkout@v4

View File

@ -213,6 +213,7 @@ runs:
${{ inputs.rhel-test-dependencies }}
${{ matrix.build_system == 'CMake' && 'cmake' || 'autoconf automake redhat-rpm-config' }}
${{ matrix.compiler == 'LLVM' && 'clang' || 'gcc gcc-c++' }}
rpm-build
if: startsWith(matrix.image, 'quay.io/centos/centos:stream')
- name: Install Dependencies (Debian)
@ -234,6 +235,7 @@ runs:
${{ inputs.fedora-test-dependencies }}
${{ matrix.build_system == 'CMake' && 'cmake' || 'autoconf automake redhat-rpm-config' }}
${{ matrix.compiler == 'LLVM' && 'clang' || 'gcc gcc-c++' }}
rpm-build
if: startsWith(matrix.image, 'fedora:')
- name: Install Dependencies (FreeBSD)
@ -265,6 +267,7 @@ runs:
${{ inputs.opensuse-test-dependencies }}
${{ matrix.build_system == 'CMake' && 'cmake' || 'automake' }}
${{ matrix.compiler == 'LLVM' && 'clang' || 'gcc12 gcc12-c++' }}
rpm-build
if: startsWith(matrix.image, 'opensuse/')
- name: Install Dependencies (Ubuntu)

View File

@ -77,9 +77,15 @@ jobs:
if: |
matrix.build_system == 'CMake' &&
matrix.compiler != 'LLVM' &&
matrix.image != 'debian:testing' &&
matrix.image != 'opensuse/leap:15' &&
matrix.image != 'ubuntu:rolling'
- name: Package `mod_tile`
uses: ./.github/actions/cmake/package
if: |
matrix.build_system == 'CMake'
- name: Install `mod_tile`
uses: ./.github/actions/install
@ -127,6 +133,11 @@ jobs:
uses: ./.github/actions/coverage
if: matrix.build_system == 'CMake'
- name: Package `mod_tile`
uses: ./.github/actions/cmake/package
if: |
matrix.build_system == 'CMake'
- name: Install `mod_tile`
uses: ./.github/actions/install
@ -182,9 +193,15 @@ jobs:
- name: Process & Report `mod_tile` coverage results
uses: ./.github/actions/coverage
with:
genhtml-extra-options: --ignore-errors inconsistent --ignore-errors unmapped
lcov-extra-options: --ignore-errors gcov --ignore-errors inconsistent
if: matrix.build_system == 'CMake'
- name: Package `mod_tile`
uses: ./.github/actions/cmake/package
if: |
matrix.build_system == 'CMake'
- name: Install `mod_tile`
uses: ./.github/actions/install
@ -224,8 +241,8 @@ jobs:
- name: Set `BUILD_PARALLEL_LEVEL` & `TEST_PARALLEL_LEVEL`
run: |
echo "BUILD_PARALLEL_LEVEL=$(nproc)" >> "$GITHUB_ENV"
echo "TEST_PARALLEL_LEVEL=$(nproc)" >> "$GITHUB_ENV"
echo "BUILD_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV}
echo "TEST_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV}
- name: Provision VM
uses: hummeltech/freebsd-vagrant-action@v1.4
@ -253,5 +270,8 @@ jobs:
- 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

View File

@ -1,81 +0,0 @@
---
name: Coverage
on:
pull_request:
push:
branches:
- develop
- master
- "*CI"
jobs:
Coverage:
name: >-
Build, Test & Report Coverage
${{ matrix.mapnik_latest && '(Latest Mapnik)' || '' }}
runs-on: ubuntu-latest
env:
BUILD_TYPE: Debug
CFLAGS: --coverage
CXXFLAGS: --coverage
strategy:
matrix:
compiler:
- GNU
mapnik_latest:
- false
- true
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/dependencies/install
with:
ubuntu-mapnik-latest-build-dependencies: >-
cmake
git
libboost-program-options-dev
libboost-regex-dev
libfreetype6-dev
libgdal-dev
libharfbuzz-dev
libicu-dev
libjpeg-dev
libpq-dev
libproj-dev
libsqlite3-dev
libtiff-dev
libwebp-dev
libxml2-dev
- name: Stop `memcached` service
run: |
sudo systemctl stop memcached
- name: Build `mod_tile`
uses: ./.github/actions/cmake/build
- name: Test `mod_tile`
uses: ./.github/actions/cmake/test
- name: Process & Report `mod_tile` coverage results
uses: ./.github/actions/coverage
- name: Write coverage summary to `$GITHUB_STEP_SUMMARY`
run: lcov --summary build/coverage.info | sed 's/^ /* /g' >> ${GITHUB_STEP_SUMMARY}
- name: Generate `mod_tile` coverage results artifact
run: |
genhtml coverage.info --output-directory coverage
working-directory: build
- name: Upload `mod_tile` coverage results artifact
uses: actions/upload-artifact@v4
with:
name: Coverage Results - ${{ matrix.mapnik_latest && 'mapnik_latest' || 'mapnik' }}
path: |
build/coverage
build/coverage.info

View File

@ -66,11 +66,11 @@ jobs:
timeout-minutes: 1
- name: Show logs
if: failure()
run: docker compose logs
working-directory: docker
if: failure()
- name: Stop
if: success() || failure()
run: docker compose down --volumes
working-directory: docker
if: success() || failure()

View File

@ -42,24 +42,24 @@ jobs:
exit 1
fi
- name: Write `$ASTYLE_OUTPUT` to `$GITHUB_STEP_SUMMARY`
if: failure()
run: |
ASTYLE_OUTPUT=$(${ASTYLE_CMD} --dry-run)
echo "### The following files are in need of formatting:" >> ${GITHUB_STEP_SUMMARY}
echo "${ASTYLE_OUTPUT}" | grep -v "Unchanged" | awk '{print "- `"$2"`"}' >> ${GITHUB_STEP_SUMMARY}
echo "### Run the following command before submitting a pull request:" >> ${GITHUB_STEP_SUMMARY}
echo -e '```shell\n'"${ASTYLE_CMD}"'\n```' >> ${GITHUB_STEP_SUMMARY}
- name: Generate `ArtisticStyleFormattingFixes.patch` file
if: failure()
- name: Generate `ArtisticStyleFormattingFixes.patch` file
run: |
${ASTYLE_CMD}
git diff --patch > ArtisticStyleFormattingFixes.patch
- name: Upload `ArtisticStyleFormattingFixes.patch` file
if: failure()
- name: Upload `ArtisticStyleFormattingFixes.patch` file
uses: actions/upload-artifact@v4
with:
name: ArtisticStyleFormattingFixes.patch
path: ArtisticStyleFormattingFixes.patch
if: failure()
cmakelint:
name: Lint with `CMakeLint`

View File

@ -172,6 +172,8 @@ add_subdirectory(src)
#
#-----------------------------------------------------------------------------
include(CPack)
# Determine install destination for 'etc/apache2/tile.load.in'
if(EXISTS "/etc/os-release")
execute_process(COMMAND sh -c ". /etc/os-release && echo $ID"

3
docker/.gitignore vendored
View File

@ -1,3 +0,0 @@
data
fonts
styles

View File

@ -51,10 +51,10 @@ services:
condition: service_healthy
entrypoint: /entrypoint.sh
volumes:
- data:/opt/data
- fonts:/opt/fonts
- styles:/opt/styles
- tiles:/var/cache/renderd/tiles
- ./archlinux/data:/opt/data
- ./archlinux/fonts:/opt/fonts
- ./archlinux/styles:/opt/styles
- ./full-entrypoint.sh:/entrypoint.sh:ro
centos-7:
<<: *service_defaults
@ -283,11 +283,11 @@ services:
condition: service_healthy
entrypoint: /entrypoint.sh
volumes:
- data:/opt/data
- fonts:/opt/fonts
- styles:/opt/styles
- tiles:/var/cache/renderd/tiles
- ./full-entrypoint.sh:/entrypoint.sh:ro
- ./ubuntu/data:/opt/data
- ./ubuntu/fonts:/opt/fonts
- ./ubuntu/styles:/opt/styles
postgres:
env_file: .env
environment:
@ -304,5 +304,8 @@ services:
shm_size: 1gb
volumes:
data:
fonts:
pgdata:
styles:
tiles:

View File

@ -37,8 +37,6 @@ then
npm install --global carto
carto /opt/openstreetmap-carto/project.mml > /opt/styles/mapnik.xml
chmod --recursive 777 /opt/*
fi
sed -i \