From e09ed170d7977550e27b087ed1daebc608544bf3 Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 14:03:24 +0100 Subject: [PATCH 01/21] Added renovate tests --- .gitea/workflows/test-config.yaml | 20 +++++++++++++++++++ scripts/test-renovate.sh | 32 +++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 .gitea/workflows/test-config.yaml create mode 100755 scripts/test-renovate.sh diff --git a/.gitea/workflows/test-config.yaml b/.gitea/workflows/test-config.yaml new file mode 100644 index 0000000..207442e --- /dev/null +++ b/.gitea/workflows/test-config.yaml @@ -0,0 +1,20 @@ +name: Test Renovate Config +on: + push: + pull_request: + +jobs: + test-renovate: + runs-on: ubuntu-latest + container: ghcr.io/renovatebot/renovate:42.8.1 + steps: + - name: Checkout + uses: actions/checkout@v5.0.0 + + - name: Run Renovate Test Script + run: bash scripts/test-renovate.sh + env: + RENOVATE_CONFIG_FILE: "/workspace/kovagoadi.hu/Renovate/renovate-config.js" + LOG_LEVEL: "debug" + RENOVATE_TOKEN: ${{ secrets.RENOVATE_TEST_TOKEN }} + GITHUB_COM_TOKEN: ${{ secrets.RENOVATE_GITHUB_TOKEN }} diff --git a/scripts/test-renovate.sh b/scripts/test-renovate.sh new file mode 100755 index 0000000..37388ef --- /dev/null +++ b/scripts/test-renovate.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -e + +echo "Validating Renovate configuration..." +renovate-config-validator + +echo "Running Renovate dry-run..." +renovate --dry-run=full > renovate-output.log 2>&1 +cat renovate-output.log + +# Assertions +echo "Checking for successful run..." +if ! grep -q "Repository finished" renovate-output.log; then + echo "Error: Renovate run did not finish successfully." + exit 1 +fi + +echo "Checking for errors..." +if grep -q "ERROR" renovate-output.log; then + echo "Error: Renovate log contains errors." + exit 1 +fi + +# Example assertion: Check if a specific dependency update is planned +# echo "Checking for expected update..." +# if ! grep -q "update-dependency" renovate-output.log; then +# echo "Error: Expected dependency update not found." +# exit 1 +# fi + +echo "Test passed!" +rm renovate-output.log -- 2.49.1 From 4853c7d5ca861d5b0f6175e3b59aceacf208f45c Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 14:11:51 +0100 Subject: [PATCH 02/21] Added assertions --- scripts/test-renovate.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/test-renovate.sh b/scripts/test-renovate.sh index 37388ef..45d1227 100755 --- a/scripts/test-renovate.sh +++ b/scripts/test-renovate.sh @@ -21,12 +21,18 @@ if grep -q "ERROR" renovate-output.log; then exit 1 fi -# Example assertion: Check if a specific dependency update is planned -# echo "Checking for expected update..." -# if ! grep -q "update-dependency" renovate-output.log; then -# echo "Error: Expected dependency update not found." -# exit 1 -# fi +# Specific assertions based on the test repo state +echo "Checking for expected nginx update..." +if ! grep -q "renovate/nginx-1.x" renovate-output.log; then + echo "Error: Expected 'renovate/nginx-1.x' branch not found in output." + exit 1 +fi + +echo "Checking for onboarding PR..." +if ! grep -q "Would create onboarding PR" renovate-output.log; then + echo "Error: Expected onboarding PR creation not found." + exit 1 +fi echo "Test passed!" rm renovate-output.log -- 2.49.1 From afb5a7e9e976d63882b3740639218e1b06950150 Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 14:14:44 +0100 Subject: [PATCH 03/21] Test fail --- renovate-config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/renovate-config.js b/renovate-config.js index fdad5fd..4ca2c3c 100644 --- a/renovate-config.js +++ b/renovate-config.js @@ -5,6 +5,6 @@ module.exports = { extends: ['config:recommended'], pinDigests: true, }, - autodiscover: true, + autodiscover: false, }; -- 2.49.1 From 37f1542427be29300275ecface6eb473afa7c776 Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 14:26:46 +0100 Subject: [PATCH 04/21] Modified stuff --- .gitea/workflows/test-config.yaml | 2 ++ renovate-config.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/test-config.yaml b/.gitea/workflows/test-config.yaml index 207442e..5274b9e 100644 --- a/.gitea/workflows/test-config.yaml +++ b/.gitea/workflows/test-config.yaml @@ -1,6 +1,8 @@ name: Test Renovate Config on: push: + branches: + - main pull_request: jobs: diff --git a/renovate-config.js b/renovate-config.js index 4ca2c3c..fdad5fd 100644 --- a/renovate-config.js +++ b/renovate-config.js @@ -5,6 +5,6 @@ module.exports = { extends: ['config:recommended'], pinDigests: true, }, - autodiscover: false, + autodiscover: true, }; -- 2.49.1 From 09efcb9e1a62711113a746b075174a373b1cd3eb Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 14:41:14 +0100 Subject: [PATCH 05/21] Added more tests --- scripts/test-renovate.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/test-renovate.sh b/scripts/test-renovate.sh index 45d1227..c0e7729 100755 --- a/scripts/test-renovate.sh +++ b/scripts/test-renovate.sh @@ -28,6 +28,24 @@ if ! grep -q "renovate/nginx-1.x" renovate-output.log; then exit 1 fi +echo "Checking for nginx PR title..." +if ! grep -q "Update nginx Docker tag to v1.29.3" renovate-output.log; then + echo "Error: Expected PR title 'Update nginx Docker tag to v1.29.3' not found." + exit 1 +fi + +echo "Checking for expected actions/checkout update..." +if ! grep -q "renovate/actions-checkout-6.x" renovate-output.log; then + echo "Error: Expected 'renovate/actions-checkout-6.x' branch not found in output." + exit 1 +fi + +echo "Checking for actions/checkout PR title..." +if ! grep -q "Update actions/checkout action to v6" renovate-output.log; then + echo "Error: Expected PR title 'Update actions/checkout action to v6' not found." + exit 1 +fi + echo "Checking for onboarding PR..." if ! grep -q "Would create onboarding PR" renovate-output.log; then echo "Error: Expected onboarding PR creation not found." -- 2.49.1 From c6a7d755db5421020331d4eac9b2afe8155f9c9b Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 15:02:11 +0100 Subject: [PATCH 06/21] Fixed test versions --- scripts/test-renovate.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/test-renovate.sh b/scripts/test-renovate.sh index c0e7729..8824dff 100755 --- a/scripts/test-renovate.sh +++ b/scripts/test-renovate.sh @@ -23,26 +23,26 @@ fi # Specific assertions based on the test repo state echo "Checking for expected nginx update..." -if ! grep -q "renovate/nginx-1.x" renovate-output.log; then - echo "Error: Expected 'renovate/nginx-1.x' branch not found in output." +if ! grep -q "renovate/nginx-" renovate-output.log; then + echo "Error: Expected 'renovate/nginx-' branch not found in output." exit 1 fi echo "Checking for nginx PR title..." -if ! grep -q "Update nginx Docker tag to v1.29.3" renovate-output.log; then - echo "Error: Expected PR title 'Update nginx Docker tag to v1.29.3' not found." +if ! grep -q "Update nginx Docker tag to" renovate-output.log; then + echo "Error: Expected PR title 'Update nginx Docker tag to...' not found." exit 1 fi echo "Checking for expected actions/checkout update..." -if ! grep -q "renovate/actions-checkout-6.x" renovate-output.log; then - echo "Error: Expected 'renovate/actions-checkout-6.x' branch not found in output." +if ! grep -q "renovate/actions-checkout-" renovate-output.log; then + echo "Error: Expected 'renovate/actions-checkout-' branch not found in output." exit 1 fi echo "Checking for actions/checkout PR title..." -if ! grep -q "Update actions/checkout action to v6" renovate-output.log; then - echo "Error: Expected PR title 'Update actions/checkout action to v6' not found." +if ! grep -q "Update actions/checkout action to" renovate-output.log; then + echo "Error: Expected PR title 'Update actions/checkout action to...' not found." exit 1 fi -- 2.49.1 From 0402941668eb0e58484370439243a464688b8da2 Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 15:04:16 +0100 Subject: [PATCH 07/21] Added e2e test --- .gitea/workflows/e2e-test.yaml | 25 ++++++++ scripts/e2e-renovate.sh | 109 +++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 .gitea/workflows/e2e-test.yaml create mode 100755 scripts/e2e-renovate.sh diff --git a/.gitea/workflows/e2e-test.yaml b/.gitea/workflows/e2e-test.yaml new file mode 100644 index 0000000..3cbdd41 --- /dev/null +++ b/.gitea/workflows/e2e-test.yaml @@ -0,0 +1,25 @@ +name: E2E Renovate Test +on: + workflow_run: + workflows: ["Test Renovate Config"] + types: + - completed + +jobs: + e2e-renovate: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + container: ghcr.io/renovatebot/renovate:42.8.1 + steps: + - name: Checkout + uses: actions/checkout@v5.0.0 + with: + ref: ${{ github.event.workflow_run.head_branch }} + + - name: Run Renovate E2E Script + run: bash scripts/e2e-renovate.sh + env: + RENOVATE_CONFIG_FILE: "/workspace/kovagoadi.hu/Renovate/renovate-config.js" + LOG_LEVEL: "debug" + RENOVATE_TOKEN: ${{ secrets.RENOVATE_TEST_TOKEN }} + GITHUB_COM_TOKEN: ${{ secrets.RENOVATE_GITHUB_TOKEN }} diff --git a/scripts/e2e-renovate.sh b/scripts/e2e-renovate.sh new file mode 100755 index 0000000..c42b40c --- /dev/null +++ b/scripts/e2e-renovate.sh @@ -0,0 +1,109 @@ +#!/bin/bash +set -e + +echo "Validating Renovate configuration..." +renovate-config-validator + +echo "Running Renovate E2E (no dry-run)..." +# Capture output but also stream it to stdout for debugging +renovate > renovate-e2e-output.log 2>&1 +cat renovate-e2e-output.log + +# Assertions +echo "Checking for successful run..." +if ! grep -q "Repository finished" renovate-e2e-output.log; then + echo "Error: Renovate run did not finish successfully." + exit 1 +fi + +echo "Checking for errors..." +if grep -q "ERROR" renovate-e2e-output.log; then + echo "Error: Renovate log contains errors." + exit 1 +fi + +echo "E2E Test passed!" +rm renovate-e2e-output.log + +# API Verification and Cleanup +GITEA_API_URL="https://gitea.kovagoadi.hu/api/v1" +REPO_OWNER="renovate-test" +REPO_NAME="test" + +# Function to clean up PRs +cleanup() { + echo "Cleaning up PRs..." + # Get all open PRs/issues created by the bot (or just all open ones in this test repo) + # Note: In a real scenario, we might want to filter by author, but for this honeypot repo, all open PRs are fair game. + PRS=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/pulls?state=open") + + # Check if jq is installed, if not, try to install or use python + if ! command -v jq &> /dev/null; then + echo "jq not found, attempting to install..." + # Attempt to install jq (assuming debian/ubuntu based container) + if [ -w /var/lib/apt/lists ]; then + apt-get update && apt-get install -y jq + else + # Download static binary if no root + curl -L -o jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 + chmod +x jq + export PATH=$PATH:$PWD + fi + fi + + # Extract PR indexes + PR_INDEXES=$(echo "$PRS" | jq -r '.[].number') + + for INDEX in $PR_INDEXES; do + if [ "$INDEX" != "null" ]; then + echo "Deleting PR #$INDEX..." + curl -s -X DELETE -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$INDEX" + fi + done +} + +# Register cleanup to run on exit +trap cleanup EXIT + +echo "Verifying PR creation and content via API..." +# We expect PRs for nginx and actions/checkout +# Fetch PRs again to verify +PRS=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/pulls?state=open") + +# Verify Nginx PR +NGINX_PR_NUM=$(echo "$PRS" | jq -r '.[] | select(.title | contains("Update nginx Docker tag")) | .number') +if [ -n "$NGINX_PR_NUM" ] && [ "$NGINX_PR_NUM" != "null" ]; then + echo "API Verification: Nginx PR found (#$NGINX_PR_NUM)." + + # Verify Content + DIFF=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/pulls/$NGINX_PR_NUM.diff") + if echo "$DIFF" | grep -q "nginx:1.29.3"; then + echo "Content Verification: Nginx version update found in diff." + else + echo "Content Verification Failed: Nginx version update NOT found in diff." + exit 1 + fi +else + echo "API Verification Failed: Nginx PR not found." + exit 1 +fi + +# Verify Actions/Checkout PR +ACTIONS_PR_NUM=$(echo "$PRS" | jq -r '.[] | select(.title | contains("Update actions/checkout action")) | .number') +if [ -n "$ACTIONS_PR_NUM" ] && [ "$ACTIONS_PR_NUM" != "null" ]; then + echo "API Verification: Actions/Checkout PR found (#$ACTIONS_PR_NUM)." + + # Verify Content + DIFF=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/pulls/$ACTIONS_PR_NUM.diff") + if echo "$DIFF" | grep -q "actions/checkout@v6"; then + echo "Content Verification: Actions/Checkout version update found in diff." + else + echo "Content Verification Failed: Actions/Checkout version update NOT found in diff." + exit 1 + fi +else + echo "API Verification Failed: Actions/Checkout PR not found." + exit 1 +fi + +echo "API & Content Verification passed!" -- 2.49.1 From 61bf6f74e146793cbc087983c924868326ee7682 Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 15:09:20 +0100 Subject: [PATCH 08/21] Move workflow --- .gitea/workflows/e2e-test.yaml | 25 ------------------------- .gitea/workflows/test-config.yaml | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 25 deletions(-) delete mode 100644 .gitea/workflows/e2e-test.yaml diff --git a/.gitea/workflows/e2e-test.yaml b/.gitea/workflows/e2e-test.yaml deleted file mode 100644 index 3cbdd41..0000000 --- a/.gitea/workflows/e2e-test.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: E2E Renovate Test -on: - workflow_run: - workflows: ["Test Renovate Config"] - types: - - completed - -jobs: - e2e-renovate: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - container: ghcr.io/renovatebot/renovate:42.8.1 - steps: - - name: Checkout - uses: actions/checkout@v5.0.0 - with: - ref: ${{ github.event.workflow_run.head_branch }} - - - name: Run Renovate E2E Script - run: bash scripts/e2e-renovate.sh - env: - RENOVATE_CONFIG_FILE: "/workspace/kovagoadi.hu/Renovate/renovate-config.js" - LOG_LEVEL: "debug" - RENOVATE_TOKEN: ${{ secrets.RENOVATE_TEST_TOKEN }} - GITHUB_COM_TOKEN: ${{ secrets.RENOVATE_GITHUB_TOKEN }} diff --git a/.gitea/workflows/test-config.yaml b/.gitea/workflows/test-config.yaml index 5274b9e..1113a26 100644 --- a/.gitea/workflows/test-config.yaml +++ b/.gitea/workflows/test-config.yaml @@ -20,3 +20,19 @@ jobs: LOG_LEVEL: "debug" RENOVATE_TOKEN: ${{ secrets.RENOVATE_TEST_TOKEN }} GITHUB_COM_TOKEN: ${{ secrets.RENOVATE_GITHUB_TOKEN }} + + e2e-renovate: + runs-on: ubuntu-latest + needs: test-renovate + container: ghcr.io/renovatebot/renovate:42.8.1 + steps: + - name: Checkout + uses: actions/checkout@v5.0.0 + + - name: Run Renovate E2E Script + run: bash scripts/e2e-renovate.sh + env: + RENOVATE_CONFIG_FILE: "/workspace/kovagoadi.hu/Renovate/renovate-config.js" + LOG_LEVEL: "debug" + RENOVATE_TOKEN: ${{ secrets.RENOVATE_TEST_TOKEN }} + GITHUB_COM_TOKEN: ${{ secrets.RENOVATE_GITHUB_TOKEN }} -- 2.49.1 From 0cfc699af7df4646e3ccfde8ce287b75d8a35780 Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 15:12:38 +0100 Subject: [PATCH 09/21] Added debugging --- scripts/e2e-renovate.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/e2e-renovate.sh b/scripts/e2e-renovate.sh index c42b40c..2b6fe1f 100755 --- a/scripts/e2e-renovate.sh +++ b/scripts/e2e-renovate.sh @@ -6,9 +6,18 @@ renovate-config-validator echo "Running Renovate E2E (no dry-run)..." # Capture output but also stream it to stdout for debugging +set +e renovate > renovate-e2e-output.log 2>&1 +RENOVATE_EXIT_CODE=$? +set -e + cat renovate-e2e-output.log +if [ $RENOVATE_EXIT_CODE -ne 0 ]; then + echo "Error: Renovate command failed with exit code $RENOVATE_EXIT_CODE" + exit 1 +fi + # Assertions echo "Checking for successful run..." if ! grep -q "Repository finished" renovate-e2e-output.log; then -- 2.49.1 From 425a6fa692c9f17ff75da49e69df01562e2bf919 Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 15:28:29 +0100 Subject: [PATCH 10/21] Make test run faster && onboarding PR test as well --- .gitea/workflows/test-config.yaml | 28 +++++----- scripts/e2e-renovate.sh | 93 +++++++++++++++++++++++-------- scripts/test-renovate.sh | 92 +++++++++++++++--------------- 3 files changed, 129 insertions(+), 84 deletions(-) diff --git a/.gitea/workflows/test-config.yaml b/.gitea/workflows/test-config.yaml index 1113a26..272823b 100644 --- a/.gitea/workflows/test-config.yaml +++ b/.gitea/workflows/test-config.yaml @@ -6,24 +6,24 @@ on: pull_request: jobs: - test-renovate: - runs-on: ubuntu-latest - container: ghcr.io/renovatebot/renovate:42.8.1 - steps: - - name: Checkout - uses: actions/checkout@v5.0.0 + # test-renovate: + # runs-on: ubuntu-latest + # container: ghcr.io/renovatebot/renovate:42.8.1 + # steps: + # - name: Checkout + # uses: actions/checkout@v5.0.0 - - name: Run Renovate Test Script - run: bash scripts/test-renovate.sh - env: - RENOVATE_CONFIG_FILE: "/workspace/kovagoadi.hu/Renovate/renovate-config.js" - LOG_LEVEL: "debug" - RENOVATE_TOKEN: ${{ secrets.RENOVATE_TEST_TOKEN }} - GITHUB_COM_TOKEN: ${{ secrets.RENOVATE_GITHUB_TOKEN }} + # - name: Run Renovate Test Script + # run: bash scripts/test-renovate.sh + # env: + # RENOVATE_CONFIG_FILE: "/workspace/kovagoadi.hu/Renovate/renovate-config.js" + # LOG_LEVEL: "debug" + # RENOVATE_TOKEN: ${{ secrets.RENOVATE_TEST_TOKEN }} + # GITHUB_COM_TOKEN: ${{ secrets.RENOVATE_GITHUB_TOKEN }} e2e-renovate: runs-on: ubuntu-latest - needs: test-renovate + # needs: test-renovate container: ghcr.io/renovatebot/renovate:42.8.1 steps: - name: Checkout diff --git a/scripts/e2e-renovate.sh b/scripts/e2e-renovate.sh index 2b6fe1f..f284596 100755 --- a/scripts/e2e-renovate.sh +++ b/scripts/e2e-renovate.sh @@ -39,44 +39,89 @@ GITEA_API_URL="https://gitea.kovagoadi.hu/api/v1" REPO_OWNER="renovate-test" REPO_NAME="test" -# Function to clean up PRs +# Function to clean up PRs and reset repo cleanup() { - echo "Cleaning up PRs..." - # Get all open PRs/issues created by the bot (or just all open ones in this test repo) - # Note: In a real scenario, we might want to filter by author, but for this honeypot repo, all open PRs are fair game. - PRS=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/pulls?state=open") + echo "Cleaning up..." - # Check if jq is installed, if not, try to install or use python - if ! command -v jq &> /dev/null; then - echo "jq not found, attempting to install..." - # Attempt to install jq (assuming debian/ubuntu based container) - if [ -w /var/lib/apt/lists ]; then - apt-get update && apt-get install -y jq - else - # Download static binary if no root - curl -L -o jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 - chmod +x jq - export PATH=$PATH:$PWD - fi - fi - - # Extract PR indexes + # 1. Delete all Open PRs + PRS=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/pulls?state=open") PR_INDEXES=$(echo "$PRS" | jq -r '.[].number') - for INDEX in $PR_INDEXES; do if [ "$INDEX" != "null" ]; then echo "Deleting PR #$INDEX..." curl -s -X DELETE -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$INDEX" fi done + + # 2. Delete renovate.json from main branch to reset state (if exists) + FILE_INFO=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/contents/renovate.json?ref=main") + FILE_SHA=$(echo "$FILE_INFO" | jq -r '.sha') + + if [ "$FILE_SHA" != "null" ] && [ -n "$FILE_SHA" ]; then + echo "Deleting renovate.json to reset repository state..." + curl -s -X DELETE -H "Authorization: token $RENOVATE_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"message\": \"Cleanup: Delete renovate.json\", \"sha\": \"$FILE_SHA\", \"branch\": \"main\"}" \ + "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/contents/renovate.json" + fi } # Register cleanup to run on exit trap cleanup EXIT -echo "Verifying PR creation and content via API..." -# We expect PRs for nginx and actions/checkout -# Fetch PRs again to verify +# --- Step 1: Initial Run (Onboarding) --- +echo "Running Renovate E2E (Run 1: Onboarding)..." +set +e +renovate > renovate-e2e-output.log 2>&1 +RENOVATE_EXIT_CODE=$? +set -e +cat renovate-e2e-output.log + +if [ $RENOVATE_EXIT_CODE -ne 0 ]; then + echo "Error: Renovate command failed." + exit 1 +fi + +# Check for Onboarding PR +PRS=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/pulls?state=open") +ONBOARDING_PR_NUM=$(echo "$PRS" | jq -r '.[] | select(.title | contains("Configure Renovate")) | .number') + +if [ -n "$ONBOARDING_PR_NUM" ] && [ "$ONBOARDING_PR_NUM" != "null" ]; then + echo "Onboarding PR found (#$ONBOARDING_PR_NUM). Merging it to enable updates..." + + # Merge Onboarding PR + MERGE_RESP=$(curl -s -X POST -H "Authorization: token $RENOVATE_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"Do\": \"merge\"}" \ + "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/pulls/$ONBOARDING_PR_NUM/merge") + + # Check if merge was successful (simple check) + if echo "$MERGE_RESP" | grep -q "Pull request has been merged"; then + echo "Onboarding PR merged successfully." + else + # Fallback: check status code or response + echo "Merge response: $MERGE_RESP" + fi + + # --- Step 2: Second Run (Updates) --- + echo "Running Renovate E2E (Run 2: Updates)..." + set +e + renovate > renovate-e2e-output-2.log 2>&1 + RENOVATE_EXIT_CODE=$? + set -e + cat renovate-e2e-output-2.log + + if [ $RENOVATE_EXIT_CODE -ne 0 ]; then + echo "Error: Renovate command (Run 2) failed." + exit 1 + fi + +else + echo "No Onboarding PR found. Assuming repo is already onboarded or config exists." +fi + +echo "Verifying Update PRs and Content..." +# Fetch PRs again PRS=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/pulls?state=open") # Verify Nginx PR diff --git a/scripts/test-renovate.sh b/scripts/test-renovate.sh index 8824dff..2308ec7 100755 --- a/scripts/test-renovate.sh +++ b/scripts/test-renovate.sh @@ -1,56 +1,56 @@ -#!/bin/bash -set -e +# #!/bin/bash +# set -e -echo "Validating Renovate configuration..." -renovate-config-validator +# echo "Validating Renovate configuration..." +# renovate-config-validator -echo "Running Renovate dry-run..." -renovate --dry-run=full > renovate-output.log 2>&1 -cat renovate-output.log +# echo "Running Renovate dry-run..." +# renovate --dry-run=full > renovate-output.log 2>&1 +# cat renovate-output.log -# Assertions -echo "Checking for successful run..." -if ! grep -q "Repository finished" renovate-output.log; then - echo "Error: Renovate run did not finish successfully." - exit 1 -fi +# # Assertions +# echo "Checking for successful run..." +# if ! grep -q "Repository finished" renovate-output.log; then +# echo "Error: Renovate run did not finish successfully." +# exit 1 +# fi -echo "Checking for errors..." -if grep -q "ERROR" renovate-output.log; then - echo "Error: Renovate log contains errors." - exit 1 -fi +# echo "Checking for errors..." +# if grep -q "ERROR" renovate-output.log; then +# echo "Error: Renovate log contains errors." +# exit 1 +# fi -# Specific assertions based on the test repo state -echo "Checking for expected nginx update..." -if ! grep -q "renovate/nginx-" renovate-output.log; then - echo "Error: Expected 'renovate/nginx-' branch not found in output." - exit 1 -fi +# # Specific assertions based on the test repo state +# echo "Checking for expected nginx update..." +# if ! grep -q "renovate/nginx-" renovate-output.log; then +# echo "Error: Expected 'renovate/nginx-' branch not found in output." +# exit 1 +# fi -echo "Checking for nginx PR title..." -if ! grep -q "Update nginx Docker tag to" renovate-output.log; then - echo "Error: Expected PR title 'Update nginx Docker tag to...' not found." - exit 1 -fi +# echo "Checking for nginx PR title..." +# if ! grep -q "Update nginx Docker tag to" renovate-output.log; then +# echo "Error: Expected PR title 'Update nginx Docker tag to...' not found." +# exit 1 +# fi -echo "Checking for expected actions/checkout update..." -if ! grep -q "renovate/actions-checkout-" renovate-output.log; then - echo "Error: Expected 'renovate/actions-checkout-' branch not found in output." - exit 1 -fi +# echo "Checking for expected actions/checkout update..." +# if ! grep -q "renovate/actions-checkout-" renovate-output.log; then +# echo "Error: Expected 'renovate/actions-checkout-' branch not found in output." +# exit 1 +# fi -echo "Checking for actions/checkout PR title..." -if ! grep -q "Update actions/checkout action to" renovate-output.log; then - echo "Error: Expected PR title 'Update actions/checkout action to...' not found." - exit 1 -fi +# echo "Checking for actions/checkout PR title..." +# if ! grep -q "Update actions/checkout action to" renovate-output.log; then +# echo "Error: Expected PR title 'Update actions/checkout action to...' not found." +# exit 1 +# fi -echo "Checking for onboarding PR..." -if ! grep -q "Would create onboarding PR" renovate-output.log; then - echo "Error: Expected onboarding PR creation not found." - exit 1 -fi +# echo "Checking for onboarding PR..." +# if ! grep -q "Would create onboarding PR" renovate-output.log; then +# echo "Error: Expected onboarding PR creation not found." +# exit 1 +# fi -echo "Test passed!" -rm renovate-output.log +# echo "Test passed!" +# rm renovate-output.log -- 2.49.1 From bbd592710f74564dc748ebc50e9aecdc9b6a834a Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 15:38:31 +0100 Subject: [PATCH 11/21] Add pr hourly limit --- scripts/e2e-renovate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/e2e-renovate.sh b/scripts/e2e-renovate.sh index f284596..f927b46 100755 --- a/scripts/e2e-renovate.sh +++ b/scripts/e2e-renovate.sh @@ -72,7 +72,7 @@ trap cleanup EXIT # --- Step 1: Initial Run (Onboarding) --- echo "Running Renovate E2E (Run 1: Onboarding)..." set +e -renovate > renovate-e2e-output.log 2>&1 +renovate --pr-hourly-limit=0 > renovate-e2e-output.log 2>&1 RENOVATE_EXIT_CODE=$? set -e cat renovate-e2e-output.log @@ -106,7 +106,7 @@ if [ -n "$ONBOARDING_PR_NUM" ] && [ "$ONBOARDING_PR_NUM" != "null" ]; then # --- Step 2: Second Run (Updates) --- echo "Running Renovate E2E (Run 2: Updates)..." set +e - renovate > renovate-e2e-output-2.log 2>&1 + renovate --pr-hourly-limit=0 > renovate-e2e-output-2.log 2>&1 RENOVATE_EXIT_CODE=$? set -e cat renovate-e2e-output-2.log -- 2.49.1 From 7476a7e5bfcb4ee25ee81c196cb29ed78bc96223 Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 15:52:00 +0100 Subject: [PATCH 12/21] Added more testing and cleanup --- scripts/e2e-renovate.sh | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/scripts/e2e-renovate.sh b/scripts/e2e-renovate.sh index f927b46..de330fe 100755 --- a/scripts/e2e-renovate.sh +++ b/scripts/e2e-renovate.sh @@ -44,6 +44,7 @@ cleanup() { echo "Cleaning up..." # 1. Delete all Open PRs + echo "Deleting Open PRs..." PRS=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/pulls?state=open") PR_INDEXES=$(echo "$PRS" | jq -r '.[].number') for INDEX in $PR_INDEXES; do @@ -53,7 +54,41 @@ cleanup() { fi done - # 2. Delete renovate.json from main branch to reset state (if exists) + # 2. Delete "Configure Renovate" PR (Closed/Merged) + echo "Deleting 'Configure Renovate' PR..." + # Fetch closed PRs to find the onboarding one + CLOSED_PRS=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/pulls?state=closed") + ONBOARDING_PR_INDEX=$(echo "$CLOSED_PRS" | jq -r '.[] | select(.title | contains("Configure Renovate")) | .number') + if [ -n "$ONBOARDING_PR_INDEX" ] && [ "$ONBOARDING_PR_INDEX" != "null" ]; then + echo "Deleting Onboarding PR #$ONBOARDING_PR_INDEX..." + curl -s -X DELETE -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$ONBOARDING_PR_INDEX" + fi + + # 3. Delete "Dependency Dashboard" Issue + echo "Deleting 'Dependency Dashboard' Issue..." + ISSUES=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/issues?state=open") + DASHBOARD_INDEX=$(echo "$ISSUES" | jq -r '.[] | select(.title | contains("Dependency Dashboard")) | .number') + if [ -n "$DASHBOARD_INDEX" ] && [ "$DASHBOARD_INDEX" != "null" ]; then + echo "Deleting Dashboard Issue #$DASHBOARD_INDEX..." + curl -s -X DELETE -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$DASHBOARD_INDEX" + fi + + # 4. Delete Renovate Branches + echo "Deleting Renovate Branches..." + BRANCHES=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/branches") + RENOVATE_BRANCHES=$(echo "$BRANCHES" | jq -r '.[].name | select(startswith("renovate/"))') + for BRANCH in $RENOVATE_BRANCHES; do + if [ -n "$BRANCH" ]; then + echo "Deleting branch $BRANCH..." + # URL encode branch name (slash needs to be %2F, but curl might handle it or we need to be careful) + # Gitea API: DELETE /repos/{owner}/{repo}/branches/{branch} + # Simple bash URL encoding for slash + ENCODED_BRANCH=${BRANCH//\//%2F} + curl -s -X DELETE -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/branches/$ENCODED_BRANCH" + fi + done + + # 5. Delete renovate.json from main branch to reset state (if exists) FILE_INFO=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/contents/renovate.json?ref=main") FILE_SHA=$(echo "$FILE_INFO" | jq -r '.sha') @@ -160,4 +195,16 @@ else exit 1 fi +# Verify Dependency Dashboard Issue +echo "Verifying Dependency Dashboard..." +ISSUES=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/issues?state=open") +DASHBOARD_NUM=$(echo "$ISSUES" | jq -r '.[] | select(.title | contains("Dependency Dashboard")) | .number') + +if [ -n "$DASHBOARD_NUM" ] && [ "$DASHBOARD_NUM" != "null" ]; then + echo "API Verification: Dependency Dashboard found (#$DASHBOARD_NUM)." +else + echo "API Verification Failed: Dependency Dashboard NOT found." + exit 1 +fi + echo "API & Content Verification passed!" -- 2.49.1 From 4895885b280c7fe666e7540616ce107bddf09af7 Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 15:59:12 +0100 Subject: [PATCH 13/21] No cleanup after run --- scripts/e2e-renovate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/e2e-renovate.sh b/scripts/e2e-renovate.sh index de330fe..a7fa970 100755 --- a/scripts/e2e-renovate.sh +++ b/scripts/e2e-renovate.sh @@ -102,7 +102,7 @@ cleanup() { } # Register cleanup to run on exit -trap cleanup EXIT +# trap cleanup EXIT # --- Step 1: Initial Run (Onboarding) --- echo "Running Renovate E2E (Run 1: Onboarding)..." -- 2.49.1 From 12898ef47eac2ec89bcb571ae8e923902dc0d386 Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 16:07:26 +0100 Subject: [PATCH 14/21] Fix tests --- scripts/e2e-renovate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/e2e-renovate.sh b/scripts/e2e-renovate.sh index a7fa970..e758e85 100755 --- a/scripts/e2e-renovate.sh +++ b/scripts/e2e-renovate.sh @@ -166,7 +166,7 @@ if [ -n "$NGINX_PR_NUM" ] && [ "$NGINX_PR_NUM" != "null" ]; then # Verify Content DIFF=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/pulls/$NGINX_PR_NUM.diff") - if echo "$DIFF" | grep -q "nginx:1.29.3"; then + if echo "$DIFF" | grep -q "nginx:1.27.5"; then echo "Content Verification: Nginx version update found in diff." else echo "Content Verification Failed: Nginx version update NOT found in diff." @@ -184,7 +184,7 @@ if [ -n "$ACTIONS_PR_NUM" ] && [ "$ACTIONS_PR_NUM" != "null" ]; then # Verify Content DIFF=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/pulls/$ACTIONS_PR_NUM.diff") - if echo "$DIFF" | grep -q "actions/checkout@v6"; then + if echo "$DIFF" | grep -q "actions/checkout@v4"; then echo "Content Verification: Actions/Checkout version update found in diff." else echo "Content Verification Failed: Actions/Checkout version update NOT found in diff." -- 2.49.1 From 75d46ea2774b81a676d2dc72a02f608acb30e055 Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 16:10:52 +0100 Subject: [PATCH 15/21] Add cleanup --- scripts/e2e-renovate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/e2e-renovate.sh b/scripts/e2e-renovate.sh index e758e85..e0b6c59 100755 --- a/scripts/e2e-renovate.sh +++ b/scripts/e2e-renovate.sh @@ -102,7 +102,7 @@ cleanup() { } # Register cleanup to run on exit -# trap cleanup EXIT +trap cleanup EXIT # --- Step 1: Initial Run (Onboarding) --- echo "Running Renovate E2E (Run 1: Onboarding)..." -- 2.49.1 From 4bdd1320c2c95ec8b585ecd81a6a2bc286ba5135 Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 16:20:47 +0100 Subject: [PATCH 16/21] Added back dry-run test --- .gitea/workflows/test-config.yaml | 26 ++++----- scripts/test-renovate.sh | 92 +++++++++++++++---------------- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/.gitea/workflows/test-config.yaml b/.gitea/workflows/test-config.yaml index 272823b..73eef42 100644 --- a/.gitea/workflows/test-config.yaml +++ b/.gitea/workflows/test-config.yaml @@ -6,20 +6,20 @@ on: pull_request: jobs: - # test-renovate: - # runs-on: ubuntu-latest - # container: ghcr.io/renovatebot/renovate:42.8.1 - # steps: - # - name: Checkout - # uses: actions/checkout@v5.0.0 + test-renovate: + runs-on: ubuntu-latest + container: ghcr.io/renovatebot/renovate:42.8.1 + steps: + - name: Checkout + uses: actions/checkout@v5.0.0 - # - name: Run Renovate Test Script - # run: bash scripts/test-renovate.sh - # env: - # RENOVATE_CONFIG_FILE: "/workspace/kovagoadi.hu/Renovate/renovate-config.js" - # LOG_LEVEL: "debug" - # RENOVATE_TOKEN: ${{ secrets.RENOVATE_TEST_TOKEN }} - # GITHUB_COM_TOKEN: ${{ secrets.RENOVATE_GITHUB_TOKEN }} + - name: Run Renovate Test Script + run: bash scripts/test-renovate.sh + env: + RENOVATE_CONFIG_FILE: "/workspace/kovagoadi.hu/Renovate/renovate-config.js" + LOG_LEVEL: "debug" + RENOVATE_TOKEN: ${{ secrets.RENOVATE_TEST_TOKEN }} + GITHUB_COM_TOKEN: ${{ secrets.RENOVATE_GITHUB_TOKEN }} e2e-renovate: runs-on: ubuntu-latest diff --git a/scripts/test-renovate.sh b/scripts/test-renovate.sh index 2308ec7..8824dff 100755 --- a/scripts/test-renovate.sh +++ b/scripts/test-renovate.sh @@ -1,56 +1,56 @@ -# #!/bin/bash -# set -e +#!/bin/bash +set -e -# echo "Validating Renovate configuration..." -# renovate-config-validator +echo "Validating Renovate configuration..." +renovate-config-validator -# echo "Running Renovate dry-run..." -# renovate --dry-run=full > renovate-output.log 2>&1 -# cat renovate-output.log +echo "Running Renovate dry-run..." +renovate --dry-run=full > renovate-output.log 2>&1 +cat renovate-output.log -# # Assertions -# echo "Checking for successful run..." -# if ! grep -q "Repository finished" renovate-output.log; then -# echo "Error: Renovate run did not finish successfully." -# exit 1 -# fi +# Assertions +echo "Checking for successful run..." +if ! grep -q "Repository finished" renovate-output.log; then + echo "Error: Renovate run did not finish successfully." + exit 1 +fi -# echo "Checking for errors..." -# if grep -q "ERROR" renovate-output.log; then -# echo "Error: Renovate log contains errors." -# exit 1 -# fi +echo "Checking for errors..." +if grep -q "ERROR" renovate-output.log; then + echo "Error: Renovate log contains errors." + exit 1 +fi -# # Specific assertions based on the test repo state -# echo "Checking for expected nginx update..." -# if ! grep -q "renovate/nginx-" renovate-output.log; then -# echo "Error: Expected 'renovate/nginx-' branch not found in output." -# exit 1 -# fi +# Specific assertions based on the test repo state +echo "Checking for expected nginx update..." +if ! grep -q "renovate/nginx-" renovate-output.log; then + echo "Error: Expected 'renovate/nginx-' branch not found in output." + exit 1 +fi -# echo "Checking for nginx PR title..." -# if ! grep -q "Update nginx Docker tag to" renovate-output.log; then -# echo "Error: Expected PR title 'Update nginx Docker tag to...' not found." -# exit 1 -# fi +echo "Checking for nginx PR title..." +if ! grep -q "Update nginx Docker tag to" renovate-output.log; then + echo "Error: Expected PR title 'Update nginx Docker tag to...' not found." + exit 1 +fi -# echo "Checking for expected actions/checkout update..." -# if ! grep -q "renovate/actions-checkout-" renovate-output.log; then -# echo "Error: Expected 'renovate/actions-checkout-' branch not found in output." -# exit 1 -# fi +echo "Checking for expected actions/checkout update..." +if ! grep -q "renovate/actions-checkout-" renovate-output.log; then + echo "Error: Expected 'renovate/actions-checkout-' branch not found in output." + exit 1 +fi -# echo "Checking for actions/checkout PR title..." -# if ! grep -q "Update actions/checkout action to" renovate-output.log; then -# echo "Error: Expected PR title 'Update actions/checkout action to...' not found." -# exit 1 -# fi +echo "Checking for actions/checkout PR title..." +if ! grep -q "Update actions/checkout action to" renovate-output.log; then + echo "Error: Expected PR title 'Update actions/checkout action to...' not found." + exit 1 +fi -# echo "Checking for onboarding PR..." -# if ! grep -q "Would create onboarding PR" renovate-output.log; then -# echo "Error: Expected onboarding PR creation not found." -# exit 1 -# fi +echo "Checking for onboarding PR..." +if ! grep -q "Would create onboarding PR" renovate-output.log; then + echo "Error: Expected onboarding PR creation not found." + exit 1 +fi -# echo "Test passed!" -# rm renovate-output.log +echo "Test passed!" +rm renovate-output.log -- 2.49.1 From 0e8bdec8c29050bb35b8d0fe03acfb8cbcc3d500 Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 16:21:25 +0100 Subject: [PATCH 17/21] Added back needs as well --- .gitea/workflows/test-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/test-config.yaml b/.gitea/workflows/test-config.yaml index 73eef42..1113a26 100644 --- a/.gitea/workflows/test-config.yaml +++ b/.gitea/workflows/test-config.yaml @@ -23,7 +23,7 @@ jobs: e2e-renovate: runs-on: ubuntu-latest - # needs: test-renovate + needs: test-renovate container: ghcr.io/renovatebot/renovate:42.8.1 steps: - name: Checkout -- 2.49.1 From 32124d999f8bec6b101be3e01c2e6c7f8fb7664d Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 16:32:19 +0100 Subject: [PATCH 18/21] Add onboarding testing for test-renovate workflow --- scripts/test-renovate.sh | 125 +++++++++++++++++++++++++++++++-------- 1 file changed, 100 insertions(+), 25 deletions(-) diff --git a/scripts/test-renovate.sh b/scripts/test-renovate.sh index 8824dff..ec4ebcc 100755 --- a/scripts/test-renovate.sh +++ b/scripts/test-renovate.sh @@ -1,56 +1,131 @@ #!/bin/bash set -e +# Configuration +GITEA_API_URL="https://gitea.kovagoadi.hu/api/v1" +REPO_OWNER="renovate-test" +REPO_NAME="test" +RENOVATE_CONFIG_FILE=${RENOVATE_CONFIG_FILE:-"/workspace/kovagoadi.hu/Renovate/renovate-config.js"} + +# Ensure RENOVATE_TOKEN is available +if [ -z "$RENOVATE_TOKEN" ]; then + echo "Error: RENOVATE_TOKEN is not set." + exit 1 +fi + +# Cleanup function +cleanup() { + echo "Cleaning up..." + # Delete renovate.json from main branch if it exists (to reset state) + FILE_INFO=$(curl -s -H "Authorization: token $RENOVATE_TOKEN" "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/contents/renovate.json?ref=main") + FILE_SHA=$(echo "$FILE_INFO" | jq -r '.sha') + + if [ "$FILE_SHA" != "null" ] && [ -n "$FILE_SHA" ]; then + echo "Deleting renovate.json to reset repository state..." + curl -s -X DELETE -H "Authorization: token $RENOVATE_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"message\": \"Cleanup: Delete renovate.json\", \"sha\": \"$FILE_SHA\", \"branch\": \"main\"}" \ + "$GITEA_API_URL/repos/$REPO_OWNER/$REPO_NAME/contents/renovate.json" + fi + rm -f renovate-output-pre.log renovate-output-post.log +} + +# Register cleanup to run on exit +trap cleanup EXIT + echo "Validating Renovate configuration..." renovate-config-validator -echo "Running Renovate dry-run..." -renovate --dry-run=full > renovate-output.log 2>&1 -cat renovate-output.log +# --- Phase 1: Pre-Onboarding Dry-Run --- +echo "Running Renovate dry-run (Phase 1: Pre-Onboarding)..." +# Ensure repo is clean first +cleanup -# Assertions -echo "Checking for successful run..." -if ! grep -q "Repository finished" renovate-output.log; then - echo "Error: Renovate run did not finish successfully." +set +e +renovate --dry-run=full > renovate-output-pre.log 2>&1 +RENOVATE_EXIT_CODE=$? +set -e +cat renovate-output-pre.log + +if [ $RENOVATE_EXIT_CODE -ne 0 ]; then + echo "Error: Renovate dry-run (Phase 1) failed." exit 1 fi -echo "Checking for errors..." -if grep -q "ERROR" renovate-output.log; then - echo "Error: Renovate log contains errors." +echo "Checking for onboarding PR in Phase 1..." +if ! grep -q "Would create onboarding PR" renovate-output-pre.log; then + echo "Error: Expected 'Would create onboarding PR' not found in Phase 1 output." + exit 1 +fi +echo "Phase 1 Passed: Onboarding PR detected." + +# --- Phase 2: Onboarding Simulation --- +echo "Simulating Onboarding..." +# Content of renovate.json (base64 encoded for API if needed, but Gitea API takes content string) +# We'll use a simple config similar to the repo's renovate.json +CONTENT=$(cat < renovate-output-post.log 2>&1 +RENOVATE_EXIT_CODE=$? +set -e +cat renovate-output-post.log + +if [ $RENOVATE_EXIT_CODE -ne 0 ]; then + echo "Error: Renovate dry-run (Phase 3) failed." + exit 1 +fi + +# Specific assertions based on the test repo state (now onboarded) echo "Checking for expected nginx update..." -if ! grep -q "renovate/nginx-" renovate-output.log; then - echo "Error: Expected 'renovate/nginx-' branch not found in output." +if ! grep -q "renovate/nginx-" renovate-output-post.log; then + echo "Error: Expected 'renovate/nginx-' branch not found in Phase 3 output." exit 1 fi echo "Checking for nginx PR title..." -if ! grep -q "Update nginx Docker tag to" renovate-output.log; then +if ! grep -q "Update nginx Docker tag to" renovate-output-post.log; then echo "Error: Expected PR title 'Update nginx Docker tag to...' not found." exit 1 fi echo "Checking for expected actions/checkout update..." -if ! grep -q "renovate/actions-checkout-" renovate-output.log; then - echo "Error: Expected 'renovate/actions-checkout-' branch not found in output." +if ! grep -q "renovate/actions-checkout-" renovate-output-post.log; then + echo "Error: Expected 'renovate/actions-checkout-' branch not found in Phase 3 output." exit 1 fi echo "Checking for actions/checkout PR title..." -if ! grep -q "Update actions/checkout action to" renovate-output.log; then +if ! grep -q "Update actions/checkout action to" renovate-output-post.log; then echo "Error: Expected PR title 'Update actions/checkout action to...' not found." exit 1 fi -echo "Checking for onboarding PR..." -if ! grep -q "Would create onboarding PR" renovate-output.log; then - echo "Error: Expected onboarding PR creation not found." - exit 1 -fi - -echo "Test passed!" -rm renovate-output.log +echo "Phase 3 Passed: Update PRs detected." +echo "All Dry-Run Tests Passed!" -- 2.49.1 From d8bf62e321a3f3999864a9fe05deef0bf8d91233 Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 16:54:44 +0100 Subject: [PATCH 19/21] Added concurrency option --- .gitea/workflows/test-config.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitea/workflows/test-config.yaml b/.gitea/workflows/test-config.yaml index 1113a26..b74df79 100644 --- a/.gitea/workflows/test-config.yaml +++ b/.gitea/workflows/test-config.yaml @@ -5,6 +5,10 @@ on: - main pull_request: +concurrency: + group: renovate-test-lock + cancel-in-progress: false + jobs: test-renovate: runs-on: ubuntu-latest -- 2.49.1 From e6183b7078c08142ef1762d6057fae65a05004e7 Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 17:02:09 +0100 Subject: [PATCH 20/21] Added branch restriction --- .gitea/workflows/test-config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitea/workflows/test-config.yaml b/.gitea/workflows/test-config.yaml index b74df79..fdcb5c6 100644 --- a/.gitea/workflows/test-config.yaml +++ b/.gitea/workflows/test-config.yaml @@ -4,6 +4,8 @@ on: branches: - main pull_request: + branches: + - main concurrency: group: renovate-test-lock -- 2.49.1 From 09ebf1065b0367d26305bd77c16109717b2e0a3d Mon Sep 17 00:00:00 2001 From: kovagoadi Date: Sat, 22 Nov 2025 17:03:27 +0100 Subject: [PATCH 21/21] Renamed file --- .gitea/workflows/{test-config.yaml => test.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .gitea/workflows/{test-config.yaml => test.yaml} (100%) diff --git a/.gitea/workflows/test-config.yaml b/.gitea/workflows/test.yaml similarity index 100% rename from .gitea/workflows/test-config.yaml rename to .gitea/workflows/test.yaml -- 2.49.1