Skip to content

Commit ba5a187

Browse files
authored
Run subtest based on file change (#1710)
* run subtest based on file change * trigger all tests * trigger all tests on release * macos support * internal files as well
1 parent 5beb3fb commit ba5a187

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

.github/workflows/test.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ jobs:
4747
git config --global core.eol lf
4848
- name: Checkout code
4949
uses: actions/checkout@v3
50+
with:
51+
fetch-depth: 0
5052
- name: Install Go
5153
uses: actions/setup-go@v3
5254
with:
@@ -69,7 +71,23 @@ jobs:
6971
run: echo ("TF_ACC_TERRAFORM_PATH=" + (Get-Command terraform).Path) >> $env:GITHUB_ENV
7072
- name: Check Docs Are Up To Date
7173
run: make check-docs
74+
- name: Set regex for tests to run
75+
shell: bash
76+
run: |
77+
test_re=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- datadog/*.go datadog/*/*.go datadog/internal/* go.mod go.sum | \
78+
sed 's/.*_datadog_\(.*\).*.go/\1/' | sed 's/.*\/.*\/\(.*\).*.go/\1/' | \
79+
sed -E 's+test|_++g' | \
80+
sed -e "s/\(.*\)/\\(?i\\)\1/" | \
81+
xargs | sed -e 's/ /|/g')
82+
83+
if [[ "$test_re" =~ go.mod|go.sum|provider ]] || [[ ${{ github.head_ref }} = release/* ]]; then
84+
echo TESTARGS="-run \".*\"" >> $GITHUB_ENV
85+
elif [[ ! -z "$test_re" ]]; then
86+
echo TESTARGS="-run \"${test_re}\"" >> $GITHUB_ENV
87+
fi
7288
- name: Test
73-
run: make testall
89+
shell: bash
90+
run: |
91+
[[ -z "${TESTARGS}" ]] && echo "Skipping tests" || make testall
7492
env:
7593
RECORD: false

0 commit comments

Comments
 (0)