APM: use non-default port for tests to avoid running agent #46204
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Serverless Binary Size" | |
on: | |
pull_request: | |
push: | |
branches: | |
- mq-working-branch-* | |
env: | |
SIZE_ALLOWANCE: fromJSON(1000000) # 1 MB | |
jobs: | |
comment: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout datadog-agent repository | |
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | |
with: | |
path: go/src/github.com/DataDog/datadog-agent | |
- name: Checkout datadog-agent base branch | |
run: | | |
# on pull request, use the merge-base | |
# on merge queue, just use the latest main | |
if [ -n "$GITHUB_HEAD_REF" ]; then | |
cd go/src/github.com/DataDog/datadog-agent | |
git fetch origin $GITHUB_HEAD_REF $GITHUB_BASE_REF | |
TARGET=$(git merge-base origin/$GITHUB_HEAD_REF origin/$GITHUB_BASE_REF) | |
git checkout $TARGET | |
fi | |
- name: Checkout the datadog-lambda-extension repository | |
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | |
with: | |
repository: DataDog/datadog-lambda-extension | |
path: go/src/github.com/DataDog/datadog-lambda-extension | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 | |
- name: Previous binary size and dependencies | |
id: previous | |
run: | | |
cd go/src/github.com/DataDog/datadog-lambda-extension | |
OUTPUT=$(./scripts/visualize_size.sh size) | |
echo "binary size before merging this pull request is $OUTPUT" | |
echo "result=$OUTPUT" >> $GITHUB_OUTPUT | |
echo "deps<<EOF" >> $GITHUB_OUTPUT | |
./scripts/visualize_size.sh list_symbols | awk '{print $2}' | head -n 100 >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: Checkout datadog-agent pr branch | |
run: | | |
cd go/src/github.com/DataDog/datadog-agent | |
git fetch origin $GITHUB_SHA --depth 1 | |
git checkout $GITHUB_SHA | |
- name: Current binary size and dependencies | |
id: current | |
run: | | |
cd go/src/github.com/DataDog/datadog-lambda-extension | |
OUTPUT=$(./scripts/visualize_size.sh size) | |
echo "binary size after merging this pull request will be $OUTPUT" | |
echo "result=$OUTPUT" >> $GITHUB_OUTPUT | |
echo "deps<<EOF" >> $GITHUB_OUTPUT | |
./scripts/visualize_size.sh list_symbols | awk '{print $2}' | head -n 100 >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: Compare sizes | |
id: compare | |
run: | | |
OUTPUT=$(( ${{ steps.current.outputs.result }} - ${{ steps.previous.outputs.result }} )) | |
echo "binary size changed by $OUTPUT bytes" | |
echo "diff=$OUTPUT" >> $GITHUB_OUTPUT | |
OUTPUT=$(( $OUTPUT / 100000 )) | |
echo "cold start time changed by $OUTPUT ms" | |
echo "coldstart=$OUTPUT" >> $GITHUB_OUTPUT | |
- name: Should post comment | |
id: should | |
run: | | |
cd go/src/github.com/DataDog/datadog-agent | |
if test $( | |
git diff $GITHUB_BASE_REF..$GITHUB_SHA --name-only | grep dependencies_linux_amd64.txt | |
); then | |
echo "should_run=true" >> $GITHUB_OUTPUT | |
elif [[ ${{ steps.compare.outputs.diff }} > env.SIZE_ALLOWANCE ]]; then | |
echo "should_run=true" >> $GITHUB_OUTPUT | |
else | |
echo "should_run=false" >> $GITHUB_OUTPUT | |
fi | |
### Steps below run if size diff > SIZE_ALLOWANCE or file dependencies_linux_amd64.txt changed ### | |
- name: Install graphviz | |
uses: ts-graphviz/setup-graphviz@b1de5da23ed0a6d14e0aeee8ed52fdd87af2363c # v2.0.2 | |
if: steps.should.outputs.should_run == 'true' | |
- name: Install digraph | |
if: steps.should.outputs.should_run == 'true' | |
run: | | |
GOPATH=$(pwd)/go go install golang.org/x/tools/cmd/digraph@latest | |
- name: List new dependencies | |
id: deps | |
if: steps.should.outputs.should_run == 'true' | |
run: | | |
echo "deps<<EOF" >> $GITHUB_OUTPUT | |
for dep in $(echo "${{ steps.current.outputs.deps }}"); do | |
if ! echo "${{ steps.previous.outputs.deps }}" | grep -w -q "$dep"; then | |
echo "$dep" >> $GITHUB_OUTPUT | |
fi | |
done | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: Create dependency graphs | |
if: steps.should.outputs.should_run == 'true' | |
run: | | |
export PATH=$(pwd)/go/bin:$PATH | |
cd go/src/github.com/DataDog/datadog-lambda-extension | |
mkdir graphs | |
for dep in $(echo "${{ steps.deps.outputs.deps }}"); do | |
PACKAGE=$dep ./scripts/visualize_size.sh graph | |
mv .layers/output.svg graphs/$(echo $dep | tr '/' '-').svg | |
done | |
- name: Archive dependency graphs | |
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | |
if: steps.should.outputs.should_run == 'true' | |
with: | |
name: dependency-graphs | |
path: go/src/github.com/DataDog/datadog-lambda-extension/graphs | |
- name: Post comment | |
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0 | |
if: steps.should.outputs.should_run == 'true' | |
with: | |
header: serverless-binary-size | |
hide_and_recreate: true | |
hide_classify: "RESOLVED" | |
message: | | |
:warning::rotating_light: Warning, this pull request increases the binary size of serverless extension by ${{ steps.compare.outputs.diff }} bytes. Each MB of binary size increase means about 10ms of additional cold start time, so this pull request would increase cold start time by ${{ steps.compare.outputs.coldstart }}ms. | |
If you have questions, we are happy to help, come visit us in the [#serverless](https://dd.slack.com/archives/CBWDFKWV8) slack channel and provide a link to this comment. | |
<details> | |
<summary>Debug info</summary> | |
These dependencies were added to the serverless extension by this pull request: | |
``` | |
${{ steps.deps.outputs.deps }} | |
``` | |
View dependency graphs for each added dependency in the [artifacts section](https://github.com/DataDog/datadog-agent/actions/runs/${{ github.run_id }}#artifacts) of the github action. | |
We suggest you consider adding the `!serverless` build tag to remove any new dependencies not needed in the serverless extension. | |
</details> |