From d9dbf82524cb7f04fd4486c099fba308249e103f Mon Sep 17 00:00:00 2001 From: Hummeltech <6109326+hummeltech@users.noreply.github.com> Date: Tue, 12 Mar 2024 22:58:15 -0700 Subject: [PATCH] Add CPack packaging to GitHub Actions (#406) --- .github/actions/cmake/package/action.yml | 43 ++++++++++ .github/actions/cmake/test/action.yml | 4 +- .github/actions/coverage/action.yml | 33 +++++++- .../mapnik/latest/action.yml | 2 +- .../actions/dependencies/install/action.yml | 3 + .github/workflows/build-and-test.yml | 24 +++++- .github/workflows/coverage.yml | 81 ------------------- .github/workflows/docker-image-build.yml | 4 +- .github/workflows/lint.yml | 6 +- CMakeLists.txt | 2 + docker/.gitignore | 3 - docker/docker-compose.yml | 15 ++-- docker/full-entrypoint.sh | 2 - 13 files changed, 119 insertions(+), 103 deletions(-) create mode 100644 .github/actions/cmake/package/action.yml delete mode 100644 .github/workflows/coverage.yml delete mode 100644 docker/.gitignore diff --git a/.github/actions/cmake/package/action.yml b/.github/actions/cmake/package/action.yml new file mode 100644 index 00000000..46658939 --- /dev/null +++ b/.github/actions/cmake/package/action.yml @@ -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 diff --git a/.github/actions/cmake/test/action.yml b/.github/actions/cmake/test/action.yml index c4af79d1..c8260bd8 100644 --- a/.github/actions/cmake/test/action.yml +++ b/.github/actions/cmake/test/action.yml @@ -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 }} diff --git a/.github/actions/coverage/action.yml b/.github/actions/coverage/action.yml index 0a4c6543..cf7aee9f 100644 --- a/.github/actions/coverage/action.yml +++ b/.github/actions/coverage/action.yml @@ -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 diff --git a/.github/actions/dependencies/build-and-install/mapnik/latest/action.yml b/.github/actions/dependencies/build-and-install/mapnik/latest/action.yml index 0998df2d..bec73040 100644 --- a/.github/actions/dependencies/build-and-install/mapnik/latest/action.yml +++ b/.github/actions/dependencies/build-and-install/mapnik/latest/action.yml @@ -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 diff --git a/.github/actions/dependencies/install/action.yml b/.github/actions/dependencies/install/action.yml index f5515997..1b803d16 100644 --- a/.github/actions/dependencies/install/action.yml +++ b/.github/actions/dependencies/install/action.yml @@ -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) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 724b4620..836ec60a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -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 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index 54a3d5ba..00000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/docker-image-build.yml b/.github/workflows/docker-image-build.yml index 4d79eafd..87fd22c5 100644 --- a/.github/workflows/docker-image-build.yml +++ b/.github/workflows/docker-image-build.yml @@ -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() diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2a1eac37..e466327b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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` diff --git a/CMakeLists.txt b/CMakeLists.txt index ff2bf659..189d704c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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" diff --git a/docker/.gitignore b/docker/.gitignore deleted file mode 100644 index 1dc9d840..00000000 --- a/docker/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -data -fonts -styles diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index aa3f2deb..7e6297e0 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -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: diff --git a/docker/full-entrypoint.sh b/docker/full-entrypoint.sh index 05e24f7b..0f461550 100755 --- a/docker/full-entrypoint.sh +++ b/docker/full-entrypoint.sh @@ -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 \