Skip to content

Commit

Permalink
[actions] in actions, restructure manual.sh as a set of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
valassi committed Oct 31, 2023
1 parent 5570c7f commit b54bf8b
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 58 deletions.
149 changes: 95 additions & 54 deletions .github/workflows/manual.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,36 @@
###set -x

# Automatic exit on error
set -e
###set -e

# Usage
function usage() {
echo "Usage: $(basename $0) codegen|tput"
exit 1
}
# Path to the top directory of madgraphgpu
# In the CI this would be simply $(pwd), but allow the script to be run also outside the CI
echo "Executing $0 $*"; echo
topdir=$(cd $(dirname $0)/../..; pwd)

# Check input arguments
if [ "$1" == "codegen" ]; then
stage=$1
shift
elif [ "$1" == "tput" ]; then
stage=$1
shift
else
usage
fi
#----------------------------------------------------------------------------------------------------------------------------------

# Exit status
status=0
# Welcome
function welcome() {
cd ${topdir}
echo "Current directory is $(pwd)"
echo "Current git commit is $(git log --oneline -n1 | cut -d' ' -f1)"
#echo
#echo "Contents of . (start)"
#ls
#echo "Contents of . (end)"
#echo
#echo "Contents of MG5aMC/mg5amcnlo (start)"
#ls MG5aMC/mg5amcnlo
#echo "Contents of MG5aMC/mg5amcnlo (end)"
}

# Initialise
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo "[manual.sh] $stage starting at $(date)"
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
#----------------------------------------------------------------------------------------------------------------------------------

echo
echo "Current directory is $(pwd)"
echo "Current git commit is $(git log --oneline -n1 | cut -d' ' -f1)"
topdir=$(pwd)

#echo
#echo "Contents of . (start)"
#ls
#echo "Contents of . (end)"

#echo
#echo "Contents of MG5aMC/mg5amcnlo (start)"
#ls MG5aMC/mg5amcnlo
#echo "Contents of MG5aMC/mg5amcnlo (end)"

# Code generation
if [ "$stage" == "codegen" ]; then
# Code generation stage
function codegen() {
cd ${topdir}/epochX/cudacpp
echo "Current directory is $(pwd)"
###processes="$(git ls-tree --name-only HEAD *.mad *.sa)"
processes="gg_tt.mad" # FOR QUICK TESTS
for proc in $processes; do
Expand Down Expand Up @@ -81,48 +66,104 @@ if [ "$stage" == "codegen" ]; then
git diff --exit-code
echo "git diff (end)"
done
fi
}

# Tput tests (build, runTest.exe, check.exe, gcheck.exe)
if [ "$stage" == "tput" ]; then
cd ${topdir}/epochX/cudacpp
# Install ccache
#----------------------------------------------------------------------------------------------------------------------------------

function setup_ccache {
# Set up ccache environment
export PATH=${topdir}/BIN:$PATH
export CCACHE_DIR=${topdir}/CCACHE_DIR
}

function tput_ini() {
# Install and configure ccache
mkdir ${topdir}/BIN
cd ${topdir}/BIN
echo "Current directory is $(pwd)"
echo
echo "wget -q https://github.com/ccache/ccache/releases/download/v4.8.3/ccache-4.8.3-linux-x86_64.tar.xz"
wget -q https://github.com/ccache/ccache/releases/download/v4.8.3/ccache-4.8.3-linux-x86_64.tar.xz
echo
echo "tar -xvf ccache-4.8.3-linux-x86_64.tar.xz"
tar -xvf ccache-4.8.3-linux-x86_64.tar.xz
export PATH=$(pwd)/ccache-4.8.3-linux-x86_64:$PATH
# Configure ccache
mkdir $(pwd)/CCACHE_DIR
export CCACHE_DIR=$(pwd)/CCACHE_DIR
ln -sf ccache-4.8.3-linux-x86_64/ccache .
mkdir ${topdir}/CCACHE_DIR
# Set up ccache environment
setup_ccache
# Dump ccache status before the builds
echo
echo "ccache --version | head -1"
ccache --version | head -1
# Dump ccache status before the builds
echo
echo "ccache -s (before the builds)"
ccache -s
# Configure CXX
}

#----------------------------------------------------------------------------------------------------------------------------------

# Tput test stage (build, runTest.exe, check.exe, gcheck.exe)
function tput_run() {
cd ${topdir}/epochX/cudacpp
echo "Current directory is $(pwd)"
# Set up ccache environment
setup_ccache
# Dump g++ environment
echo
echo "g++ --version"
g++ --version
export CXX=g++
# Build and test
export CXX=g++ # set up CXX that is needed by cudacpp.mk
export USECCACHE=1 # enable ccache in madgraph4gpu builds
echo "./tput/teeThroughputX.sh -makej -ggtt -makeclean"
./tput/teeThroughputX.sh -makej -ggtt -makeclean
}

#----------------------------------------------------------------------------------------------------------------------------------

function tput_fin() {
# Set up ccache environment
setup_ccache
# Dump ccache status after the builds
echo
echo "ccache -s (after the builds)"
ccache -s
fi
}

#----------------------------------------------------------------------------------------------------------------------------------

# Usage
function usage() {
echo "Usage: $(basename $0) <${stages// /|}>"
exit 1
}

#----------------------------------------------------------------------------------------------------------------------------------

# Valid stages
stages="welcome codegen tput_ini tput_run tput_fin"

# Check input arguments
for astage in $stages; do
if [ "$1" == "$astage" ]; then
stage=$1; shift; break
fi
done
if [ "$stage" == "" ] || [ "$1" != "" ]; then usage; fi

# Start
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo "[manual.sh] $stage starting at $(date)"
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"

# Execute stage
( set -e; $stage ) # execute this within a subprocess and fail immediately on error
status=$?

# Finalise
# Finish
echo
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
if [ $status -eq 0 ]; then # keep this just in case, but 'set -e' causes immediate exit on any error
if [ $status -eq 0 ]; then
echo "[manual.sh] $stage finished with status=$status (OK) at $(date)"
else
echo "[manual.sh] $stage finished with status=$status (NOT OK) at $(date)"
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: 'true'
#- name: codegen_step
# run: .github/workflows/manual.sh codegen
- name: tput_step
run: .github/workflows/manual.sh tput
- name: welcome
run: .github/workflows/manual.sh welcome
- name: codegen
run: .github/workflows/manual.sh codegen
- name: tput_ini
run: .github/workflows/manual.sh tput_ini
- name: tput_run
run: .github/workflows/manual.sh tput_run
- name: tput_fin
run: .github/workflows/manual.sh tput_fin
#- name: Send greeting
# run: echo "Hello ${{ inputs.name }}"

0 comments on commit b54bf8b

Please sign in to comment.