Skip to content

Commit 3cd47b0

Browse files
vaindclaude
andcommitted
refactor: improve danger workflow test readability and maintainability
Apply same cleanup principles to danger-workflow-tests.yml: ✨ Improvements: - Move assertion to same job as action execution - Clear job name describing test purpose - Replace cryptic one-liner with readable validation logic - Add informative error messages with debugging hints - Use environment variables for better readability - Remove unnecessary job dependencies 🎯 Benefits: - Faster feedback on test failures - Self-contained test that's easier to understand - Better error messages explaining what might be wrong - Consistent structure with updater workflow tests The test now clearly validates that Danger runs successfully on PRs and provides helpful debugging information when it fails. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 6b08377 commit 3cd47b0

File tree

2 files changed

+53
-56
lines changed

2 files changed

+53
-56
lines changed

.github/workflows/danger-workflow-tests.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,33 @@ permissions:
1111
issues: write
1212

1313
jobs:
14-
danger:
14+
# Test Danger action on pull requests - should analyze PR and report findings
15+
test-danger-pr-analysis:
1516
runs-on: ubuntu-latest
16-
outputs:
17-
outcome: ${{ steps.danger.outputs.outcome }}
1817
steps:
19-
- uses: actions/checkout@v4
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
2021
- name: Run danger action
2122
id: danger
2223
uses: ./danger
2324

24-
test-outputs:
25-
runs-on: ubuntu-latest
26-
needs: danger
27-
steps:
28-
- run: "[[ '${{ needs.danger.outputs.outcome }}' == 'success' ]]"
25+
- name: Validate danger outputs
26+
env:
27+
DANGER_OUTCOME: ${{ steps.danger.outputs.outcome }}
28+
run: |
29+
echo "🔍 Validating Danger action outputs..."
30+
echo "Danger Outcome: '$DANGER_OUTCOME'"
31+
32+
# Validate that Danger ran successfully
33+
if [[ "$DANGER_OUTCOME" != "success" ]]; then
34+
echo "❌ Expected Danger outcome 'success', got '$DANGER_OUTCOME'"
35+
echo "This could indicate:"
36+
echo " - Danger found issues that caused it to fail"
37+
echo " - The action itself encountered an error"
38+
echo " - Docker container issues"
39+
exit 1
40+
fi
41+
42+
echo "✅ Danger PR analysis completed successfully!"
43+
echo "ℹ️ Check the PR comments for any Danger findings"

.github/workflows/workflow-tests.yml

Lines changed: 29 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,11 @@ jobs:
1313
# Test PR creation scenario - should create a PR with specific version pattern
1414
test-updater-pr-creation:
1515
runs-on: ubuntu-latest
16-
outputs:
17-
prUrl: ${{ steps.updater.outputs.prUrl }}
18-
baseBranch: ${{ steps.updater.outputs.baseBranch }}
19-
prBranch: ${{ steps.updater.outputs.prBranch }}
20-
originalTag: ${{ steps.updater.outputs.originalTag }}
21-
latestTag: ${{ steps.updater.outputs.latestTag }}
2216
steps:
2317
- name: Checkout repository
2418
uses: actions/checkout@v4
2519

26-
- name: Test updater - PR creation scenario
20+
- name: Run updater action
2721
id: updater
2822
uses: ./updater
2923
with:
@@ -33,41 +27,13 @@ jobs:
3327
pr-strategy: update
3428
api-token: ${{ github.token }}
3529

36-
# Test no-change scenario - should detect no updates needed
37-
test-updater-no-changes:
38-
runs-on: macos-latest
39-
outputs:
40-
prUrl: ${{ steps.updater.outputs.prUrl }}
41-
baseBranch: ${{ steps.updater.outputs.baseBranch }}
42-
prBranch: ${{ steps.updater.outputs.prBranch }}
43-
originalTag: ${{ steps.updater.outputs.originalTag }}
44-
latestTag: ${{ steps.updater.outputs.latestTag }}
45-
steps:
46-
- name: Checkout repository
47-
uses: actions/checkout@v4
48-
49-
- name: Test updater - no changes scenario
50-
id: updater
51-
uses: ./updater
52-
with:
53-
path: updater/tests/workflow-args.sh
54-
name: Workflow args test script
55-
pattern: '.*'
56-
api-token: ${{ github.token }}
57-
58-
validate-test-outputs:
59-
runs-on: ubuntu-latest
60-
needs:
61-
- test-updater-pr-creation
62-
- test-updater-no-changes
63-
steps:
64-
- name: Validate PR creation scenario outputs
30+
- name: Validate PR creation outputs
6531
env:
66-
BASE_BRANCH: ${{ needs.test-updater-pr-creation.outputs.baseBranch }}
67-
ORIGINAL_TAG: ${{ needs.test-updater-pr-creation.outputs.originalTag }}
68-
LATEST_TAG: ${{ needs.test-updater-pr-creation.outputs.latestTag }}
69-
PR_URL: ${{ needs.test-updater-pr-creation.outputs.prUrl }}
70-
PR_BRANCH: ${{ needs.test-updater-pr-creation.outputs.prBranch }}
32+
BASE_BRANCH: ${{ steps.updater.outputs.baseBranch }}
33+
ORIGINAL_TAG: ${{ steps.updater.outputs.originalTag }}
34+
LATEST_TAG: ${{ steps.updater.outputs.latestTag }}
35+
PR_URL: ${{ steps.updater.outputs.prUrl }}
36+
PR_BRANCH: ${{ steps.updater.outputs.prBranch }}
7137
run: |
7238
echo "🔍 Validating PR creation scenario outputs..."
7339
echo "Base Branch: '$BASE_BRANCH'"
@@ -108,13 +74,29 @@ jobs:
10874
10975
echo "✅ PR creation scenario validation passed!"
11076
111-
- name: Validate no-changes scenario outputs
77+
# Test no-change scenario - should detect no updates needed
78+
test-updater-no-changes:
79+
runs-on: macos-latest
80+
steps:
81+
- name: Checkout repository
82+
uses: actions/checkout@v4
83+
84+
- name: Run updater action
85+
id: updater
86+
uses: ./updater
87+
with:
88+
path: updater/tests/workflow-args.sh
89+
name: Workflow args test script
90+
pattern: '.*'
91+
api-token: ${{ github.token }}
92+
93+
- name: Validate no-changes outputs
11294
env:
113-
BASE_BRANCH: ${{ needs.test-updater-no-changes.outputs.baseBranch }}
114-
ORIGINAL_TAG: ${{ needs.test-updater-no-changes.outputs.originalTag }}
115-
LATEST_TAG: ${{ needs.test-updater-no-changes.outputs.latestTag }}
116-
PR_URL: ${{ needs.test-updater-no-changes.outputs.prUrl }}
117-
PR_BRANCH: ${{ needs.test-updater-no-changes.outputs.prBranch }}
95+
BASE_BRANCH: ${{ steps.updater.outputs.baseBranch }}
96+
ORIGINAL_TAG: ${{ steps.updater.outputs.originalTag }}
97+
LATEST_TAG: ${{ steps.updater.outputs.latestTag }}
98+
PR_URL: ${{ steps.updater.outputs.prUrl }}
99+
PR_BRANCH: ${{ steps.updater.outputs.prBranch }}
118100
run: |
119101
echo "🔍 Validating no-changes scenario outputs..."
120102
echo "Base Branch: '$BASE_BRANCH'"

0 commit comments

Comments
 (0)