Skip to content

Commit f0439bc

Browse files
chore: nightly serverless-init builds (#1135)
## Overview We'll be using this to check serverless-init against the latest main datadog agent nightly.
1 parent bac6ccb commit f0439bc

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Nightly serverless-init build
2+
3+
on:
4+
schedule:
5+
# 2 AM UTC (~9-10 PM ET), daily
6+
- cron: "0 2 * * *"
7+
workflow_dispatch:
8+
9+
env:
10+
IMAGE_NAME: datadog/datadog-lambda-extension/serverless-init
11+
REGISTRY: ghcr.io
12+
13+
jobs:
14+
build-nightly:
15+
runs-on: ubuntu-22.04
16+
permissions:
17+
contents: read
18+
packages: write
19+
strategy:
20+
matrix:
21+
arrays:
22+
- { dockerFile: "Dockerfile.serverless-init.build", isAlpine: "false", tagSuffix: "" }
23+
- { dockerFile: "Dockerfile.serverless-init.alpine.build", isAlpine: "true", tagSuffix: "-alpine" }
24+
name: "Nightly Build (isAlpine: ${{ matrix.arrays.isAlpine }})"
25+
steps:
26+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
27+
28+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29+
with:
30+
repository: DataDog/datadog-agent
31+
ref: main
32+
path: datadog-agent
33+
34+
- name: Compute version tags
35+
id: meta
36+
run: |
37+
STAMP=$(date -u +%Y%m%d)
38+
SHORT_SHA=$(git -C datadog-agent rev-parse --short=8 HEAD)
39+
echo "stamp=${STAMP}" >> "$GITHUB_OUTPUT"
40+
echo "short_sha=${SHORT_SHA}" >> "$GITHUB_OUTPUT"
41+
echo "version=nightly-${STAMP}-${SHORT_SHA}" >> "$GITHUB_OUTPUT"
42+
43+
# Pin QEMU to a known-good version. See release-serverless-init.yml
44+
# and test-qemu-versions.yml for context on QEMU breakage history.
45+
- name: Set up QEMU
46+
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
47+
with:
48+
image: tonistiigi/binfmt:qemu-v10.1.3
49+
50+
- name: Set up Docker Buildx
51+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
52+
53+
- name: Build binaries
54+
working-directory: ./scripts
55+
run: ./build_serverless_init.sh
56+
env:
57+
AGENT_PATH: datadog-agent
58+
VERSION: ${{ steps.meta.outputs.version }}
59+
SERVERLESS_INIT: "true"
60+
ALPINE: ${{ matrix.arrays.isAlpine }}
61+
62+
- name: Set up build directory and copy binaries
63+
run: cp -r .layers/. ./scripts/bin/
64+
65+
- name: Set up tracer installation script
66+
run: cp ./scripts/serverless_init_dotnet.sh ./scripts/bin/
67+
68+
- name: Login to GHCR
69+
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
70+
with:
71+
registry: ${{ env.REGISTRY }}
72+
username: ${{ github.actor }}
73+
password: ${{ secrets.GITHUB_TOKEN }}
74+
75+
- name: Build and push
76+
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
77+
with:
78+
context: ./scripts
79+
file: ./scripts/${{ matrix.arrays.dockerFile }}
80+
push: true
81+
tags: |
82+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-main${{ matrix.arrays.tagSuffix }}
83+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main-${{ steps.meta.outputs.stamp }}-${{ steps.meta.outputs.short_sha }}${{ matrix.arrays.tagSuffix }}
84+
provenance: false
85+
platforms: linux/amd64,linux/arm64
86+
87+
retry:
88+
needs: [build-nightly]
89+
if: failure() && fromJSON(github.run_attempt) < 2
90+
runs-on: ubuntu-22.04
91+
permissions:
92+
actions: write
93+
steps:
94+
- name: Retry failed action
95+
env:
96+
GH_REPO: ${{ github.repository }}
97+
GH_TOKEN: ${{ github.token }}
98+
run: gh workflow run retry-workflow.yml -F run_id=${{ github.run_id }}
99+
100+
notify:
101+
needs: [build-nightly]
102+
if: failure() && fromJSON(github.run_attempt) >= 2
103+
runs-on: ubuntu-22.04
104+
steps:
105+
- name: Notify Slack
106+
env:
107+
SLACK_CHANNEL: "#serverless-agent"
108+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
109+
run: |
110+
OPS_MESSAGE=":gh-check-failed: Nightly serverless-init build failed!
111+
112+
The nightly build from datadog-agent main did not succeed after retry.
113+
114+
See ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID} for details."
115+
116+
curl -H "Content-type: application/json" -X POST "$SLACK_WEBHOOK" \
117+
-d "$(jq -n --arg channel "$SLACK_CHANNEL" --arg text "$OPS_MESSAGE" '{channel: $channel, text: $text}')"

0 commit comments

Comments
 (0)