-
Notifications
You must be signed in to change notification settings - Fork 33
192 lines (164 loc) · 8.26 KB
/
nightly-build.yml
File metadata and controls
192 lines (164 loc) · 8.26 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
# This workflow checks for new upstream versions of OpenTelemetry dependencies, creates a PR to update them, and builds and tests the new changes.
name: Nightly Upstream Snapshot Build
on:
schedule:
- cron: "21 3 * * *"
workflow_dispatch:
env:
AWS_DEFAULT_REGION: us-east-1
BRANCH_NAME: nightly-dependency-updates
permissions:
id-token: write
contents: write
pull-requests: write
jobs:
update-dependencies:
runs-on: ubuntu-latest
outputs:
has_changes: ${{ steps.check_changes.outputs.has_changes }}
otel_python_version: ${{ steps.get_versions.outputs.otel_python_version }}
otel_contrib_version: ${{ steps.get_versions.outputs.otel_contrib_version }}
aws_sdk_ext_version: ${{ steps.get_versions.outputs.opentelemetry_sdk_extension_aws_version }}
aws_xray_prop_version: ${{ steps.get_versions.outputs.opentelemetry_propagator_aws_xray_version }}
breaking_changes_info: ${{ steps.breaking_changes.outputs.breaking_changes_info }}
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c #v6.0.0
with:
python-version: '3.x'
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install toml requests packaging
- name: Get latest upstream versions
id: get_versions
run: python scripts/get_upstream_versions.py
- name: Check for breaking changes
id: breaking_changes
env:
OTEL_PYTHON_VERSION: ${{ steps.get_versions.outputs.otel_python_version }}
OTEL_CONTRIB_VERSION: ${{ steps.get_versions.outputs.otel_contrib_version }}
run: python scripts/find_breaking_changes.py
- name: Setup Git
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
- name: Check out dependency update branch
run: |
if git ls-remote --exit-code --heads origin "$BRANCH_NAME"; then
echo "Branch $BRANCH_NAME already exists, checking out..."
git checkout "$BRANCH_NAME"
else
echo "Branch $BRANCH_NAME does not exist, creating new branch..."
git checkout -b "$BRANCH_NAME"
fi
- name: Update dependencies
env:
OTEL_PYTHON_VERSION: ${{ steps.get_versions.outputs.otel_python_version }}
OTEL_CONTRIB_VERSION: ${{ steps.get_versions.outputs.otel_contrib_version }}
OPENTELEMETRY_SDK_EXTENSION_AWS_VERSION: ${{ steps.get_versions.outputs.opentelemetry_sdk_extension_aws_version }}
OPENTELEMETRY_PROPAGATOR_AWS_XRAY_VERSION: ${{ steps.get_versions.outputs.opentelemetry_propagator_aws_xray_version }}
run: python scripts/update_dependencies.py
- name: Check for changes and commit
id: check_changes
run: |
if git diff --quiet; then
echo "No dependency updates needed"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "Dependencies were updated"
echo "has_changes=true" >> $GITHUB_OUTPUT
git add .
git commit -m "chore: update OpenTelemetry dependencies to ${{ steps.get_versions.outputs.otel_python_version }}/${{ steps.get_versions.outputs.otel_contrib_version }}"
git push origin "$BRANCH_NAME"
fi
build-and-test:
needs: update-dependencies
if: needs.update-dependencies.outputs.has_changes == 'true'
uses: ./.github/workflows/main-build.yml
secrets: inherit
permissions:
id-token: write
contents: read
actions: write
with:
ref: nightly-dependency-updates
create-pr:
needs: [update-dependencies, build-and-test]
if: always() && needs.update-dependencies.outputs.has_changes == 'true'
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials for BOT secrets
uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 #v5.0.0
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN_SECRETS_MANAGER }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Get Bot secrets
uses: aws-actions/aws-secretsmanager-get-secrets@a9a7eb4e2f2871d30dc5b892576fde60a2ecc802 #v2.0.10
id: bot_secrets
with:
secret-ids: |
BOT_TOKEN ,${{ secrets.BOT_TOKEN_SECRET_ARN }}
parse-json-secrets: true
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
with:
token: ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }}
- name: Create or update PR
env:
GITHUB_TOKEN: ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }}
run: |
BUILD_STATUS="${{ needs.build-and-test.result }}"
BUILD_EMOJI="${{ needs.build-and-test.result == 'success' && '✅' || '❌' }}"
BUILD_LINK="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
PR_BODY="Automated update of OpenTelemetry dependencies.
**Build Status:** ${BUILD_EMOJI} [${BUILD_STATUS}](${BUILD_LINK})
**Updated versions:**
- [OpenTelemetry Python](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v${{ needs.update-dependencies.outputs.otel_python_version }}): ${{ needs.update-dependencies.outputs.otel_python_version }}
- [OpenTelemetry Contrib](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v${{ needs.update-dependencies.outputs.otel_contrib_version }}): ${{ needs.update-dependencies.outputs.otel_contrib_version }}
- [opentelemetry-sdk-extension-aws](https://pypi.org/project/opentelemetry-sdk-extension-aws/${{ needs.update-dependencies.outputs.aws_sdk_ext_version }}/): ${{ needs.update-dependencies.outputs.aws_sdk_ext_version }}
- [opentelemetry-propagator-aws-xray](https://pypi.org/project/opentelemetry-propagator-aws-xray/${{ needs.update-dependencies.outputs.aws_xray_prop_version }}/): ${{ needs.update-dependencies.outputs.aws_xray_prop_version }}
**Upstream releases with breaking changes:**
Note: the mechanism to detect upstream breaking changes is not perfect. Be sure to check all new releases and understand if any additional changes need to be addressed.
${{ needs.update-dependencies.outputs.breaking_changes_info }}"
if gh pr view "$BRANCH_NAME" --json state --jq '.state' 2>/dev/null | grep -q "OPEN"; then
echo "Open PR already exists, updating title and description..."
gh pr edit "$BRANCH_NAME" \
--title "Nightly dependency update: OpenTelemetry ${{ needs.update-dependencies.outputs.otel_python_version }}/${{ needs.update-dependencies.outputs.otel_contrib_version }}" \
--body "$PR_BODY"
else
echo "Creating new PR..."
gh pr create \
--title "Nightly dependency update: OpenTelemetry ${{ needs.update-dependencies.outputs.otel_python_version }}/${{ needs.update-dependencies.outputs.otel_contrib_version }}" \
--body "$PR_BODY" \
--base main \
--head "$BRANCH_NAME"
fi
publish-nightly-build-status:
name: "Publish Nightly Build Status"
needs: [ update-dependencies, build-and-test, create-pr ]
runs-on: ubuntu-latest
if: always()
steps:
- name: Configure AWS Credentials for emitting metrics
uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 #5.0.0
with:
role-to-assume: ${{ secrets.MONITORING_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Publish nightly build status
run: |
if [[ "${{ needs.build-and-test.result }}" == "skipped" ]]; then
echo "Build was skipped (no changes)"
value="0.0"
else
value="${{ (needs.build-and-test.result == 'success' && needs.create-pr.result == 'success') && '0.0' || '1.0'}}"
fi
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=nightly_build \
--value $value