File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 - main
77
88jobs :
9- generate-matrix :
9+ detect-changes :
1010 runs-on : ubuntu-latest
1111 outputs :
12- matrix : ${{ steps.generate-matrix .outputs.matrix }}
12+ matrix : ${{ steps.detect-changes .outputs.matrix }}
1313 steps :
1414 - uses : actions/checkout@v4
15+ with :
16+ fetch-depth : 2
1517
16- - name : Generate matrix
17- id : generate-matrix
18+ - name : Detect changed files
19+ id : detect-changes
1820 run : |
19- dirs=$(find baekjoon/python -mindepth 1 -maxdepth 1 -type d)
21+ if git rev-parse HEAD~1 >/dev/null 2>&1; then
22+ base_commit="HEAD~1"
23+ else
24+ base_commit="HEAD"
25+ fi
26+
27+ changed_dirs=$(git diff --name-only $base_commit HEAD | grep '^baekjoon/python' | awk -F'/' '{print $1"/"$2"/"$3}' | sort -u || true)
28+
2029 json="["
21- for dir in $dirs; do
22- json+="\"$dir\","
30+ for dir in $changed_dirs; do
31+ if [ -d "$dir" ]; then
32+ json+="\"$dir\","
33+ fi
2334 done
2435 json="${json%,}]"
36+
2537 echo "matrix=$json" >> $GITHUB_OUTPUT
2638 shell : bash
2739
2840 run-tests :
29- needs : generate-matrix
41+ needs : detect-changes
3042 runs-on : ubuntu-latest
43+ if : needs.detect-changes.outputs.matrix != '[]'
3144 strategy :
3245 matrix :
33- dir : ${{ fromJson(needs.generate-matrix .outputs.matrix) }}
46+ dir : ${{ fromJson(needs.detect-changes .outputs.matrix) }}
3447 steps :
3548 - uses : actions/checkout@v4
3649
4659
4760 - name : Run Tests
4861 run : |
49- pytest ${{ matrix.dir }}/test_main.py
62+ pytest ${{ matrix.dir }}/test_main.py
You can’t perform that action at this time.
0 commit comments