Skip to content

Commit

Permalink
initialize all variables explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-mm committed Sep 28, 2023
1 parent 0fdd744 commit f92d755
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
28 changes: 28 additions & 0 deletions scripts/display_results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ set -euo pipefail
source "$(dirname "$0")/vars.sh" read_vars

function display_results {
# First get values, in case any are unbound
# this will set them to an empty string if they are missing entirely
MEASUREMENT_RAN=${MEASUREMENT_RAN:-}
MODEL_NAME=${MODEL_NAME:-}
TDP=${TDP:-}
CPU_THREADS=${CPU_THREADS:-}
CPU_CORES=${CPU_CORES:-}
CPU_MAKE=${CPU_MAKE:-}
RELEASE_YEAR=${RELEASE_YEAR:-}
RAM=${RAM:-}
CPU_FREQ=${CPU_FREQ:-}
CPU_CHIPS=${CPU_CHIPS:-}
VHOST_RATIO=${VHOST_RATIO:-}
PREVIOUS_VENV=${PREVIOUS_VENV:-}
MEASUREMENT_COUNT=${MEASUREMENT_COUNT:-}
WORKFLOW_ID=${WORKFLOW_ID:-}
API_BASE=${API_BASE:-}


output="/tmp/eco-ci/output.txt"
output_pr="/tmp/eco-ci/output-pr.txt"

Expand Down Expand Up @@ -123,6 +142,15 @@ function display_results {
while [[ $# -gt 0 ]]; do
opt="$1"

branch=""
display_badge=""
run_id=""
repo=""
display_table=""
display_graph=""
send_data=""
source=""

case $opt in
-b|--branch)
branch="$2"
Expand Down
26 changes: 25 additions & 1 deletion scripts/make_measurement.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,24 @@ set -euo pipefail
source "$(dirname "$0")/vars.sh" read_vars

function make_measurement() {
# First get values, in case any are unbound
# this will set them to an empty string if they are missing entirely
MODEL_NAME=${MODEL_NAME:-}
TDP=${TDP:-}
CPU_THREADS=${CPU_THREADS:-}
CPU_CORES=${CPU_CORES:-}
CPU_MAKE=${CPU_MAKE:-}
RELEASE_YEAR=${RELEASE_YEAR:-}
RAM=${RAM:-}
CPU_FREQ=${CPU_FREQ:-}
CPU_CHIPS=${CPU_CHIPS:-}
VHOST_RATIO=${VHOST_RATIO:-}
PREVIOUS_VENV=${PREVIOUS_VENV:-}
MEASUREMENT_COUNT=${MEASUREMENT_COUNT:-}
WORKFLOW_ID=${WORKFLOW_ID:-}
API_BASE=${API_BASE:-}

# check wc -l of cpu-util is greater than 0
echo $(cat /tmp/eco-ci/cpu-util.txt)
if [[ $(wc -l < /tmp/eco-ci/cpu-util.txt) -gt 0 ]]; then
# if a previous venv is already active,
if type deactivate &>/dev/null
Expand Down Expand Up @@ -94,6 +110,14 @@ function make_measurement() {

while [[ $# -gt 0 ]]; do
opt="$1"
label=""
run_id=""
branch=""
repo=""
commit_hash=""
send_data=""
source=""

case $opt in
-l|--label)
label="$2"
Expand Down
8 changes: 1 addition & 7 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ function initialize {
# install go ascii

if [[ $install_go == true ]]; then
# || true here because this line technically fails with:
# no required module provides package github.com/guptarohit/asciigraph/cmd/asciigraph: go.mod file not found in current directory or any parent directory; see 'go help modules'
# the solution would be either to `go mod init` to create a go.mod file for this directory... but are not making a go package here so this doesn't seem appropriate
# the other solution would be to set the environment variable `go env -w GO111MODULE=auto`... but I can't seem to get any already-set value ahead of time reliably, and do not want to overwrite
# any user environment settings.
# So, we ignore this error for now, as functionally the asciigraph still is installed and works for Eco-CI
go install github.com/guptarohit/asciigraph/cmd/asciigraph@latest
fi

Expand All @@ -46,7 +40,7 @@ function setup_python {

VENV_VALUE=${VIRTUAL_ENV:-}
PREVIOUS_VENV=''

if [[ $VENV_VALUE != '' ]]; then
PREVIOUS_VENV=$VENV_VALUE
source "$(dirname "$0")/vars.sh" add_var PREVIOUS_VENV $PREVIOUS_VENV
Expand Down

0 comments on commit f92d755

Please sign in to comment.