Skip to content

Commit 14889a0

Browse files
Implement prod testing
1 parent e6dc648 commit 14889a0

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Test Autoupdate Action on Real Repo
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
test-autoupdate:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout this repo
11+
uses: actions/checkout@v4
12+
13+
- name: Checkout target repo (autoupdate-action-unstable)
14+
uses: actions/checkout@v4
15+
with:
16+
repository: CSSUoB/autoupdate-action-unstable
17+
token: ${{ secrets.PR_AUTO_UPDATE_TOKEN }}
18+
path: autoupdate-action-unstable
19+
20+
- name: Run test logic
21+
env:
22+
GH_TOKEN: ${{ secrets.PR_AUTO_UPDATE_TOKEN }}
23+
run: |
24+
cd autoupdate-action-unstable
25+
git checkout main
26+
git pull
27+
git config user.name "cssbhamdev"
28+
git config user.email "66796201+cssbhamdev@users.noreply.github.com"
29+
# Create a branch with no conflict
30+
git checkout -b test-non-conflict
31+
NON_CONFLICT_FILE="non_conflict.txt"
32+
echo "non-conflict change $(date)" >> "$NON_CONFLICT_FILE"
33+
git add "$NON_CONFLICT_FILE"
34+
git commit -m "Non-conflicting change"
35+
git push origin test-non-conflict
36+
# Create a branch with a conflict
37+
git checkout main
38+
git pull
39+
git checkout -b test-conflict
40+
CONFLICT_FILE="conflict.txt"
41+
echo "conflict change $(date)" > "$CONFLICT_FILE"
42+
git add "$CONFLICT_FILE"
43+
git commit -m "Conflicting change"
44+
git push origin test-conflict
45+
# Simulate a conflict: change the same file on main
46+
git checkout main
47+
echo "main branch change $(date)" > "$CONFLICT_FILE"
48+
git add "$CONFLICT_FILE"
49+
git commit -m "Main branch conflicting change"
50+
git push origin main
51+
# Open PRs using gh CLI
52+
gh pr create --base main --head test-non-conflict --title "Test Non-Conflict" --body "Testing non-conflicting PR" --repo "CSSUoB/autoupdate-action-unstable" --label "sync"
53+
gh pr create --base main --head test-conflict --title "Test Conflict" --body "Testing conflicting PR" --repo "CSSUoB/autoupdate-action-unstable" --label "sync"
54+
# Wait for autoupdate action to run (adjust sleep as needed)
55+
sleep 120
56+
# Get PR numbers
57+
NON_CONFLICT_PR=$(gh pr list --head test-non-conflict --json number --jq '.[0].number' --repo "CSSUoB/autoupdate-action-unstable")
58+
CONFLICT_PR=$(gh pr list --head test-conflict --json number --jq '.[0].number' --repo "CSSUoB/autoupdate-action-unstable")
59+
# Check if non-conflicting PR is mergeable (should be true)
60+
NON_CONFLICT_STATUS=$(gh pr view "$NON_CONFLICT_PR" --json mergeable --jq '.mergeable' --repo "CSSUoB/autoupdate-action-unstable")
61+
if [[ "$NON_CONFLICT_STATUS" != "MERGEABLE" ]]; then
62+
echo "Non-conflicting PR is not mergeable"
63+
exit 1
64+
fi
65+
# Check if conflicting PR is labelled as conflict
66+
CONFLICT_LABELS=$(gh pr view "$CONFLICT_PR" --json labels --jq '.labels[].name' --repo "CSSUoB/autoupdate-action-unstable")
67+
if ! echo "$CONFLICT_LABELS" | grep -q "conflict"; then
68+
echo "Conflicting PR is not labelled as conflict"
69+
exit 1
70+
fi
71+
echo "Test passed: Non-conflicting PR is mergeable and conflicting PR is labelled"

0 commit comments

Comments
 (0)