Skip to content

Commit

Permalink
feat: Introduce a metrics workflow (PLC-lang#786)
Browse files Browse the repository at this point in the history
This commit introduces a workflow to continuously run and collect benchmark data whenever the master branch receives a commit. The collected data is appended onto a JSON file located in the `metrics-data` RuSTy branch which in turn is used by our frontend[1] to display the data graphically to track RuSTys performance over time.

[1] https://plc-lang.github.io/metrics/
  • Loading branch information
volsa authored Mar 2, 2023
1 parent a0b9a14 commit ef7c70f
Show file tree
Hide file tree
Showing 17 changed files with 731 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
xtask = "run --manifest-path ./xtask/Cargo.toml --"
32 changes: 32 additions & 0 deletions .github/workflows/metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Metrics

on:
push:
branches:
- master

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
IMAGE_NAME: rust-llvm
IMAGE_VERSION: latest

jobs:
metrics:
name: Metrics
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: master

- name: Collect metrics
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$IMAGE_VERSION
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker pull $IMAGE_ID
./scripts/build.sh --metrics --container --container-name=$IMAGE_ID --ci
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,4 @@
*.o
*.bc
*.a
*.elf

# Introduced with issue #679:
# We're assuming config.toml to be a local config file for now.
# This entry has to be removed if a global config file is needed in the near future.
.cargo/config.toml
*.elf
51 changes: 40 additions & 11 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ vendor=0
offline=0
check=0
check_style=0
metrics=0
build=0
doc=0
test=0
Expand All @@ -14,6 +15,7 @@ debug=0
container=0
assume_linux=0
junit=0
ci=0

CONTAINER_NAME='rust-llvm'

Expand Down Expand Up @@ -78,23 +80,28 @@ function run_build() {

function run_check() {
CARGO_OPTIONS=$(set_cargo_options)
log "Running cargo check"
log "Running cargo check"
cargo check $CARGO_OPTIONS
}

function run_metrics() {
log "Running cargo xtask metrics"
cargo xtask metrics
}

function run_doc() {
CARGO_OPTIONS=$(set_cargo_options)
log "Running cargo doc"
log "Running cargo doc"
cargo doc $CARGO_OPTIONS
log "Building book"
cd book && mdbook build && mdbook test
}

function run_check_style() {
CARGO_OPTIONS=$(set_cargo_options)
log "Running cargo clippy"
log "Running cargo clippy"
cargo clippy $CARGO_OPTIONS -- -Dwarnings
log "Running cargo fmt check"
log "Running cargo fmt check"
cargo fmt -- --check
}

Expand Down Expand Up @@ -136,6 +143,8 @@ function set_offline() {
function run_in_container() {
container_engine=$(get_container_engine)
params=""
options=""

if [[ $offline -ne 0 ]]; then
params="$params --offline"
fi
Expand All @@ -148,6 +157,9 @@ function run_in_container() {
if [[ $check_style -ne 0 ]]; then
params="$params --check-style"
fi
if [[ $metrics -ne 0 ]]; then
params="$params --metrics"
fi
if [[ $build -ne 0 ]]; then
params="$params --build"
fi
Expand All @@ -166,6 +178,9 @@ function run_in_container() {
if [[ $doc -ne 0 ]]; then
params="$params --doc"
fi
if [[ $ci -ne 0 ]]; then
options="$options --env=CI_RUN=true"
fi

volume_target="/build"
unameOut="$(uname -s)"
Expand All @@ -184,7 +199,7 @@ function run_in_container() {
build_location=$(sanitize_path "$project_location")
log "Sanitized Project location : $project_location"

command_to_run="$container_engine run -v $build_location:$volume_target $CONTAINER_NAME scripts/build.sh $params"
command_to_run="$container_engine run $options -v $build_location:$volume_target $CONTAINER_NAME scripts/build.sh $params"
log "Running command : $command_to_run"
eval "$command_to_run"
}
Expand All @@ -193,7 +208,7 @@ function run_in_container() {
set -o errexit -o pipefail -o noclobber -o nounset

OPTIONS=sorbvc
LONGOPTS=sources,offline,release,check,check-style,build,doc,test,junit,verbose,container,linux,container-name:,coverage
LONGOPTS=sources,offline,release,check,check-style,metrics,ci,build,doc,test,junit,verbose,container,linux,container-name:,coverage

check_env
# -activate quoting/enhanced mode (e.g. by writing out “--options”)
Expand Down Expand Up @@ -239,6 +254,12 @@ while true; do
--check)
check=1
;;
--metrics)
metrics=1
;;
--ci)
ci=1
;;
-b|--build)
build=1
;;
Expand Down Expand Up @@ -268,6 +289,10 @@ log "Moving to project level directory $project_location"
cd "$project_location"


if [[ $ci -ne 0 ]]; then
export CI_RUN=true
fi

if [[ $container -ne 0 ]]; then
log "Container Build"
run_in_container
Expand All @@ -288,27 +313,31 @@ if [[ $offline -ne 0 ]]; then
fi

if [[ $check -ne 0 ]]; then
run_check
run_check
fi

if [[ $check_style -ne 0 ]]; then
run_check_style
run_check_style
fi

if [[ $metrics -ne 0 ]]; then
run_metrics
fi

if [[ $build -ne 0 ]]; then
run_build
run_build
fi

if [[ $test -ne 0 ]]; then
run_test
run_test
fi

if [[ $doc -ne 0 ]]; then
run_doc
fi

if [[ $coverage -ne 0 ]]; then
run_coverage
run_coverage
fi

if [[ -d $project_location/target/ ]]; then
Expand Down
1 change: 1 addition & 0 deletions xtask/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
Loading

0 comments on commit ef7c70f

Please sign in to comment.