Skip to content

Commit 358b750

Browse files
chore: Adding workflow
Signed-off-by: Francisco Javier Arceo <[email protected]>
1 parent 6a59815 commit 358b750

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Check for Changes
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
base-sha:
7+
required: true
8+
type: string
9+
head-sha:
10+
required: true
11+
type: string
12+
excluded-dirs:
13+
required: false
14+
type: array
15+
default: ['docs/**', 'community/**', 'examples/**']
16+
17+
jobs:
18+
check-changes:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
skip_tests: ${{ steps.check_changes.outputs.skip_tests}}
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 2
28+
ref: ${{ inputs.head-sha }}
29+
30+
- name: Check for excluded directory changes
31+
id: check_changes
32+
run: |
33+
CHANGED_FILES=$(git diff --name-only ${{ inputs.base-sha }} ${{ inputs.head-sha }})
34+
echo "Changed files:"
35+
echo "$CHANGED_FILES"
36+
37+
# Join the excluded directories into a single pattern
38+
EXCLUDE_PATTERN=$(IFS='|'; echo "${{ inputs.excluded-dirs[*] }}")
39+
40+
# Check if any changed file matches the exclusion patterns
41+
NON_EXCLUDED_CHANGED=$(echo "$CHANGED_FILES" | grep -Ev "^($EXCLUDE_PATTERN)" || true)
42+
43+
if [[ -z "$NON_EXCLUDED_CHANGED" ]]; then
44+
echo "skip_tests=true" >> "$GITHUB_ENV"
45+
echo "::set-output name=skip_tests::true"
46+
else
47+
echo "skip_tests=false" >> "$GITHUB_ENV"
48+
echo "::set-output name=skip_tests::false"
49+
fi
50+

.github/workflows/unit_tests.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ on:
44
pull_request:
55

66
jobs:
7+
check-changes:
8+
uses: ./.github/workflows/check_skip_tests.yml
9+
with:
10+
base-sha: ${{ github.event.pull_request.base.sha }}
11+
head-sha: ${{ github.event.pull_request.head.sha }}
12+
excluded-dirs: ['docs/**', 'community/**', 'examples/**']
13+
id: check_changes
14+
715
unit-test-python:
8-
if: ${{ !contains(github.event.pull_request.files, 'docs/') }} # Skip if docs files changed
16+
if: ${{ steps.check_changes.outputs.skip-tests == 'false' }}
917
runs-on: ${{ matrix.os }}
1018
strategy:
1119
fail-fast: false
@@ -43,6 +51,7 @@ jobs:
4351
run: uv cache prune --ci
4452

4553
unit-test-ui:
54+
if: ${{ steps.check_changes.outputs.skip-tests == 'false' }}
4655
runs-on: ubuntu-latest
4756
env:
4857
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)