[ASCII-1513] Add json flag to diagnose command #38439
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: | | |
cd go/src/github.com/DataDog/datadog-agent | |
git fetch origin $GITHUB_BASE_REF --depth 1 | |
git checkout $GITHUB_BASE_REF | |
- 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 "diff=$OUTPUT" >> $GITHUB_OUTPUT | |
OUTPUT=$(( $OUTPUT / 100000 )) | |
echo "coldstart=$OUTPUT" >> $GITHUB_OUTPUT | |
### Steps below only run if size diff > SIZE_ALLOWANCE ### | |
- name: Install graphviz | |
uses: ts-graphviz/setup-graphviz@b1de5da23ed0a6d14e0aeee8ed52fdd87af2363c # v2.0.2 | |
if: steps.compare.outputs.diff > env.SIZE_ALLOWANCE | |
- name: Install digraph | |
if: steps.compare.outputs.diff > env.SIZE_ALLOWANCE | |
run: | | |
GOPATH=$(pwd)/go go install golang.org/x/tools/cmd/digraph@latest | |
- name: List new dependencies | |
id: deps | |
if: steps.compare.outputs.diff > env.SIZE_ALLOWANCE | |
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.compare.outputs.diff > env.SIZE_ALLOWANCE | |
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.compare.outputs.diff > env.SIZE_ALLOWANCE | |
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.compare.outputs.diff > env.SIZE_ALLOWANCE | |
with: | |
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> |