Skip to content

Commit

Permalink
Per #1546, moved time_command function into a file to be sourced by e…
Browse files Browse the repository at this point in the history
…ach script that needs to use it
  • Loading branch information
georgemccabe committed Jan 20, 2022
1 parent e85c79c commit f2dbb7d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
16 changes: 16 additions & 0 deletions .github/jobs/bash_functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/bash

# utility function to run command get log the time it took to run
function time_command {
local start_seconds=$SECONDS
echo "RUNNING: $*"
"$@"
local error=$?

local duration=$(( SECONDS - start_seconds ))
echo "TIMING: Command took `printf '%02d' $(($duration / 60))`:`printf '%02d' $(($duration % 60))` (MM:SS): '$*'"
if [ ${error} -ne 0 ]; then
echo "ERROR: '$*' exited with status = ${error}"
fi
return $error
}
7 changes: 1 addition & 6 deletions .github/jobs/build_docker_image.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#! /bin/bash

# utility function to run command get log the time it took to run
function time_command {
local start_seconds=$SECONDS
echo "RUNNING: $*"
"$@"
local error=$?
source ${GITHUB_WORKSPACE}/.github/jobs/bash_functions.sh

local duration=$(( SECONDS - start_seconds ))
echo "TIMING: Command took `printf '%02d' $(($duration / 60))`:`printf '%02d' $(($duration % 60))` (MM:SS): '$*'"
Expand Down
15 changes: 1 addition & 14 deletions .github/jobs/push_docker_image.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
#! /bin/bash

# utility function to run command get log the time it took to run
function time_command {
local start_seconds=$SECONDS
echo "RUNNING: $*"
"$@"
local error=$?

local duration=$(( SECONDS - start_seconds ))
echo "TIMING: Command took `printf '%02d' $(($duration / 60))`:`printf '%02d' $(($duration % 60))` (MM:SS): '$*'"
if [ ${error} -ne 0 ]; then
echo "ERROR: '$*' exited with status = ${error}"
fi
return $error
}
source ${GITHUB_WORKSPACE}/.github/jobs/bash_functions.sh

prefix=refs/heads/
branch_name=${GITHUB_REF#"$prefix"}
Expand Down

0 comments on commit f2dbb7d

Please sign in to comment.