Skip to content
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

feat: add upload-metrics-artifact GitHub Action ✨ #348

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
47 changes: 47 additions & 0 deletions github-actions/upload-metrics-artifact/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Upload Metrics Artifact

This GitHub Action will upload metrics collected by CI run to GitHub Artifacts.
This allows for future runners or other actions to download the artifact and
upload them to S3 bucket that is used for monitoring GitHub CI.

You can follow the discussion in [the corresponding GitHub issue][issue-source].

## Usage

If the default metrics' file path is `build/cpu-usage.csv`, you don't need to
pass any argument to the runner.

Note: the default metrics' file path for Rust compiler repository is
`build/cpu-usage.csv` as you can see in the workflow file
[here][rust-cpu-collector-ci] and [here][rust-cpu-collector-script].

```yaml
- name: Upload metrics artifact
uses: rust-lang/simpleinfra/github-actions/upload-metrics-artifact@master
```

If the metrics is stored in a different file, you can pass the path to the
action:

```yaml
- name: Upload metrics artifact
uses: rust-lang/simpleinfra/github-actions/upload-metrics-artifact@master
with:
metrics-filepath: |
file1.csv
file2.csv
file3.csv
```

## Development

This is a composite GitHub Action, and as such, you can run the action using
[`act`][act-github]. You can also use one of the above syntaxes in your own
fork of this repository. Here's one [test-run][first-test-run] for your
reference.

[issue-source]: https://github.com/rust-lang/infra-team/issues/74
[act-github]: https://github.com/nektos/act
[rust-cpu-collector-ci]: https://github.com/rust-lang/rust/blob/1.72.1/.github/workflows/ci.yml#L90
[rust-cpu-collector-script]: https://github.com/rust-lang/rust/blob/1.72.1/src/ci/scripts/collect-cpu-stats.sh#L10
[first-test-run]: https://github.com/meysam81/simpleinfra/actions/runs/6283641163
17 changes: 17 additions & 0 deletions github-actions/upload-metrics-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Upload metrics artifact
description: Upload collected [cpu] metrics to GitHub artifact to later upload to S3 bucket from a trusted runner

inputs:
metrics-filepath:
description: Comma or space separated list of metrics files to be uploaded to GitHub artifact
required: true
default: build/cpu-usage.csv

runs:
using: composite
steps:
- name: Upload metrics artifact
uses: actions/upload-artifact@v3
with:
name: Upload metrics
path: ${{ github.workspace }}/${{ inputs.metrics-filepath }}
Comment on lines +13 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be easier to use the actions/upload-artifact@v3 action directly? 🤔