Skip to content

Commit 1f10e2d

Browse files
authored
Trigger windows e2e tests when windows-related files change (open-telemetry#36857)
#### Description We've noticed that many of the CI failures on main come from Windows e2e tests. We want to be more proactive in catching those failures, so this PR changes the workflow triggering Windows e2e tests to ensure they run on Pull Requests that change Windows-related files, even if the label `Run Windows` is absent. It does so by looking at changed files. If the word `windows` is present in the file name, it triggers the workflow. #### Link to tracking issue Related to open-telemetry#36788 --------- Signed-off-by: Arthur Silva Sens <[email protected]>
1 parent 43d345e commit 1f10e2d

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

.github/workflows/e2e-tests-windows.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,22 @@ env:
1919
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
2020

2121
jobs:
22+
windows-file-changed:
23+
runs-on: ubuntu-latest
24+
if: ${{ github.event_name == 'pull_request' }}
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
- name: Did windows files changed
31+
run: echo "changed=$(./.github/workflows/scripts/is_changed_file_windows.sh )" >> "$GITHUB_OUTPUT"
32+
- run: echo $(./.github/workflows/scripts/is_changed_file_windows.sh ${{ github.event.pull_request.base.sha }} ${{ github.sha }} )
33+
2234
collector-build:
2335
runs-on: windows-latest
24-
if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Windows') || github.event_name == 'push' || github.event_name == 'merge_group') }}
36+
needs: [windows-file-changed]
37+
if: ${{ github.actor != 'dependabot[bot]' && ((contains(github.event.pull_request.labels.*.name, 'Run Windows') || github.event_name == 'push' || github.event_name == 'merge_group') || needs.windows-file-changed.outputs.changed == 'true') }}
2538
steps:
2639
- name: Checkout
2740
uses: actions/checkout@v4
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright The OpenTelemetry Authors
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
#
7+
# verifies if any changed file is related to windows architecture.
8+
# this script is used to determine if e2e tests should be run on windows.
9+
#
10+
# It's intended to be used in a GitHub Actions workflow:
11+
# bash .github/workflows/scripts/is_changed_file_windows.sh ${{ github.event.pull_request.base.sha }} ${{ github.sha }}
12+
13+
14+
# Get changed files
15+
base_sha=$1
16+
head_sha=$2
17+
changed_files=$(git diff --name-only $base_sha $head_sha)
18+
19+
# Find windows related files
20+
windows_files=$(find * -regex ".*windows.*.go")
21+
22+
23+
# Loop over changed files and check if they exist in windows_files
24+
found_windows_file=false
25+
for file in $changed_files; do
26+
for windows_file in $windows_files; do
27+
if [[ $file == "$windows_file" ]]; then
28+
found_windows_file=true
29+
break
30+
fi
31+
done
32+
done
33+
34+
echo "$found_windows_file"

0 commit comments

Comments
 (0)