Make test run faster && onboarding PR test as well
Some checks failed
Test Renovate Config / e2e-renovate (pull_request) Failing after 2m44s
Some checks failed
Test Renovate Config / e2e-renovate (pull_request) Failing after 2m44s
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user