Skip to content

Commit

Permalink
[actions] in .github/workflows/manual*: add also test/googletest) to …
Browse files Browse the repository at this point in the history
…github cache; delete all caches; merge welcome/list_cache stages and add goodbye stage in testsuite job, add dependency on cleanup job
  • Loading branch information
valassi committed Nov 1, 2023
1 parent 2d2d4be commit 8acf1ea
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 47 deletions.
28 changes: 10 additions & 18 deletions .github/workflows/manual.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,6 @@ topdir=$(cd $(dirname $0)/../..; pwd)

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

# 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)"
}

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

# Code generation stage
function codegen() {
cd ${topdir}/epochX/cudacpp
Expand Down Expand Up @@ -118,6 +101,15 @@ function tput_ini() {
echo
echo "ccache -s (before the builds)"
ccache -s
# Check if googletest has already been installed and configured
if [ -d ${topdir}/test/googletest ]; then
echo "Directory ${topdir}/test/googletest already exists (retrieved from cache)"
echo "ls ${topdir}/test/googletest (start)"
ls ${topdir}/test/googletest
echo "ls ${topdir}/test/googletest (end)"
else
echo "Directory ${topdir}/test/googletest does not exist: it will be created during the build"
fi
}

#----------------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -165,7 +157,7 @@ function usage() {
#----------------------------------------------------------------------------------------------------------------------------------

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

# Check input arguments
for astage in $stages; do
Expand Down
76 changes: 47 additions & 29 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,67 +29,72 @@ jobs:

# See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy
cleanup:
###if: ${{ false }} # disable the job (comment this out to enable it!)
runs-on: ubuntu-latest
permissions:
actions: write # this is required to delete caches
contents: read
steps:
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
echo "Fetching list of cache keys"
cacheKeys=$(gh actions-cache list -R $REPO | cut -f 1 )
set +e # do not fail while deleting cache keys
echo "Deleting caches..."
for cacheKey in $cacheKeys; do gh actions-cache delete $cacheKey -R $REPO --confirm; done
echo "Deleting caches... done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: cleanup_cache
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
echo "List cache keys (start)"
gh actions-cache list -R $REPO --sort created-at --order asc
echo "List cache keys (end)"
cacheKeys=$(gh actions-cache list -R $REPO --sort created-at --order asc | cut -f 1) # delete ALL caches
###cacheKeys=$(gh actions-cache list -R $REPO --sort created-at --order asc | cut -f 1 | head --lines=-1) # keep only the most recent cache
set +e # do not fail while deleting cache keys
echo "Deleting caches..."
for cacheKey in $cacheKeys; do gh actions-cache delete $cacheKey -R $REPO --confirm; done
echo "Deleting caches... done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

manualtestsuite:
testsuite:
runs-on: ubuntu-latest
needs: cleanup

steps:
- # See https://github.com/actions/checkout
# (NB actions/checkout@v2 is deprecated)
# (NB actions/checkout@v4 need "Allow owner and select non-owner" and "Allow actions created by github")
# (NB actions/checkout needs "Allow owner and select non-owner" and "Allow actions created by github")
uses: actions/checkout@v4
with:
submodules: 'true'

- name: welcome
run: .github/workflows/manual.sh welcome

- name: codegen
run: .github/workflows/manual.sh codegen

- # See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy
name: list_cached
- name: WELCOME
run: |
echo "WELCOME! $(date)"
echo "Current directory is $(pwd)"
echo "Current git commit is $(git log --oneline -n1 | cut -d' ' -f1)"
# See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
echo "List cache keys (start)"
gh actions-cache list -R $REPO | cut -f 1
gh actions-cache list -R $REPO --sort created-at --order asc
echo "List cache keys (end)"
env:
GH_TOKEN: ${{ github.token }}

- # See https://github.com/actions/cache
# See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
name: restore_cache
- name: restore_cache
id: cache-restore
# See https://github.com/actions/cache
# See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
uses: actions/cache/restore@v3
with:
path: |
CCACHE_DIR
DOWNLOADS
test/googletest
key: cache-${{ runner.os }}-${{ github.run_id }}
restore-keys:
cache-${{ runner.os }}

- name: codegen
run: .github/workflows/manual.sh codegen

- name: tput_ini
run: .github/workflows/manual.sh tput_ini

Expand All @@ -99,16 +104,29 @@ jobs:
- name: tput_fin
run: .github/workflows/manual.sh tput_fin

- # See https://github.com/actions/cache
name: update_cache
- name: update_cache
id: cache-update
# See https://github.com/actions/cache
uses: actions/cache/save@v3
with:
path: |
CCACHE_DIR
DOWNLOADS
test/googletest
key: cache-${{ runner.os }}-${{ github.run_id }}

- name: GOODBYE
run: |
echo "GOODBYE! $(date)"
echo "Current directory is $(pwd)"
echo "Current git commit is $(git log --oneline -n1 | cut -d' ' -f1)"
REPO=${{ github.repository }}
echo "List cache keys (start)"
gh actions-cache list -R $REPO --sort created-at --order asc
echo "List cache keys (end)"
env:
GH_TOKEN: ${{ github.token }}

#- name: Send greeting
# run: echo "Hello ${{ inputs.name }}"

Expand Down

0 comments on commit 8acf1ea

Please sign in to comment.