Skip to content
This repository has been archived by the owner on Oct 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #457 from hotosm/ci/test-failure-signals
Browse files Browse the repository at this point in the history
Correctly handle exit signal on ci test pass/fail
  • Loading branch information
emi420 authored Dec 15, 2023
2 parents bfa9a9e + 8bfb6c0 commit 32fef60
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_ci_img.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

jobs:
underpass-ci-build:
uses: hotosm/gh-workflows/.github/workflows/[email protected].0
uses: hotosm/gh-workflows/.github/workflows/[email protected].1
with:
dockerfile: docker/underpass.dockerfile
scan_dockerfile: false
Expand Down
29 changes: 6 additions & 23 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,12 @@ on:
push:
paths:
- docs/**
- src/**
- mkdocs.yml
branches:
- master

permissions:
contents: write
branches: [master]
# Allow manual trigger (workflow_dispatch)
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV


- uses: actions/cache@v3
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material mkdocs-exclude mkdocstrings
- run: mkdocs gh-deploy --force
publish_docs:
uses: hotosm/gh-workflows/.github/workflows/[email protected]
3 changes: 3 additions & 0 deletions .github/workflows/release_img.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@ jobs:
uses: hotosm/gh-workflows/.github/workflows/[email protected]
with:
dockerfile: docker/underpass.dockerfile
scan_dockerfile: false
build_target: prod
image_name: ghcr.io/${{ github.repository }}

api-build:
uses: hotosm/gh-workflows/.github/workflows/[email protected]
with:
dockerfile: docker/underpass-api.dockerfile
scan_dockerfile: false
build_target: prod
image_name: ghcr.io/${{ github.repository }}/api

ui-build:
uses: hotosm/gh-workflows/.github/workflows/[email protected]
with:
dockerfile: docker/underpass-ui.dockerfile
scan_dockerfile: false
build_target: prod
image_name: ghcr.io/${{ github.repository }}/ui
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:
image_name: ghcr.io/${{ github.repository }}
build_dockerfile: docker/underpass.dockerfile
compose_service: underpass
compose_command: echo "Tests complete."
compose_command: '"make check -j $(nproc)"'
tag_override: ci
# TODO update postgis image to use github repo var ${{ vars.POSTGIS_TAG }}
cache_extra_imgs: |
"docker.io/postgis/postgis:15-3.3-alpine"
16 changes: 12 additions & 4 deletions ci/ci_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ cd ${TEMP_DIR}
make distclean -j `nproc` || true
make clean -j `nproc` || true

# Run CI
APP_VERSION=ci docker compose run underpass --exit-code-from=underpass
# Stop containers if running
docker rm --force underpass underpass_postgis underpass_api underpass_ui || true

# Shut down containers
APP_VERSION=ci docker compose down
# Run CI
export TAG_OVERRIDE=ci
echo
# Use -t flag to pass signals via tty
docker compose run -t --rm --build underpass
echo "Returned signal from tests: $?"
echo

# Cleanup containers
docker rm --force underpass underpass_postgis underpass_api underpass_ui || true

echo "Remove temporary folder ${TEMP_DIR}"
sudo rm -rf ${TEMP_DIR}
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ services:

# Underpass
underpass:
image: "ghcr.io/hotosm/underpass:${APP_VERSION:-debug}"
image: "ghcr.io/hotosm/underpass:${TAG_OVERRIDE:-debug}"
container_name: "underpass"
build:
context: .
dockerfile: docker/underpass.dockerfile
target: debug
target: ${TAG_OVERRIDE:-debug}
args:
APP_VERSION: ${APP_VERSION:-debug}
depends_on: [postgis]
environment:
- REPLICATOR_UNDERPASS_DB_URL=underpass:underpass@postgis/underpass
command: tail -f /dev/null
volumes:
- ./replication:/code/build/replication
# - ./:/code
# volumes:
# - ${PWD}:/code
# - ./replication:/code/build/replication
networks:
internal:

Expand Down
41 changes: 0 additions & 41 deletions docker/build-and-test.sh

This file was deleted.

39 changes: 25 additions & 14 deletions docker/underpass.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ RUN set -ex \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install \
-y --no-install-recommends \
"git" \
"software-properties-common" \
"libboost-all-dev" \
"autotools-dev" \
Expand All @@ -42,21 +43,15 @@ RUN set -ex \
"libgdal-dev" \
"libosmium2-dev" \
"libpqxx-dev" \
"postgresql" \
"postgresql-postgis" \
"libgumbo-dev" \
"librange-v3-dev" \
"libtool" \
"osm2pgsql" \
&& rm -rf /var/lib/apt/lists/*



FROM deps as ci
COPY docker/build-and-test.sh /build-and-test.sh
RUN chmod +x /build-and-test.sh
ENTRYPOINT [ "/bin/bash", "-c" ]



FROM deps as build
# Build underpass
COPY . .
Expand All @@ -68,11 +63,22 @@ RUN ../configure && \



FROM build as ci
ENV LD_LIBRARY_PATH=/code/build/.libs/
WORKDIR /code/build
ENTRYPOINT [ "/bin/bash", "-c" ]
CMD ["make", "check", "-j", "$(nproc)"]



FROM deps as debug
# Local debug with all dev deps
ENV PATH=$PATH:/code/build \
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/code/build/.libs
COPY --from=build /code/build /code/build
ENV LD_LIBRARY_PATH=/code/build/.libs/
COPY --from=build /usr/local/bin /usr/local/bin
COPY --from=build /code/build/.libs/ \
/code/build/.libs/
COPY --from=build /usr/local/lib/underpass/config \
/usr/local/lib/underpass/config
WORKDIR /code/build
# Add non-root user
RUN useradd -r -u 1001 -m -c "hotosm account" -d /home/appuser -s /bin/false appuser
Expand All @@ -83,8 +89,7 @@ USER appuser

FROM base as prod
# Production image with minimal deps
ENV PATH=$PATH:/code/build \
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/code/build/.libs
ENV LD_LIBRARY_PATH=/usr/local/lib
RUN set -ex \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install \
Expand All @@ -96,8 +101,14 @@ RUN set -ex \
"libjemalloc2" \
"libpqxx-6.4" \
"libgumbo1" \
"postgresql-client" \
"osm2pgsql" \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build /code/build /code/build
COPY --from=build /usr/local/bin /usr/local/bin
COPY --from=build /code/build/.libs/ \
/usr/local/lib/
COPY --from=build /usr/local/lib/underpass/config \
/usr/local/lib/underpass/config
WORKDIR /code/build
# Add non-root user
RUN useradd -r -u 1001 -m -c "hotosm account" -d /home/appuser -s /bin/false appuser
Expand Down

0 comments on commit 32fef60

Please sign in to comment.