Skip to content

Commit

Permalink
Add CPack packaging to GitHub Actions (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
hummeltech authored Mar 13, 2024
1 parent 0aa7607 commit d9dbf82
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 103 deletions.
43 changes: 43 additions & 0 deletions .github/actions/cmake/package/action.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions .github/actions/cmake/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
33 changes: 32 additions & 1 deletion .github/actions/coverage/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
inputs:
genhtml-extra-options:
default: ""
lcov-extra-options:
default: ""

Expand All @@ -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/[email protected]
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .github/actions/dependencies/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
24 changes: 22 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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/[email protected]
Expand Down Expand Up @@ -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
81 changes: 0 additions & 81 deletions .github/workflows/coverage.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/docker-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions docker/.gitignore

This file was deleted.

15 changes: 9 additions & 6 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -304,5 +304,8 @@ services:
shm_size: 1gb

volumes:
data:
fonts:
pgdata:
styles:
tiles:
2 changes: 0 additions & 2 deletions docker/full-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit d9dbf82

Please sign in to comment.