Skip to content

Commit

Permalink
[chore] 3 Improvements to scoped-tests action (#37145)
Browse files Browse the repository at this point in the history
#### Description

1. Completely skip the `scoped-tests` if there are no changes to go
files (avoids checking out and setting the repo and not running any
tests). Test on my fork:
https://github.com/pjanotti/opentelemetry-service-contrib/actions/runs/12698095207/job/35395815043?pr=31
2. Make the step to build `gotestsum` work on non-Windows - this needs
further investigation, since the `test` target depends on `gotestsum`,
but, as seem yesterday it was failing to build the tool (at least on
Windows GH runner, it didn't repro on my box). Test on my fork:
https://github.com/pjanotti/opentelemetry-service-contrib/actions/runs/12697644120/job/35394429408
3. On `Makefile.Common` account for the case when an internal package is
not used by any other package.
  • Loading branch information
pjanotti authored Jan 10, 2025
1 parent 32dc3be commit c76f56a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/scoped-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ jobs:
- '**/*_test.go'
scoped-tests:
needs: changedfiles
if: needs.changedfiles.outputs.go_sources != '' || needs.changedfiles.outputs.go_tests != ''
strategy:
fail-fast: false
matrix:
os: [ windows-latest ]
runs-on: ${{ matrix.os }}
needs: changedfiles
steps:
- name: Echo changed files
shell: bash
Expand All @@ -59,9 +60,14 @@ jobs:
./.tools
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}

- name: Build test tools
- name: Build gotestsum on Windows
if: runner.os == 'Windows'
run: make "$(${PWD} -replace '\\', '/')/.tools/gotestsum"

- name: Build gotestsum
if: runner.os != 'Windows'
run: make "$PWD/.tools/gotestsum"

- name: Run changed tests
if: needs.changedfiles.outputs.go_tests
env:
Expand Down
2 changes: 1 addition & 1 deletion Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ for-affected-components:
if [ -z '$${DEPENDENT_PKGS}' ]; then \
echo "No other package depends on the one being changed."; \
else \
DEPENDENT_PKG_DIRS=$$(echo $${DEPENDENT_PKGS} | tr ' ' '\n' | xargs -I {} grep --include=go.mod -rl {} | xargs dirname | uniq); \
DEPENDENT_PKG_DIRS=$$(echo $${DEPENDENT_PKGS} | tr ' ' '\n' | xargs -I {} grep --include=go.mod -rl {} | xargs -r dirname | uniq); \
set -e; for dir in $$(echo $${DEPENDENT_PKG_DIRS}); do \
(cd "$${dir}" && \
echo "running $${CMD} in $${dir}" && \
Expand Down

0 comments on commit c76f56a

Please sign in to comment.