From 9379364a54535e09e2681e5bdee739a4ca757ff2 Mon Sep 17 00:00:00 2001 From: Jerome Van Der Linden Date: Thu, 15 Jun 2023 13:48:03 +0200 Subject: [PATCH 01/11] reporting size of the jars in the github comments --- .github/workflows/build.yml | 28 ++++++++++++++++++++++++++++ pom.xml | 8 ++++++++ 2 files changed, 36 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 73ae67553..e1beea5e0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,6 +73,34 @@ jobs: if: ${{ matrix.java == '11' }} # publish results once with: files: ./powertools-cloudformation/target/site/jacoco/jacoco.xml,./powertools-core/target/site/jacoco/jacoco.xml,./powertools-idempotency/target/site/jacoco/jacoco.xml,./powertools-logging/target/site/jacoco/jacoco.xml,./powertools-metrics/target/site/jacoco/jacoco.xml,./powertools-parameters/target/site/jacoco/jacoco.xml,./powertools-serialization/target/site/jacoco/jacoco.xml,./powertools-sqs/target/site/jacoco/jacoco.xml,./powertools-tracing/target/site/jacoco/jacoco.xml,./powertools-validation/target/site/jacoco/jacoco.xml + - name: Get artifacts size & build report + id: artifacts-size-report + if: ${{ matrix.java == '11.0.x' }} # do it once + run: | + report='## Artifacts Size Report\n\n' + report+='| Module | Version | Size |\n' + report+='| --- | --- | --- |\n' + artifact_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + grep 'outputs.*.jar' target/powertools-parent-*.buildinfo | grep -v 'sources.jar' | while IFS= read -r artifact; 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) + echo "$artifact_name = $artifact_size" + report+="| $artifact_name | $artifact_version | $artifact_size |\n" + done + echo "ARTIFACT_REPORT=$report" >> "$GITHUB_OUTPUT" + - name: Comment artifacts size report + if: ${{ matrix.java == '11.0.x' }} # do it once + uses: actions/github-script@v6 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: ${{ steps.artifacts-size-report.outputs.ARTIFACT_REPORT }} + }) + savepr: runs-on: ubuntu-latest name: Save PR number if running on PR by dependabot diff --git a/pom.xml b/pom.xml index a74e13fc2..36abf162e 100644 --- a/pom.xml +++ b/pom.xml @@ -368,6 +368,14 @@ false + + org.apache.maven.plugins + maven-artifact-plugin + 3.4.1 + + true + + dev.aspectj aspectj-maven-plugin From 3ebf78f33695c2d71bb112009b98c53cddf5c799 Mon Sep 17 00:00:00 2001 From: Jerome Van Der Linden Date: Thu, 15 Jun 2023 13:57:18 +0200 Subject: [PATCH 02/11] quote report body --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e1beea5e0..2510816fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -98,7 +98,7 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: ${{ steps.artifacts-size-report.outputs.ARTIFACT_REPORT }} + body: "${{ steps.artifacts-size-report.outputs.ARTIFACT_REPORT }}" }) savepr: From 9092dbfb49d3410df4469a656f0998093bc05ab1 Mon Sep 17 00:00:00 2001 From: Jerome Van Der Linden Date: Thu, 15 Jun 2023 14:31:40 +0200 Subject: [PATCH 03/11] fix report content --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2510816fb..c7fe94915 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -86,7 +86,7 @@ jobs: artifact_name=${artifact_name%-$artifact_version.jar} artifact_size=$(grep "${artifact%%.filename*}.length" target/powertools-parent-*.buildinfo | cut -d '=' -f2) echo "$artifact_name = $artifact_size" - report+="| $artifact_name | $artifact_version | $artifact_size |\n" + report+="| ${artifact_name} | ${artifact_version} | ${artifact_size} |\n" done echo "ARTIFACT_REPORT=$report" >> "$GITHUB_OUTPUT" - name: Comment artifacts size report From bb10ccdcc1d07bfb3803603c31bb452794f7f367 Mon Sep 17 00:00:00 2001 From: Jerome Van Der Linden Date: Thu, 15 Jun 2023 14:39:33 +0200 Subject: [PATCH 04/11] removing version from report --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c7fe94915..c107213d4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,15 +78,15 @@ jobs: if: ${{ matrix.java == '11.0.x' }} # do it once run: | report='## Artifacts Size Report\n\n' - report+='| Module | Version | Size |\n' - report+='| --- | --- | --- |\n' + report+='| Module | Size |\n' + report+='| --- | --- |\n' artifact_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) grep 'outputs.*.jar' target/powertools-parent-*.buildinfo | grep -v 'sources.jar' | while IFS= read -r artifact; 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) echo "$artifact_name = $artifact_size" - report+="| ${artifact_name} | ${artifact_version} | ${artifact_size} |\n" + report+="| ${artifact_name} | ${artifact_size} |\n" done echo "ARTIFACT_REPORT=$report" >> "$GITHUB_OUTPUT" - name: Comment artifacts size report From 03d90fb9a5aae48fcf17e59c862d153045ace582 Mon Sep 17 00:00:00 2001 From: Jerome Van Der Linden Date: Thu, 15 Jun 2023 14:48:12 +0200 Subject: [PATCH 05/11] fix report content --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c107213d4..afadb6c98 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,15 +78,15 @@ jobs: if: ${{ matrix.java == '11.0.x' }} # do it once run: | report='## Artifacts Size Report\n\n' - report+='| Module | Size |\n' - report+='| --- | --- |\n' + report+='| Module | Version | Size |\n' + report+='| --- | --- | --- |\n' artifact_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) grep 'outputs.*.jar' target/powertools-parent-*.buildinfo | grep -v 'sources.jar' | while IFS= read -r artifact; 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) echo "$artifact_name = $artifact_size" - report+="| ${artifact_name} | ${artifact_size} |\n" + report+="\| ${artifact_name} \| ${artifact_version} \| ${artifact_size} \|\n" done echo "ARTIFACT_REPORT=$report" >> "$GITHUB_OUTPUT" - name: Comment artifacts size report From 1c88f36a4b3c822845461e8fe53907866a3b6a38 Mon Sep 17 00:00:00 2001 From: Jerome Van Der Linden Date: Thu, 15 Jun 2023 15:04:06 +0200 Subject: [PATCH 06/11] fix report content --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index afadb6c98..60fc2d186 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -81,12 +81,12 @@ jobs: report+='| Module | Version | Size |\n' report+='| --- | --- | --- |\n' artifact_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) - grep 'outputs.*.jar' target/powertools-parent-*.buildinfo | grep -v 'sources.jar' | while IFS= read -r artifact; do + 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) echo "$artifact_name = $artifact_size" - report+="\| ${artifact_name} \| ${artifact_version} \| ${artifact_size} \|\n" + report+="| ${artifact_name} | ${artifact_version} | ${artifact_size} |\n" done echo "ARTIFACT_REPORT=$report" >> "$GITHUB_OUTPUT" - name: Comment artifacts size report From c6c946929819dd2cf9de2b991cbb1014ad3e51d3 Mon Sep 17 00:00:00 2001 From: Jerome Van Der Linden Date: Thu, 15 Jun 2023 22:45:38 +0200 Subject: [PATCH 07/11] update comment if already exists in pull request --- .github/workflows/build.yml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 60fc2d186..f58f665e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -89,18 +89,22 @@ jobs: report+="| ${artifact_name} | ${artifact_version} | ${artifact_size} |\n" done echo "ARTIFACT_REPORT=$report" >> "$GITHUB_OUTPUT" - - name: Comment artifacts size report + - name: Find potential existing report if: ${{ matrix.java == '11.0.x' }} # do it once - uses: actions/github-script@v6 + uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # 2.4.0 + id: find-comment with: - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: "${{ steps.artifacts-size-report.outputs.ARTIFACT_REPORT }}" - }) - + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: Artifacts Size Report + - name: Artifacts size report in comment + if: ${{ matrix.java == '11.0.x' }} # do it once + 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: "${{ steps.artifacts-size-report.outputs.ARTIFACT_REPORT }}" + edit-mode: replace savepr: runs-on: ubuntu-latest name: Save PR number if running on PR by dependabot From 5b73ac6a1521e58bb56c4a1890932b5d0c62be35 Mon Sep 17 00:00:00 2001 From: Jerome Van Der Linden Date: Thu, 15 Jun 2023 23:00:52 +0200 Subject: [PATCH 08/11] update comment if already exists in pull request --- .github/workflows/build.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f58f665e3..ae5132f01 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -77,18 +77,16 @@ jobs: id: artifacts-size-report if: ${{ matrix.java == '11.0.x' }} # do it once run: | - report='## Artifacts Size Report\n\n' - report+='| Module | Version | Size |\n' - report+='| --- | --- | --- |\n' + echo '## Artifacts Size Report' > report.md + echo '| Module | Version | Size |' >> 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) - echo "$artifact_name = $artifact_size" - report+="| ${artifact_name} | ${artifact_version} | ${artifact_size} |\n" + echo "| ${artifact_name} | ${artifact_version} | ${artifact_size} |" >> report.md done - echo "ARTIFACT_REPORT=$report" >> "$GITHUB_OUTPUT" - name: Find potential existing report if: ${{ matrix.java == '11.0.x' }} # do it once uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # 2.4.0 @@ -97,13 +95,13 @@ jobs: issue-number: ${{ github.event.pull_request.number }} comment-author: 'github-actions[bot]' body-includes: Artifacts Size Report - - name: Artifacts size report in comment + - name: Write artifacts size report in comment if: ${{ matrix.java == '11.0.x' }} # do it once 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: "${{ steps.artifacts-size-report.outputs.ARTIFACT_REPORT }}" + body-path: 'report.md' edit-mode: replace savepr: runs-on: ubuntu-latest From a52cbd072189f40d367eff859d2520d148266605 Mon Sep 17 00:00:00 2001 From: Jerome Van Der Linden Date: Fri, 16 Jun 2023 09:33:05 +0200 Subject: [PATCH 09/11] human readable size --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ae5132f01..7398670b1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -77,14 +77,15 @@ jobs: id: artifacts-size-report if: ${{ matrix.java == '11.0.x' }} # do it once run: | - echo '## Artifacts Size Report' > report.md - echo '| Module | Version | Size |' >> report.md + 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) + artifact_size=$((artifact_size/1000)) echo "| ${artifact_name} | ${artifact_version} | ${artifact_size} |" >> report.md done - name: Find potential existing report From 450d67c17a36011747eb8d462640793a999d0706 Mon Sep 17 00:00:00 2001 From: Jerome Van Der Linden Date: Fri, 16 Jun 2023 11:43:48 +0200 Subject: [PATCH 10/11] float size --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7398670b1..e50f9121e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -85,8 +85,7 @@ jobs: 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) - artifact_size=$((artifact_size/1000)) - echo "| ${artifact_name} | ${artifact_version} | ${artifact_size} |" >> report.md + printf "| %s | %s | %.2f |\n" "$artifact_name" "$artifact_version" "$(bc <<< "scale=2; $artifact_size/1000")" >> report.md done - name: Find potential existing report if: ${{ matrix.java == '11.0.x' }} # do it once From 2dd3222f7ab51056e0e5a8f9aa0171fa75d5675e Mon Sep 17 00:00:00 2001 From: Jerome Van Der Linden Date: Tue, 27 Jun 2023 14:42:03 +0200 Subject: [PATCH 11/11] move artifactsize report out of build --- .github/workflows/pr_artifacts_size.yml | 57 +++++++++++++++++++ .github/workflows/{build.yml => pr_build.yml} | 30 ---------- 2 files changed, 57 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/pr_artifacts_size.yml rename .github/workflows/{build.yml => pr_build.yml} (64%) diff --git a/.github/workflows/pr_artifacts_size.yml b/.github/workflows/pr_artifacts_size.yml new file mode 100644 index 000000000..cbacd78da --- /dev/null +++ b/.github/workflows/pr_artifacts_size.yml @@ -0,0 +1,57 @@ +name: Artifacts Size + +on: + pull_request: + branches: + - master + paths: + - 'powertools-cloudformation/**' + - 'powertools-core/**' + - 'powertools-serialization/**' + - 'powertools-logging/**' + - 'powertools-sqs/**' + - 'powertools-tracing/**' + - 'powertools-validation/**' + - 'powertools-parameters/**' + - 'powertools-idempotency/**' + - 'powertools-metrics/**' + - 'pom.xml' +jobs: + codecheck: + runs-on: ubuntu-latest + 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 + - 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 \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/pr_build.yml similarity index 64% rename from .github/workflows/build.yml rename to .github/workflows/pr_build.yml index e50f9121e..73ae67553 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/pr_build.yml @@ -73,36 +73,6 @@ jobs: if: ${{ matrix.java == '11' }} # publish results once with: files: ./powertools-cloudformation/target/site/jacoco/jacoco.xml,./powertools-core/target/site/jacoco/jacoco.xml,./powertools-idempotency/target/site/jacoco/jacoco.xml,./powertools-logging/target/site/jacoco/jacoco.xml,./powertools-metrics/target/site/jacoco/jacoco.xml,./powertools-parameters/target/site/jacoco/jacoco.xml,./powertools-serialization/target/site/jacoco/jacoco.xml,./powertools-sqs/target/site/jacoco/jacoco.xml,./powertools-tracing/target/site/jacoco/jacoco.xml,./powertools-validation/target/site/jacoco/jacoco.xml - - name: Get artifacts size & build report - id: artifacts-size-report - if: ${{ matrix.java == '11.0.x' }} # do it once - 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 - if: ${{ matrix.java == '11.0.x' }} # do it once - 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 - if: ${{ matrix.java == '11.0.x' }} # do it once - 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 savepr: runs-on: ubuntu-latest name: Save PR number if running on PR by dependabot