forked from anthropics/anthropic-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (164 loc) · 7.05 KB
/
Copy pathci.yml
File metadata and controls
186 lines (164 loc) · 7.05 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: CI
on:
push:
branches:
- '**'
- '!integrated/**'
- '!stl-preview-head/**'
- '!stl-preview-base/**'
- '!generated'
- '!codegen/**'
- 'codegen/stl/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
- 'stl-preview-base/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.sha || github.ref }}
cancel-in-progress: true
jobs:
lint:
timeout-minutes: 15
name: lint
runs-on: ${{ github.repository == 'anthropics/anthropic-sdk-java' && 'ubuntu-latest-16core' || 'ubuntu-latest-16-core' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: temurin
java-version: |
8
21
- name: Set up Gradle
uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.3
with:
# Required for configuration-cache data to be saved/restored across CI runs.
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- name: Run lints
run: ./scripts/lint
build:
# The first run on a fresh cache compiles everything and generates all documentation, which
# does not fit in 15 minutes; cached runs are much faster.
timeout-minutes: 30
name: build
permissions:
contents: read
id-token: write
runs-on: ${{ github.repository == 'anthropics/anthropic-sdk-java' && 'ubuntu-latest-16core' || 'ubuntu-latest-16-core' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: temurin
java-version: |
8
21
- name: Set up Gradle
uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.3
with:
# Required for configuration-cache data to be saved/restored across CI runs.
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- name: Build SDK
run: ./scripts/build
- name: Build local Maven repo
if: |-
github.repository == 'anthropics/anthropic-sdk-java-private' &&
!startsWith(github.ref, 'refs/heads/stl/')
run: ./gradlew publishMavenPublicationToLocalFileSystemRepository -PpublishLocal
- name: Get GitHub OIDC Token
if: |-
github.repository == 'anthropics/anthropic-sdk-java-private' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: core.setOutput('github_token', await core.getIDToken());
- name: Upload Maven artifacts
if: |-
github.repository == 'anthropics/anthropic-sdk-java-private' &&
!startsWith(github.ref, 'refs/heads/stl/')
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
SHA: ${{ github.sha }}
PROJECT: anthropic-java
run: ./scripts/upload-artifacts
test:
timeout-minutes: 30
name: test
runs-on: ${{ github.repository == 'anthropics/anthropic-sdk-java' && 'ubuntu-latest-16core' || 'ubuntu-latest-16-core' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: temurin
java-version: |
8
21
- name: Set up Gradle
uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.3
with:
# Required for configuration-cache data to be saved/restored across CI runs.
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- name: Run tests
run: ./scripts/test
detect_breaking_changes:
timeout-minutes: 15
name: detect-breaking-changes
runs-on: ${{ github.repository == 'anthropics/anthropic-sdk-java' && 'ubuntu-latest-16core' || 'ubuntu-latest-16-core' }}
if: |-
(github.event_name == 'push' &&
!startsWith(github.ref, 'refs/heads/release-please--')) ||
github.event.pull_request.head.repo.fork
steps:
# fetch-depth: 0 fetches full commit history (all branches and
# tags, so the base ref is available) so `git merge-base`
# below can resolve the fork point. filter: blob:none keeps the
# fetch cheap: commit metadata is downloaded eagerly, file blobs
# only when a later `git checkout` asks for them.
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
filter: blob:none
- name: Set up Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: temurin
java-version: |
8
21
- name: Set up Gradle
uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.3
with:
# Required for configuration-cache data to be saved/restored across CI runs.
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- name: Determine base SHA
run: |
# A breaking-change-baseline tag, when the repo keeps one, marks the API
# surface to compare against; it is moved by force, so refetch it.
git fetch --quiet --force origin '+refs/tags/breaking-change-baseline:refs/tags/breaking-change-baseline' 2>/dev/null || true
if git rev-parse --quiet --verify 'refs/tags/breaking-change-baseline^{commit}' >/dev/null; then
BASE_REF='refs/tags/breaking-change-baseline'
elif git rev-parse --quiet --verify 'origin/main^{commit}' >/dev/null; then
BASE_REF='origin/main'
else
echo 'No breaking-change-baseline tag or origin/main to compare against; skipping.'
echo "BASE_SHA=" >> "$GITHUB_ENV"
exit 0
fi
echo "Comparing against $BASE_REF"
BASE_SHA=$(git merge-base HEAD "$BASE_REF" 2>/dev/null || echo "")
echo "BASE_SHA=$BASE_SHA" >> "$GITHUB_ENV"
- name: Detect breaking changes
if: env.BASE_SHA != ''
run: |
# Try to check out previous versions of the breaking change detection script. This ensures that
# we still detect breaking changes when entire files and their tests are removed.
git checkout "$BASE_SHA" -- ./scripts/detect-breaking-changes 2>/dev/null || true
./scripts/detect-breaking-changes "$BASE_SHA"