diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml new file mode 100644 index 0000000000..8f844f63bf --- /dev/null +++ b/.github/workflows/docker-test.yml @@ -0,0 +1,55 @@ +# ----------------------------------------------------------------------------- +# Copyright 2024, Siemens AG +# Part of the SW360 Project. +# +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# SPDX-FileCopyrightText: 2024, Siemens AG +# SPDX-FileContributor: Gaurav Mishra +# +# ----------------------------------------------------------------------------- + +name: Docker test + +on: + pull_request + +env: + REGISTRY: ghcr.io + +permissions: + contents: read + +jobs: + docker-test: + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + with: + egress-policy: audit + + - name: Checkout main repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1 + + - name: Login to GitHub Container Registry + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build images + run: ./docker_build.sh + + - name: Test cluster + run: ./utils/test-cluster.sh diff --git a/utils/test-cluster.sh b/utils/test-cluster.sh new file mode 100755 index 0000000000..c499987e91 --- /dev/null +++ b/utils/test-cluster.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# SPDX-FileCopyrightText: © 2024 Siemens AG +# SPDX-FileContributor: Gaurav Mishra +# SPDX-License-Identifier: EPL-2.0 + +set -o errexit -o nounset -o xtrace + +docker compose up -d + +#### Sleep for Tomcat to start +sleep 15 + +readonly HOST="127.0.0.1:8080" + +#### Check health endpoint +curl --silent --location "http://${HOST}/resource/api/health" | grep -q '"status":"UP"' +curl --silent --location "http://${HOST}/resource/api/health" | grep -q '"isDbReachable":true' +curl --silent --location "http://${HOST}/resource/api/health" | grep -q '"isThriftReachable":true' + +docker compose down