-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore] Add scoped GH action to test affected components on Windows (#…
…37106) #### Description Many times changes that break Windows CI are merged since it is not apparent that they will break on Windows. Given the cost of running Windows CI for every PR the label `Run Windows` is only added in few cases. This change adds make targets that allow to run make commands only for tests and dependencies affected by files being changed. It uses a simple detection of go files that were changed and look to the import commands to find the components that depend directly on the package being changed. #### Link to tracking issue Relates to #36788 #### Testing Validated on my fork, e.g.: https://github.com/pjanotti/opentelemetry-service-contrib/actions/runs/12659871185 #### Documentation N/A
- Loading branch information
Showing
2 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: scoped-test | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
jobs: | ||
changedfiles: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.actor != 'dependabot[bot]' }} | ||
outputs: | ||
go_sources: ${{ steps.changed-files.outputs.sources_all_changed_files }} | ||
go_tests: ${{ steps.changed-files.outputs.tests_all_changed_files }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get changed go files | ||
id: changed-files | ||
uses: tj-actions/changed-files@v45 | ||
with: | ||
files_yaml: | | ||
sources: | ||
- '**/*.go' | ||
- '!**/*_test.go' | ||
tests: | ||
- '**/*_test.go' | ||
scoped-tests: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ windows-latest ] | ||
runs-on: ${{ matrix.os }} | ||
needs: changedfiles | ||
steps: | ||
- name: Echo changed files | ||
shell: bash | ||
run: | | ||
echo "go_sources: ${{ needs.changedfiles.outputs.go_sources }}" | ||
echo "go_tests: ${{ needs.changedfiles.outputs.go_tests }}" | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.22.8" | ||
cache: false | ||
|
||
- name: Try to restore go-cache | ||
id: go-cache | ||
timeout-minutes: 25 | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
~/go/bin | ||
~/go/pkg/mod | ||
./.tools | ||
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Run changed tests | ||
if: needs.changedfiles.outputs.go_tests | ||
env: | ||
CHANGED_GOLANG_TESTS: ${{ needs.changedfiles.outputs.go_tests }} | ||
run: | | ||
make run-changed-tests | ||
- name: Run tests on dependent components | ||
if: needs.changedfiles.outputs.go_sources | ||
env: | ||
CHANGED_GOLANG_SOURCES: ${{ needs.changedfiles.outputs.go_sources }} | ||
run: | | ||
make for-affected-components CMD="make test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters