feat(ci): skip redundant tests on PR merge
Tests only run on: - Pull requests (CI checks) - Direct pushes to main - Manual workflow dispatch PR merges skip tests (already passed) but still trigger version bump.
This commit is contained in:
parent
957dd988dc
commit
54f2d98723
1 changed files with 62 additions and 4 deletions
66
.github/workflows/test-agents.yml
vendored
66
.github/workflows/test-agents.yml
vendored
|
|
@ -12,9 +12,57 @@ on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
# Check if this is a PR merge commit (skip tests if so - they already ran on PR)
|
||||||
|
check-trigger:
|
||||||
|
name: Check Trigger Type
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
should_test: ${{ steps.check.outputs.should_test }}
|
||||||
|
should_bump: ${{ steps.check.outputs.should_bump }}
|
||||||
|
steps:
|
||||||
|
- name: Determine if tests should run
|
||||||
|
id: check
|
||||||
|
run: |
|
||||||
|
# For PRs, always run tests
|
||||||
|
if [ "${{ github.event_name }}" == "pull_request" ]; then
|
||||||
|
echo "should_test=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "should_bump=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "PR detected - will run tests"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For workflow_dispatch, always run tests
|
||||||
|
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
||||||
|
echo "should_test=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "should_bump=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "Manual trigger - will run tests"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For push events, check if it's a PR merge
|
||||||
|
COMMIT_MSG="${{ github.event.head_commit.message }}"
|
||||||
|
|
||||||
|
# PR merges have messages like "Merge pull request #123" or contain (#123)
|
||||||
|
if echo "$COMMIT_MSG" | grep -qE "^Merge pull request #|^.*\(#[0-9]+\)$"; then
|
||||||
|
echo "should_test=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "should_bump=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "PR merge detected - skipping tests, will bump version"
|
||||||
|
# Skip version bump commits
|
||||||
|
elif echo "$COMMIT_MSG" | grep -qE "^\[skip ci\]|chore: bump version"; then
|
||||||
|
echo "should_test=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "should_bump=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "Version bump commit - skipping everything"
|
||||||
|
else
|
||||||
|
echo "should_test=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "should_bump=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "Direct push detected - will run tests and bump version"
|
||||||
|
fi
|
||||||
|
|
||||||
test-openagent:
|
test-openagent:
|
||||||
name: Test OpenAgent
|
name: Test OpenAgent
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: check-trigger
|
||||||
|
if: needs.check-trigger.outputs.should_test == 'true'
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -65,6 +113,8 @@ jobs:
|
||||||
test-opencoder:
|
test-opencoder:
|
||||||
name: Test OpenCoder
|
name: Test OpenCoder
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: check-trigger
|
||||||
|
if: needs.check-trigger.outputs.should_test == 'true'
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -115,8 +165,8 @@ jobs:
|
||||||
report-results:
|
report-results:
|
||||||
name: Report Test Results
|
name: Report Test Results
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [test-openagent, test-opencoder]
|
needs: [check-trigger, test-openagent, test-opencoder]
|
||||||
if: always()
|
if: always() && needs.check-trigger.outputs.should_test == 'true'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download OpenAgent results
|
- name: Download OpenAgent results
|
||||||
|
|
@ -152,8 +202,16 @@ jobs:
|
||||||
auto-version-bump:
|
auto-version-bump:
|
||||||
name: Auto Version Bump
|
name: Auto Version Bump
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [test-openagent, test-opencoder]
|
needs: [check-trigger, test-openagent, test-opencoder]
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
# Run version bump if:
|
||||||
|
# 1. Tests ran and passed, OR
|
||||||
|
# 2. This is a PR merge (tests already passed on PR)
|
||||||
|
if: |
|
||||||
|
github.event_name == 'push' &&
|
||||||
|
github.ref == 'refs/heads/main' &&
|
||||||
|
needs.check-trigger.outputs.should_bump == 'true' &&
|
||||||
|
(needs.check-trigger.outputs.should_test == 'false' ||
|
||||||
|
(needs.test-openagent.result == 'success' && needs.test-opencoder.result == 'success'))
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue