diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c207e7ea115c..19cef6f3912c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -159,6 +159,25 @@ jobs: AWS_ACCESS_KEY_ID: "${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}" AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}" if: "success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')" + - name: gather collected metrics + run: src/ci/scripts/gather-metrics.sh build + if: always() && !env.SKIP_JOB + - name: upload metrics to GitHub Artifact for windows + uses: actions/upload-artifact@v3 + with: + name: "metrics-${CI_JOB_NAME}" + path: "build\\cpu-${CI_JOB_NAME}.csv\nbuild\\metrics-${CI_JOB_NAME}.json\n" + if-no-files-found: ignore + retention-days: 5 + if: "always() && !env.SKIP_JOB && contains(matrix.os, 'windows')" + - name: upload metrics to GitHub Artifact for linux + uses: actions/upload-artifact@v3 + with: + name: "metrics-${CI_JOB_NAME}" + path: "obj/build/cpu-${CI_JOB_NAME}.csv\nobj/build/metrics-${CI_JOB_NAME}.json\n" + if-no-files-found: ignore + retention-days: 5 + if: "always() && !env.SKIP_JOB && (contains(matrix.os, 'linux') || contains(matrix.os, 'ubuntu'))" auto: name: "auto - ${{ matrix.name }}" env: @@ -524,6 +543,25 @@ jobs: AWS_ACCESS_KEY_ID: "${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}" AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}" if: "success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')" + - name: gather collected metrics + run: src/ci/scripts/gather-metrics.sh build + if: always() && !env.SKIP_JOB + - name: upload metrics to GitHub Artifact for windows + uses: actions/upload-artifact@v3 + with: + name: "metrics-${CI_JOB_NAME}" + path: "build\\cpu-${CI_JOB_NAME}.csv\nbuild\\metrics-${CI_JOB_NAME}.json\n" + if-no-files-found: ignore + retention-days: 5 + if: "always() && !env.SKIP_JOB && contains(matrix.os, 'windows')" + - name: upload metrics to GitHub Artifact for linux + uses: actions/upload-artifact@v3 + with: + name: "metrics-${CI_JOB_NAME}" + path: "obj/build/cpu-${CI_JOB_NAME}.csv\nobj/build/metrics-${CI_JOB_NAME}.json\n" + if-no-files-found: ignore + retention-days: 5 + if: "always() && !env.SKIP_JOB && (contains(matrix.os, 'linux') || contains(matrix.os, 'ubuntu'))" try: name: "try - ${{ matrix.name }}" env: @@ -644,6 +682,25 @@ jobs: AWS_ACCESS_KEY_ID: "${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}" AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}" if: "success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')" + - name: gather collected metrics + run: src/ci/scripts/gather-metrics.sh build + if: always() && !env.SKIP_JOB + - name: upload metrics to GitHub Artifact for windows + uses: actions/upload-artifact@v3 + with: + name: "metrics-${CI_JOB_NAME}" + path: "build\\cpu-${CI_JOB_NAME}.csv\nbuild\\metrics-${CI_JOB_NAME}.json\n" + if-no-files-found: ignore + retention-days: 5 + if: "always() && !env.SKIP_JOB && contains(matrix.os, 'windows')" + - name: upload metrics to GitHub Artifact for linux + uses: actions/upload-artifact@v3 + with: + name: "metrics-${CI_JOB_NAME}" + path: "obj/build/cpu-${CI_JOB_NAME}.csv\nobj/build/metrics-${CI_JOB_NAME}.json\n" + if-no-files-found: ignore + retention-days: 5 + if: "always() && !env.SKIP_JOB && (contains(matrix.os, 'linux') || contains(matrix.os, 'ubuntu'))" master: name: master runs-on: ubuntu-latest diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index 93b07350ac172..67571a9236272 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -249,6 +249,41 @@ x--expand-yaml-anchors--remove: if: success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1') <<: *step + - name: gather collected metrics + run: src/ci/scripts/gather-metrics.sh build + if: always() && !env.SKIP_JOB + <<: *step + + - name: upload metrics to GitHub Artifact for windows + uses: actions/upload-artifact@v3 + with: + name: metrics-${CI_JOB_NAME} + path: | + build\cpu-${CI_JOB_NAME}.csv + build\metrics-${CI_JOB_NAME}.json + if-no-files-found: ignore + retention-days: 5 + # Having `always` makes metric collection always happen even if the prior + # steps fail. This is useful because the whole point of metrics is to + # help gathering information about the runtime of the CI. + if: always() && !env.SKIP_JOB && contains(matrix.os, 'windows') + <<: *step + + - name: upload metrics to GitHub Artifact for linux + uses: actions/upload-artifact@v3 + with: + name: metrics-${CI_JOB_NAME} + path: | + obj/build/cpu-${CI_JOB_NAME}.csv + obj/build/metrics-${CI_JOB_NAME}.json + if-no-files-found: ignore + retention-days: 5 + # Having `always` makes metric collection always happen even if the prior + # steps fail. This is useful because the whole point of metrics is to + # help gathering information about the runtime of the CI. + if: always() && !env.SKIP_JOB && (contains(matrix.os, 'linux') || contains(matrix.os, 'ubuntu')) + <<: *step + # These snippets are used by the try-success, try-failure, auto-success and auto-failure jobs. # Check out their documentation for more information on why they're needed. diff --git a/src/ci/scripts/gather-metrics.sh b/src/ci/scripts/gather-metrics.sh new file mode 100755 index 0000000000000..13e4ddc983014 --- /dev/null +++ b/src/ci/scripts/gather-metrics.sh @@ -0,0 +1,24 @@ +#!/bin/bash -eux + +if [ -z "${upload_dir+x}" ]; then + upload_dir="$1" +fi + +if [ -z "${build_dir+x}" ]; then + source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" + + build_dir="build" + + if isLinux; then + build_dir=obj/build + fi + +fi + +# CPU usage statistics. +cp build/cpu-usage.csv "${upload_dir}/cpu-${CI_JOB_NAME}.csv" + +if [ -f "${build_dir}/metrics.json" ]; then + # Build metrics generated by x.py. + cp "${build_dir}/metrics.json" "${upload_dir}/metrics-${CI_JOB_NAME}.json" +fi diff --git a/src/ci/scripts/upload-artifacts.sh b/src/ci/scripts/upload-artifacts.sh index 9755edb6dce58..6437f76badd6c 100755 --- a/src/ci/scripts/upload-artifacts.sh +++ b/src/ci/scripts/upload-artifacts.sh @@ -22,11 +22,7 @@ if [[ "${DEPLOY-0}" -eq "1" ]] || [[ "${DEPLOY_ALT-0}" -eq "1" ]]; then cp -r "${dist_dir}"/* "${upload_dir}" fi -# CPU usage statistics. -cp build/cpu-usage.csv "${upload_dir}/cpu-${CI_JOB_NAME}.csv" - -# Build metrics generated by x.py. -cp "${build_dir}/metrics.json" "${upload_dir}/metrics-${CI_JOB_NAME}.json" +source "$(cd "$(dirname "$0")" && pwd)/gather-metrics.sh" # Toolstate data. if [[ -n "${DEPLOY_TOOLSTATES_JSON+x}" ]]; then