diff --git a/.github/workflows/build_tests.yml b/.github/workflows/build_tests.yml index 7dde621a72f..7a024172368 100644 --- a/.github/workflows/build_tests.yml +++ b/.github/workflows/build_tests.yml @@ -153,7 +153,7 @@ jobs: run: | cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: oppia-bazel.apk path: /home/runner/work/oppia-android/oppia-android/oppia.apk diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 84cc12006a8..f5ba874970e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -64,7 +64,7 @@ jobs: # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 run: sudo ./gradlew --full-stacktrace :utility:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME - name: Upload Utility Test Reports - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status with: name: utility reports @@ -77,7 +77,7 @@ jobs: # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 run: sudo ./gradlew --full-stacktrace :data:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME - name: Upload Data Test Reports - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status with: name: data reports @@ -90,7 +90,7 @@ jobs: # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 run: sudo ./gradlew --full-stacktrace :domain:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME - name: Upload Domain Test Reports - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status with: name: domain reports @@ -103,7 +103,7 @@ jobs: # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 run: sudo ./gradlew --full-stacktrace :testing:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME - name: Upload Testing Test Reports - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status with: name: testing reports @@ -144,7 +144,7 @@ jobs: run: | sudo ./gradlew --full-stacktrace :app:testDebugUnitTest --${{ matrix.shard }} -Dorg.gradle.java.home=$JAVA_HOME - name: Upload App Test Reports - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status with: name: app reports ${{ matrix.shard }} diff --git a/.github/workflows/stats.yml b/.github/workflows/stats.yml index de3ce5fadd5..74cbbeabbed 100644 --- a/.github/workflows/stats.yml +++ b/.github/workflows/stats.yml @@ -184,6 +184,63 @@ jobs: beta $(pwd)/oppia_beta_without_changes.aab $(pwd)/oppia_beta_with_changes.aab \ ga $(pwd)/oppia_ga_without_changes.aab $(pwd)/oppia_ga_with_changes.aab + - name: Find CI workflow run for PR + id: find-workflow-run + uses: actions/github-script@v7 + continue-on-error: true + with: + script: | + const { owner, repo } = context.repo; + const runsResponse = await github.rest.actions.listWorkflowRuns({ + owner, + repo, + workflow_id: 'stats.yml', + }); + + const runs = runsResponse.data.workflow_runs; + runs.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()); + + const run = runs[1]; + if(!run) { + core.setFailed('Could not find a succesful workflow run'); + return; + } + console.log(run.id); + + core.setOutput('run-id', run.id); + + - name: Download previous build summary + uses: actions/download-artifact@v4 + with: + name: brief_build_summary_${{ matrix.prInfo.number }} + path: ./previous_build_logs + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ steps.find-workflow-run.outputs.run-id }} + continue-on-error: true # Ignore errors if the file doesn't exist (first run) + + - name: Compare current build summary with the previous one + id: build-comparison + run: | + if [ -f ./develop/brief_build_summary.log ]; then + echo "Comparing current and previous build summaries..." + if diff ./develop/brief_build_summary.log ./previous_build_logs/brief_build_summary.log > /dev/null; then + echo "No changes detected; skipping comment." + echo "skip_comment=true" >> $GITHUB_ENV + else + echo "Changes detected; proceeding with the comment." + echo "skip_comment=false" >> $GITHUB_ENV + fi + else + echo "No previous summary found; proceeding with the comment." + echo "skip_comment=false" >> $GITHUB_ENV + fi + + - name: Upload current build summary for future comparison + uses: actions/upload-artifact@v4 + with: + name: brief_build_summary_${{ matrix.prInfo.number }} + path: ./develop/brief_build_summary.log + # Reference: https://github.com/peter-evans/create-or-update-comment#setting-the-comment-body-from-a-file. # Also, for multi-line env values, see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings. - name: Extract reports for uploading & commenting @@ -203,6 +260,7 @@ jobs: cp "$GITHUB_WORKSPACE/develop/full_build_summary.log" "$FULL_BUILD_SUMMARY_FILE_PATH" - name: Add build stats summary comment + if: ${{ env.skip_comment == 'false' }} env: PR_NUMBER: ${{ matrix.prInfo.number }} uses: peter-evans/create-or-update-comment@v1 @@ -210,7 +268,7 @@ jobs: issue-number: ${{ env.PR_NUMBER }} body: ${{ steps.compute-comment-body.outputs.comment_body }} - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ${{ env.FULL_BUILD_SUMMARY_FILE_NAME }} path: ${{ env.FULL_BUILD_SUMMARY_FILE_PATH }}