Repository navigation
94 lines (86 loc) · 4.08 KB
/
Copy pathbuild-pull-request.yml
File metadata and controls
94 lines (86 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Build pull request
# Optional test variants (openj9, windows, full smoke) are gated by
# `test openj9`, `test windows`, and `test full smoke` labels on the PR,
# read from the event payload. We
# deliberately do NOT subscribe to `pull_request: [labeled]` — see
# https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/18446
# for the history of why every previous attempt to use that trigger failed.
#
# Practical consequence: adding a `test openj9`, `test windows`, or
# `test full smoke` label
# doesn't retrigger the build. Push another commit or close/reopen the
# PR to pick it up. `comment-on-test-label.yml` posts a reminder when one
# of those labels is added. `test openj9` and `test full smoke` also disable
# limited app-server selection; `test openj9` enables the OpenJ9 jobs.
#
# `test native` is detected automatically from the PR's changed paths (the
# `resolve-pr-changes` job below). The manual `test native` label is still
# honored as a force-enable.
on:
pull_request:
types:
- opened
- synchronize
- reopened
concurrency:
group: build-pull-request-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# Run native tests automatically when the PR touches a library
# instrumentation module with native support (logback-appender, jdbc,
# spring), the native smoke test harness, conventions, or the top-level
# build config, native workflow, or container configuration that affects them.
#
# Build the Servlet smoke-test images only when the PR touches the
# servlet image sources or its workflow definition.
resolve-pr-changes:
runs-on: ubuntu-slim
outputs:
run-native-tests: ${{ steps.filter.outputs.native }}
build-servlet-images: ${{ steps.filter.outputs.servlet }}
steps:
- name: Detect native- and servlet-image-relevant changes
id: filter
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
files=$(
gh api --paginate "/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files" \
--jq '.[].filename'
)
# `|| true` so an empty result from `grep -v` (everything filtered)
# doesn't fail the step under pipefail.
native_files=$(grep -Ev '^instrumentation/spring/.+/javaagent/' <<<"$files" || true)
native='^instrumentation/logback/logback-appender-1\.0/library/'
native+='|^instrumentation/jdbc/library/'
native+='|^instrumentation/spring/'
native+='|^smoke-tests-otel-starter/'
native+='|^conventions/'
native+='|^dependencyManagement/build\.gradle\.kts$'
native+='|^settings\.gradle\.kts$'
native+='|^\.github/workflows/reusable-native-tests\.yml$'
native+='|^\.github/graal-native-docker-compose\.yaml$'
if grep -Eq "$native" <<<"$native_files"; then
echo "native=true" >> "$GITHUB_OUTPUT"
else
echo "native=false" >> "$GITHUB_OUTPUT"
fi
servlet='^smoke-tests/images/servlet/'
servlet+='|^\.github/workflows/reusable-build-servlet-images\.yml$'
if grep -Eq "$servlet" <<<"$files"; then
echo "servlet=true" >> "$GITHUB_OUTPUT"
else
echo "servlet=false" >> "$GITHUB_OUTPUT"
fi
build:
needs: resolve-pr-changes
uses: $/.github/workflows/reusable-pr-build.yml
with:
skip-native-tests: ${{ !(needs.resolve-pr-changes.outputs.run-native-tests == 'true' || contains(github.event.pull_request.labels.*.name, 'test native')) }}
skip-openj9-tests: ${{ !contains(github.event.pull_request.labels.*.name, 'test openj9') }}
skip-windows-smoke-tests: ${{ !contains(github.event.pull_request.labels.*.name, 'test windows') }}
limited-appserver-matrix: ${{ !contains(github.event.pull_request.labels.*.name, 'test full smoke') && !contains(github.event.pull_request.labels.*.name, 'test openj9') }}
skip-servlet-images: ${{ needs.resolve-pr-changes.outputs.build-servlet-images != 'true' }}