Commit 7a36164d authored by Nikos Psaromanolakis's avatar Nikos Psaromanolakis
Browse files

possible fix

parent 9c16633a
Loading
Loading
Loading
Loading
Loading
+38 −25
Changes for .gitlab-ci.yml: 38 added lines, 25 removed lines.
Original line number Diff line number Diff line
@@ -18,6 +18,20 @@ cache:
  stage: test
  timeout: 30 minutes

  tags:
    - hypo

  variables:
    CHROME_BIN: "/usr/bin/chromium"
    CHROMEDRIVER_BIN: "/usr/bin/chromedriver"

  .karate_test_template:
  stage: test
  timeout: 30 minutes

  # Overrides the global Ubuntu-based Maven image for these jobs.
  image: maven:3.9-eclipse-temurin-17-alpine

  tags:
    - hypo

@@ -28,23 +42,11 @@ cache:
  before_script:
    - mvn -version

    # Install Chromium and the matching ChromeDriver.
    - apt-get update -qq
    - >
      apt-get install
      -y
      -qq
      --no-install-recommends
      chromium
      chromium-driver
      curl
    # Install Chromium and its matching ChromeDriver.
    - apk add --no-cache chromium chromium-chromedriver

    # -------------------------------------------------------------
    # Fix the GitLab Runner hostname resolution problem.
    #
    # This addresses:
    # java.net.UnknownHostException:
    # runner-... Temporary failure in name resolution
    # Fix Java/Selenium resolution of the GitLab Runner hostname.
    # -------------------------------------------------------------
    - |
      RUNNER_HOSTNAME="$(hostname)"
@@ -53,22 +55,20 @@ cache:
      echo "Runner hostname: ${RUNNER_HOSTNAME}"
      echo "Runner IP: ${RUNNER_IP}"

      if ! getent hosts "${RUNNER_HOSTNAME}" > /dev/null 2>&1; then
      if ! grep -qE "(^|[[:space:]])${RUNNER_HOSTNAME}([[:space:]]|$)" /etc/hosts; then
        echo "${RUNNER_IP:-127.0.0.1} ${RUNNER_HOSTNAME}" >> /etc/hosts
      fi

      echo "Hostname resolution:"
      getent hosts "${RUNNER_HOSTNAME}"
      echo "Hostname mapping:"
      grep "${RUNNER_HOSTNAME}" /etc/hosts

    # Display browser and driver versions.
    # Verify browser and driver installation.
    - echo "Chromium path:" && command -v chromium
    - echo "ChromeDriver path:" && command -v chromedriver
    - chromium --version
    - chromedriver --version

    # Verify that both executables exist.
    - test -x "$CHROME_BIN"
    - test -x "$CHROMEDRIVER_BIN"

    # Verify that Chromium can start in the runner.
    # Verify that Chromium starts correctly in the CI container.
    - |
      chromium \
        --headless=new \
@@ -78,10 +78,11 @@ cache:
        about:blank \
        > /tmp/chromium-smoke-test.html

    # Maven preparation.
    - mvn -q validate
    - mvn -q test-compile

    # Validate the Karate syntax without executing the tests.
    # Optional syntax/dry-run validation.
    - mvn -q test "-Dkarate.options=--dryrun"

  script:
@@ -102,6 +103,18 @@ cache:
      junit:
        - target/surefire-reports/TEST-*.xml

  artifacts:
    when: always
    expire_in: 14 days

    paths:
      - target/karate-reports/
      - target/surefire-reports/

    reports:
      junit:
        - target/surefire-reports/TEST-*.xml

# 1) Smoke on Merge Requests
smoke:
  extends: .karate_test_template