From dd7f952091843b1a8de5b4dd86c621f4d6f100fa Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Wed, 11 Sep 2024 17:45:00 +0200 Subject: [PATCH 1/7] Create test.yml --- .github/workflows/test.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..82ea6ff --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,23 @@ +name: test + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: prepare .env + run: cp env.sample .env + - name: Build the Docker image + run: docker compose up -d + - name: Test if RHDH is running + run: curl https://localhost:7007 + From a0553f0b5af3625eb10c9bc69c7b8fc4bfbc6755 Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Wed, 11 Sep 2024 18:07:21 +0200 Subject: [PATCH 2/7] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 82ea6ff..868b4e1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,5 +19,5 @@ jobs: - name: Build the Docker image run: docker compose up -d - name: Test if RHDH is running - run: curl https://localhost:7007 + run: curl -k https://localhost:7007 From 1e56ef41310fe5d47c101faeb88b2d7b4d3ba8e5 Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Thu, 12 Sep 2024 12:42:50 +0200 Subject: [PATCH 3/7] Update test.yml --- .github/workflows/test.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 868b4e1..4243bd5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,19 @@ jobs: run: cp env.sample .env - name: Build the Docker image run: docker compose up -d - - name: Test if RHDH is running - run: curl -k https://localhost:7007 - + - name: Wait for HTTP 200 response + run: | + URL="https://localhost:7007" + TIMEOUT=120 + SLEEP=5 + start_time=$(date +%s) + while [ $(( $(date +%s) - start_time )) -lt $TIMEOUT ]; do + if [ "$(curl -o /dev/null -s -w '%{http_code}' $URL)" -eq 200 ]; then + echo "HTTP 200 OK" + exit 0 + fi + echo "Waiting for HTTP 200..." + sleep $SLEEP + done + echo "Timeout exceeded" + exit 1 From 1114d8fc41ac85024e7230b98cd12633d69abbe6 Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Thu, 12 Sep 2024 15:06:15 +0200 Subject: [PATCH 4/7] Update test.yml --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4243bd5..e9e57b1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: - name: Wait for HTTP 200 response run: | URL="https://localhost:7007" - TIMEOUT=120 + TIMEOUT=240 SLEEP=5 start_time=$(date +%s) while [ $(( $(date +%s) - start_time )) -lt $TIMEOUT ]; do @@ -29,6 +29,7 @@ jobs: echo "HTTP 200 OK" exit 0 fi + curl $URL echo "Waiting for HTTP 200..." sleep $SLEEP done From d96b678002895639a68a7c61f0ff8ab446bc264e Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Thu, 12 Sep 2024 15:36:28 +0200 Subject: [PATCH 5/7] Update test.yml --- .github/workflows/test.yml | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e9e57b1..27e8d7a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,17 +21,31 @@ jobs: - name: Wait for HTTP 200 response run: | URL="https://localhost:7007" - TIMEOUT=240 - SLEEP=5 + TIMEOUT=240 # Max time to wait in seconds + SLEEP=5 # Time to wait between checks in seconds + start_time=$(date +%s) - while [ $(( $(date +%s) - start_time )) -lt $TIMEOUT ]; do - if [ "$(curl -o /dev/null -s -w '%{http_code}' $URL)" -eq 200 ]; then - echo "HTTP 200 OK" + + while true; do + # Send a request to the URL and get the status code + STATUS=$(curl -o /dev/null -s -w "%{http_code}" "$URL") + + # Check if the status code is 200 + if [ "$STATUS" -eq 200 ]; then + echo "Success: HTTP 200 OK received from $URL" exit 0 fi - curl $URL - echo "Waiting for HTTP 200..." - sleep $SLEEP + + # Check if the timeout has been exceeded + current_time=$(date +%s) + elapsed_time=$((current_time - start_time)) + + if [ "$elapsed_time" -ge "$TIMEOUT" ]; then + echo "Error: Timeout of $TIMEOUT seconds exceeded. Last status: $STATUS" + exit 1 + fi + + # Wait for a while before checking again + echo "Waiting for HTTP 200... Current status: $STATUS" + sleep "$SLEEP" done - echo "Timeout exceeded" - exit 1 From bf6e871520b1a828571024bec95e3a7c2235db81 Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Thu, 12 Sep 2024 15:39:59 +0200 Subject: [PATCH 6/7] Update test.yml --- .github/workflows/test.yml | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 27e8d7a..f4c5723 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,33 +19,9 @@ jobs: - name: Build the Docker image run: docker compose up -d - name: Wait for HTTP 200 response - run: | - URL="https://localhost:7007" - TIMEOUT=240 # Max time to wait in seconds - SLEEP=5 # Time to wait between checks in seconds - - start_time=$(date +%s) - - while true; do - # Send a request to the URL and get the status code - STATUS=$(curl -o /dev/null -s -w "%{http_code}" "$URL") - - # Check if the status code is 200 - if [ "$STATUS" -eq 200 ]; then - echo "Success: HTTP 200 OK received from $URL" - exit 0 - fi - - # Check if the timeout has been exceeded - current_time=$(date +%s) - elapsed_time=$((current_time - start_time)) - - if [ "$elapsed_time" -ge "$TIMEOUT" ]; then - echo "Error: Timeout of $TIMEOUT seconds exceeded. Last status: $STATUS" - exit 1 - fi - - # Wait for a while before checking again - echo "Waiting for HTTP 200... Current status: $STATUS" - sleep "$SLEEP" - done + uses: cygnetdigital/wait_for_response@v2.0.0 + with: + url: 'https://localhost:7007/' + responseCode: '200' + timeout: 2000 + interval: 500 From 3888eeb24b157dfcca7ad04b5f389d81f54883b6 Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Tue, 1 Oct 2024 17:48:03 +0200 Subject: [PATCH 7/7] test --- .github/workflows/test.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f4c5723..19eef27 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,9 +19,16 @@ jobs: - name: Build the Docker image run: docker compose up -d - name: Wait for HTTP 200 response - uses: cygnetdigital/wait_for_response@v2.0.0 - with: - url: 'https://localhost:7007/' - responseCode: '200' - timeout: 2000 - interval: 500 + run: | + max=30 + i=0 + echo "Waiting for localhost to respond with status code 200..." + until curl --insecure --head --fail https://localhost:7007; do + i=$((i+1)) + if [ "$i" -ge "$max" ]; then + echo "Max retries reached. Exiting." + exit 1 + echo "($i/$max)Waiting for https://localhost:7007 to return HTTP 200..." + sleep 5 + done + echo "RHDH is ready!"