Skip to content

feat(ci): upload metrics to GitHub Artifacts ✨ #116517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
24 changes: 24 additions & 0 deletions src/ci/scripts/gather-metrics.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 1 addition & 5 deletions src/ci/scripts/upload-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down