Skip to content

Commit

Permalink
Merge pull request #1021 from ix5/fix/ci
Browse files Browse the repository at this point in the history
Docker, CI: Make JS integration tests more robust; update screenshots
  • Loading branch information
ix5 authored Apr 29, 2024
2 parents dc11434 + 265d8e6 commit ac9fb0d
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 14 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/docker-testbed-periodic-rebuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Rebuild js testbed image

on:
workflow_dispatch:
schedule:
# Run weekly, at 2:15pm on Monday (chosen at random)
# https://cron.help/#15_14_*_*_1
- cron: '15 14 * * 1'

env:
build_platforms: ${{ vars.BUILD_PLATFORMS || 'linux/amd64' }}
build_image: ${{ vars.BUILD_IMAGE || 'ghcr.io/isso-comments/isso-js-testbed' }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
flavor: |
latest=false
images: ${{ env.build_image }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
- name: Login to Github Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build docker-js-testbed
run: make docker-testbed

- name: Push docker-js-testbed image as ${{ env.build_image }}
run: make docker-testbed-push
8 changes: 5 additions & 3 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ jobs:
run: docker compose build isso-server

- name: Bring up containers
# Don't wait for healthcheck via --wait. This would fail with a
# negative exit code since the isso-client container is expected to
# exit
run: docker compose up -d

- name: Client unit tests
run: make docker-js-unit

- name: Check if containers are up, sleep if not
shell: bash
run: '[ "$(docker inspect --format={{.State.Health.Status}} isso-server)" = "healthy" ] || sleep 5'
- name: Wait for isso-server container to be ready
run: 'for i in $(seq 1 30); do [ "`docker inspect -f {{.State.Health.Status}} isso-server`" == "healthy" ] && s=0 && break || s=$? && sleep 0.3; done; (exit $s)'

- name: Client integration tests
run: make docker-js-integration
Expand Down
17 changes: 11 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ services:
#command: /isso/bin/isso -c /config/isso.cfg run
environment:
ISSO_SETTINGS: "/config/isso-dev.cfg"
ISSO_ENDPOINT: "http://isso-dev.local:8080"
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:8080/info || exit 1
interval: 5s # short timeout needed during start phase
retries: 3
start_period: 5s
timeout: 3s
# Double $$ for parsing vars inside CMD: https://stackoverflow.com/a/54989793
# Debug with 'docker inspect --format "{{json .State.Health }}" isso-server | jq'
test: wget --no-verbose --tries=1 --spider $$ISSO_ENDPOINT/info || exit 1
interval: 1s # time before first check and between subsequent checks
retries: 10
start_period: 10s
timeout: 10s
# If needed, production docker image can also be exposed to host for
# non-docker unit/integration testing
ports:
- 127.0.0.1:8080:8080
# Expose port 80080 to other containerized services, not to host machine:
# Expose port 8080 to other containerized services, not to host machine:
expose:
- 8080
networks:
Expand All @@ -49,6 +52,8 @@ services:
dockerfile: docker/Dockerfile-js-testbed
environment:
ISSO_ENDPOINT: "http://isso-dev.local:8080"
healthcheck:
disable: true
# Command may also run from outside docker compose, e.g.:
# $ docker run isso-js-testbed [mount, networks, ...] npm run test-integration
#command: npm run test-integration
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile-js-testbed
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

# Note: Do not use alpine images as they do not contain needed GObject, X11
# etc. packages and complicate things
# :current resolves to NodeJS 17 on Debian Buster as of 03/2022
# :22-bookworm resolves to NodeJS 22 on Debian Bookworm as of 04/2024
# https://hub.docker.com/_/node
FROM docker.io/node:current AS isso-js-testbed
FROM docker.io/node:22-bookworm AS isso-js-testbed
WORKDIR /src/

# Install everything necessary to run headless
Expand Down
Binary file modified isso/js/tests/screenshots/reference/comment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion isso/js/tests/screenshots/reference/comment.png.hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
065f2dfac1c6bc174c8406e574f8890d3bb867b13407809eb9aec184f97c172d
56314990cb566160044f46033a7bd0c4d8be5bb41afa44fa54cf156aed21bbe3
Binary file modified isso/js/tests/screenshots/reference/postbox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion isso/js/tests/screenshots/reference/postbox.png.hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0eb72a0e3faaf65c373383e9cfe9359de37e31c7f0e6e38c2b2369eb85f0eba4
a218440951dbc7312118647c955d0d4480fc46bb6dddd72e0d9459744b471f32
Binary file modified isso/js/tests/screenshots/reference/thread.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion isso/js/tests/screenshots/reference/thread.png.hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3185d06957e792d48d28b47c3e2c7e89353aa8d70757d4c92890d38850a66e54
78ea677962d3f80607995d9b88d81df2b7787832023cb7f1d64811829d0fc10a

0 comments on commit ac9fb0d

Please sign in to comment.