mirror of
https://github.com/selfxyz/self.git
synced 2026-01-07 22:04:03 -05:00
Enhance GitHub workflows to conditionally run tests based on file changes. Added checks for 'circuits' in circuits.yml and 'contracts' or 'common' in contracts.yml to determine if tests should execute on dev branch. This avoids too wide changelist in trigger filter that is problematic
This commit is contained in:
29
.github/workflows/circuits.yml
vendored
29
.github/workflows/circuits.yml
vendored
@@ -5,11 +5,34 @@ on:
|
||||
- dev
|
||||
- staging
|
||||
- main
|
||||
paths:
|
||||
- "circuits/**"
|
||||
jobs:
|
||||
check_changes:
|
||||
runs-on: ubuntu-slim
|
||||
outputs:
|
||||
should_run: ${{ steps.filter.outputs.should_run }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Check if should run
|
||||
id: filter
|
||||
run: |
|
||||
if [[ "${{ github.base_ref }}" == "main" ]] || [[ "${{ github.base_ref }}" == "staging" ]]; then
|
||||
echo "should_run=true" >> $GITHUB_OUTPUT
|
||||
echo "Running for ${{ github.base_ref }} - no path filter"
|
||||
else
|
||||
# For dev branch, check if circuits files changed
|
||||
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -q "^circuits/"; then
|
||||
echo "should_run=true" >> $GITHUB_OUTPUT
|
||||
echo "Running for dev - circuits files changed"
|
||||
else
|
||||
echo "should_run=false" >> $GITHUB_OUTPUT
|
||||
echo "Skipping for dev - no circuits files changed"
|
||||
fi
|
||||
fi
|
||||
|
||||
run_circuit_tests:
|
||||
if: github.event.pull_request.draft == false
|
||||
needs: check_changes
|
||||
if: github.event.pull_request.draft == false && needs.check_changes.outputs.should_run == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
environment: development
|
||||
permissions:
|
||||
|
||||
30
.github/workflows/contracts.yml
vendored
30
.github/workflows/contracts.yml
vendored
@@ -5,17 +5,39 @@ on:
|
||||
- dev
|
||||
- staging
|
||||
- main
|
||||
paths:
|
||||
- "contracts/**"
|
||||
- "common/**"
|
||||
|
||||
concurrency:
|
||||
group: contracts-ci-${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check_changes:
|
||||
runs-on: ubuntu-slim
|
||||
outputs:
|
||||
should_run: ${{ steps.filter.outputs.should_run }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Check if should run
|
||||
id: filter
|
||||
run: |
|
||||
if [[ "${{ github.base_ref }}" == "main" ]] || [[ "${{ github.base_ref }}" == "staging" ]]; then
|
||||
echo "should_run=true" >> $GITHUB_OUTPUT
|
||||
echo "Running for ${{ github.base_ref }} - no path filter"
|
||||
else
|
||||
# For dev branch, check if contracts or common files changed
|
||||
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -qE "^(contracts|common)/"; then
|
||||
echo "should_run=true" >> $GITHUB_OUTPUT
|
||||
echo "Running for dev - contracts or common files changed"
|
||||
else
|
||||
echo "should_run=false" >> $GITHUB_OUTPUT
|
||||
echo "Skipping for dev - no contracts or common files changed"
|
||||
fi
|
||||
fi
|
||||
|
||||
test_contracts:
|
||||
if: github.event.pull_request.draft == false
|
||||
needs: check_changes
|
||||
if: github.event.pull_request.draft == false && needs.check_changes.outputs.should_run == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
environment: development
|
||||
steps:
|
||||
|
||||
Reference in New Issue
Block a user