-
Notifications
You must be signed in to change notification settings - Fork 15
282 lines (257 loc) · 9.63 KB
/
Copy pathnightly.yml
File metadata and controls
282 lines (257 loc) · 9.63 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
name: Nightly
on:
workflow_dispatch: {}
push:
branches:
- "main"
schedule:
- cron: '00 03 * * *'
jobs:
nightly:
strategy:
matrix:
library:
- cpp
- cpp_httpd
- dotnet
- golang
- java
- nodejs
- php
- python
- python_lambda
- nodejs_lambda
- ruby
- cpp_nginx
version:
- prod
include:
- library: rust
version: dev
fail-fast: false
uses: ./.github/workflows/system-tests.yml
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
permissions:
contents: read
id-token: write
with:
scenarios_groups: tracer_release
library: ${{ matrix.library }}
parametric_job_count: 8
_system_tests_dev_mode: ${{ matrix.version == 'dev' }}
push_to_test_optimization: true
create_test_report:
name: Create test report
permissions:
contents: read
packages: read
if: (success() || failure()) && github.event_name == 'schedule'
needs:
- nightly
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
with:
sparse-checkout: .github/actions
sparse-checkout-cone-mode: false
- name: Download logs artifact
uses: ./.github/actions/download_artifact
with:
merge-multiple: false
pattern: logs_*
- name: Uncompress logs
run: |
for d in logs_*; do
if [ -f "$d/artifact.tar.gz" ]; then
tar -xzf "$d/artifact.tar.gz" -C "$d" --wildcards '*/report.json' || true
fi
done
- name: Upload test report
uses: ./.github/actions/upload_artifact
with:
name: test-report
path: |
logs_*
!logs_*/artifact.tar.gz
test_activation:
name: Test activation
runs-on: ubuntu-latest
if: (success() || failure()) && github.event_name == 'schedule'
strategy:
fail-fast: false
matrix:
library:
- cpp
- cpp_httpd
- cpp_nginx
- dotnet
- golang
- java
- nodejs
- php
- python
- python_lambda
- nodejs_lambda
- ruby
- rust
include:
- library: cpp
exclude_owners: ""
use_dev: ""
- library: cpp_httpd
exclude_owners: ""
use_dev: ""
- library: cpp_nginx
exclude_owners: ""
use_dev: ""
- library: dotnet
exclude_owners: ""
use_dev: ""
- library: golang
exclude_owners: ""
use_dev: ""
- library: java
exclude_owners: ""
use_dev: ""
- library: nodejs
exclude_owners: ""
use_dev: ""
- library: php
exclude_owners: ""
use_dev: ""
- library: python
exclude_owners: ""
use_dev: ""
- library: python_lambda
exclude_owners: ""
use_dev: ""
- library: nodejs_lambda
exclude_owners: ""
use_dev: ""
- library: ruby
exclude_owners: ""
use_dev: ""
- library: rust
exclude_owners: ""
use_dev: "true"
permissions:
contents: read
actions: read
id-token: write
needs:
- create_test_report
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
with:
repository: DataDog/system-tests
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
persist-credentials: false
- uses: ./.github/actions/download_artifact
with:
name: test-report
path: data
- uses: DataDog/system-tests/.github/actions/install_runner@main
- name: Install additional dependencies
shell: bash
run: |
source venv/bin/activate
python -m pip install --upgrade pip ruamel.yaml requests tqdm pygtrie
- name: Configure git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Run activation script
id: activation_script
shell: bash
run: |
source venv/bin/activate
set +e
EXTRA_ARGS=""
if [[ -n "${{ matrix.exclude_owners }}" ]]; then
EXTRA_ARGS="$EXTRA_ARGS --exclude ${{ matrix.exclude_owners }}"
fi
if [[ -n "${{ matrix.use_dev }}" ]]; then
EXTRA_ARGS="$EXTRA_ARGS --dev"
fi
python -m utils.scripts.activate_easy_wins --no-download --split-co --components "${{ matrix.library }}" $EXTRA_ARGS
EXIT_CODE=$?
set -e
echo "activation_exit_code=$EXIT_CODE" >> "$GITHUB_OUTPUT"
# Collect branches created by --split-co
BRANCHES=$(git branch --list 'easy-win/*/${{ matrix.library }}' --format='%(refname:short)' | tr '\n' ' ')
echo "branches=$BRANCHES" >> "$GITHUB_OUTPUT"
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
id: octo-sts
if: steps.activation_script.outputs.activation_exit_code == '0' && steps.activation_script.outputs.branches != ''
with:
scope: DataDog/system-tests
policy: self.test-activation-github
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
if: steps.activation_script.outputs.activation_exit_code == '0' && steps.activation_script.outputs.branches != ''
with:
repository: DataDog/commit-headless
ref: action/v3.3.0
path: .commit-headless
- name: Push signed branches and create PRs
if: steps.activation_script.outputs.activation_exit_code == '0' && steps.activation_script.outputs.branches != ''
env:
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
shell: bash
run: |
gh auth setup-git
chmod +x .commit-headless/dist/commit-headless-linux-amd64
COMMIT_HEADLESS=".commit-headless/dist/commit-headless-linux-amd64"
for BRANCH_NAME in ${{ steps.activation_script.outputs.branches }}; do
echo "============ Processing $BRANCH_NAME ============"
# Extract owner name from branch: easy-win/<owner>/<library> -> <owner>
OWNER=$(echo "$BRANCH_NAME" | cut -d'/' -f2)
# Check if a PR already exists for this branch
PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number' 2>/dev/null || true)
if [[ -n "$PR_NUMBER" ]]; then
# Skip if the PR has any activity (comments, reviews, or extra commits)
COMMENTS=$(gh api "repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" --jq '[.[] | select(.user.login | endswith("[bot]") | not)] | length')
REVIEWS=$(gh api "repos/${{ github.repository }}/pulls/${PR_NUMBER}/reviews" --jq 'length')
COMMITS=$(gh api "repos/${{ github.repository }}/pulls/${PR_NUMBER}/commits" --jq 'length')
if [[ "$COMMENTS" -gt 0 || "$REVIEWS" -gt 0 || "$COMMITS" -gt 1 ]]; then
echo "PR #$PR_NUMBER for $BRANCH_NAME has activity (comments=$COMMENTS, reviews=$REVIEWS, commits=$COMMITS), skipping"
continue
fi
echo "PR #$PR_NUMBER exists but has no activity, updating"
fi
git checkout "$BRANCH_NAME"
MAIN_SHA=$(git rev-parse main)
if git ls-remote --exit-code --heads origin "$BRANCH_NAME" >/dev/null 2>&1; then
SIGNED_COMMIT=$(git log --reverse --format="%H" "$MAIN_SHA..HEAD" | \
HEADLESS_TOKEN="$GITHUB_TOKEN" $COMMIT_HEADLESS push \
-T "${{ github.repository }}" --branch "$BRANCH_NAME" \
--head-sha "$MAIN_SHA" --force)
else
SIGNED_COMMIT=$(git log --reverse --format="%H" "$MAIN_SHA..HEAD" | \
HEADLESS_TOKEN="$GITHUB_TOKEN" $COMMIT_HEADLESS push \
-T "${{ github.repository }}" --branch "$BRANCH_NAME" \
--head-sha "$MAIN_SHA" --create-branch)
fi
echo "Pushed signed commit $SIGNED_COMMIT to $BRANCH_NAME"
# Create PR if it doesn't exist
if [[ -z "$PR_NUMBER" ]]; then
gh pr create \
--title "Auto-activate ${{ matrix.library }} easy wins for $OWNER" \
--body "Automated activation of easy-win tests for \`${{ matrix.library }}\` owned by \`$OWNER\`
[View nightly workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
- If you approve this PR please also merge it.
- If the tests are failing it might be due to a change made since the last nightly system-tests run. You can close the PR, an updated one will be available tomorrow.
- If you close the PR please also delete the branch" \
--head "$BRANCH_NAME" \
--base main
PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number')
fi
# Enable auto-merge on the PR
echo "Enabling auto-merge on PR #$PR_NUMBER..."
gh pr merge "$PR_NUMBER" --auto --squash
done