Added e2e test
All checks were successful
Test Renovate Config / test-renovate (pull_request) Successful in 48s

This commit is contained in:
2025-11-22 15:04:16 +01:00
parent c6a7d755db
commit 0402941668
2 changed files with 134 additions and 0 deletions

View File

@@ -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 }}

109
scripts/e2e-renovate.sh Executable file
View File

@@ -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!"