-
Notifications
You must be signed in to change notification settings - Fork 88
64 lines (63 loc) · 3.39 KB
/
pr_artifacts_size.yml
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
name: Artifacts Size
on:
pull_request:
branches:
- v2
paths:
- 'powertools-batch/**'
- 'powertools-cloudformation/**'
- 'powertools-common/**'
- 'powertools-e2e-tests/**'
- 'powertools-idempotency-core/**'
- 'powertools-idempotency-dynamodb/**'
- 'powertools-large-messages/**'
- 'powertools-logging/**'
- 'powertools-metrics/**'
- 'powertools-parameters/**'
- 'powertools-serialization/**'
- 'powertools-tracing/**'
- 'powertools-validation/**'
- 'pom.xml'
- '.github/workflows/pr_artifacts_size.yml'
jobs:
codecheck:
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: read
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup java JDK 11
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
with:
distribution: 'corretto'
java-version: 11
- name: Build with Maven
run: mvn clean package --file pom.xml -DskipTests artifact:buildinfo -pl '!software.amazon.lambda.examples:powertools-examples-idempotency,!software.amazon.lambda.examples:powertools-examples-batch,!software.amazon.lambda.examples:powertools-examples-cloudformation,!software.amazon.lambda.examples:powertools-examples-core-utilities-cdk,!software.amazon.lambda.examples:powertools-examples-core-utilities-sam,!software.amazon.lambda.examples:powertools-examples-core-utilities-serverless,!software.amazon.lambda.examples:powertools-examples-core-utilities-terraform,!software.amazon.lambda.examples:powertools-examples-parameters,!software.amazon.lambda.examples:powertools-examples-serialization,!software.amazon.lambda.examples:powertools-examples-validation,!software.amazon.lambda.examples:cdk,!software.amazon.lambda:powertools-examples'
- name: Get artifacts size & build report
id: artifacts-size-report
run: |
echo '## :floppy_disk: Artifacts Size Report' > report.md
echo '| Module | Version | Size (KB) |' >> report.md
echo '| --- | --- | --- |' >> report.md
artifact_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
for artifact in $(cat target/powertools-parent-*.buildinfo | grep 'outputs.*.jar' | grep -v 'sources.jar'); do
artifact_name=$(echo "$artifact" | cut -d '=' -f2)
artifact_name=${artifact_name%-$artifact_version.jar}
artifact_size=$(grep "${artifact%%.filename*}.length" target/powertools-parent-*.buildinfo | cut -d '=' -f2)
printf "| %s | %s | %.2f |\n" "$artifact_name" "$artifact_version" "$(bc <<< "scale=2; $artifact_size/1000")" >> report.md
done
- name: Find potential existing report
uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # 2.4.0
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Artifacts Size Report
- name: Write artifacts size report in comment
uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # 3.0.2
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-path: 'report.md'
edit-mode: replace