[actions] in .github/workflows/testsuite, first rough workflow to rep… #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2020-2023 CERN and UCLouvain. | ||
# Licensed under the GNU Lesser General Public License (version 3 or later). | ||
# Created by: A. Valassi (Oct 2023) for the MG5aMC CUDACPP plugin. | ||
# Further modified by: A. Valassi (2023) for the MG5aMC CUDACPP plugin. | ||
#---------------------------------------------------------------------------------------------------------------------------------- | ||
name: Test one process | ||
#---------------------------------------------------------------------------------------------------------------------------------- | ||
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#run-name | ||
run-name: Manually test one process ${{ inputs.process }} (enableFPE = ${{ inputs.enableFPE }}) | ||
#---------------------------------------------------------------------------------------------------------------------------------- | ||
on: | ||
# Trigger the one-process workflow from the all-processes workflow | ||
# See https://stackoverflow.com/a/75337311 | ||
workflow_call: | ||
inputs: | ||
process: # this variable is provided by the matrix in testsuite_allprocesses.yml | ||
required: true | ||
type: string | ||
enableFPE: | ||
required: true | ||
type: boolean | ||
# Manually trigger the one-process workflow | ||
# (the lines below are adapted rom the default github manual workflow example) | ||
workflow_dispatch: | ||
inputs: | ||
process: | ||
description: 'physics process' | ||
default: 'gg_tt.mad' | ||
required: true | ||
type: choice | ||
# FIXME? Can the list of supported processes be specified only once in oneprocess.yml or allprocesses.yml? | ||
options: [ee_mumu.mad, gg_tt.mad, gg_ttg.mad, gg_ttgg.mad, gg_ttggg.mad, gg_tt01g.mad, gq_ttq.mad, pp_tt012j.mad] | ||
enableFPE: | ||
description: 'enable FPE tests?' | ||
default: true | ||
required: true | ||
type: boolean | ||
#---------------------------------------------------------------------------------------------------------------------------------- | ||
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_cache | ||
run: | | ||
gh extension install actions/gh-actions-cache | ||
REPO=${{ github.repository }} | ||
#--- LIST CODEGEN CACHES | ||
echo "List codegencache keys (start)" | ||
gh actions-cache list -R $REPO --sort created-at --order asc --key codegencache-${{ runner.os }}-${{ inputs.process }} | ||
echo "List codegencache keys (end)" | ||
cacheKeysCodegen=$(gh actions-cache list -R $REPO --sort created-at --order asc --key codegencache-${{ runner.os }}-${{ inputs.process }} | cut -f 1) # delete ALL codegen caches | ||
#--- LIST BUILD CACHES (d) | ||
echo "List buildcache keys (start)" | ||
gh actions-cache list -R $REPO --sort created-at --order asc --key buildcache-${{ runner.os }}-${{ inputs.process }}-d | ||
echo "List buildcache keys (end)" | ||
cacheKeysBuildD=$(gh actions-cache list -R $REPO --sort created-at --order asc --key buildcache-${{ runner.os }}-${{ inputs.process }}-d | cut -f 1 | head --lines=-1) # keep only the most recent build cache | ||
#--- LIST BUILD CACHES (f) | ||
echo "List buildcache keys (start)" | ||
gh actions-cache list -R $REPO --sort created-at --order asc --key buildcache-${{ runner.os }}-${{ inputs.process }}-f | ||
echo "List buildcache keys (end)" | ||
cacheKeysBuildF=$(gh actions-cache list -R $REPO --sort created-at --order asc --key buildcache-${{ runner.os }}-${{ inputs.process }}-f | cut -f 1 | head --lines=-1) # keep only the most recent build cache | ||
#--- DELETE CODEGEN AND BUILD CACHES | ||
set +e # do not fail while deleting cache keys | ||
echo "Deleting codegen caches..." | ||
for cacheKey in $cacheKeysCodegen; do gh actions-cache delete $cacheKey -R $REPO --confirm; done | ||
echo "Deleting codegen caches... done" | ||
echo "Deleting build caches..." | ||
for cacheKey in $cacheKeysBuildD; do gh actions-cache delete $cacheKey -R $REPO --confirm; done | ||
for cacheKey in $cacheKeysBuildF; do gh actions-cache delete $cacheKey -R $REPO --confirm; done | ||
echo "Deleting build caches... done" | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
codegen: | ||
runs-on: ubuntu-latest | ||
needs: cleanup | ||
steps: | ||
- # See https://github.com/actions/checkout | ||
# (NB actions/checkout needs "Allow owner and select non-owner" and "Allow actions created by github") | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: 'true' | ||
- name: HELLO_CODEGEN | ||
run: | | ||
echo "HELLO_CODEGEN ${{ inputs.process }}! $(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 codegencache keys (start)" | ||
gh actions-cache list -R $REPO --sort created-at --order asc --key codegencache-${{ runner.os }}-${{ inputs.process }} | ||
echo "List codegencache keys (end)" | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
- name: codegen | ||
run: .github/workflows/testsuite_oneprocess.sh codegen ${{ inputs.process }} | ||
- name: update_codegen_cache # update codegen caches | ||
id: codegen-cache-update | ||
# See https://github.com/actions/cache | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: | | ||
epochX/cudacpp/${{ inputs.process }} | ||
key: codegencache-${{ runner.os }}-${{ inputs.process }}-${{ github.run_id }} | ||
- name: GOODBYE_CODEGEN | ||
run: | | ||
echo "GOODBYE_CODEGEN ${{ inputs.process }}! $(date)" | ||
echo "Current directory is $(pwd)" | ||
echo "Current git commit is $(git log --oneline -n1 | cut -d' ' -f1)" | ||
REPO=${{ github.repository }} | ||
echo "List codegencache keys (start)" | ||
gh actions-cache list -R $REPO --sort created-at --order asc --key codegencache-${{ runner.os }}-${{ inputs.process }} | ||
echo "List codegencache keys (end)" | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
testsuite: | ||
runs-on: ubuntu-latest | ||
needs: codegen | ||
strategy: | ||
matrix: | ||
fptype: [d, f] | ||
steps: | ||
- # See https://github.com/actions/checkout | ||
# (NB actions/checkout needs "Allow owner and select non-owner" and "Allow actions created by github") | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: 'true' | ||
- name: HELLO_TESTSUITE | ||
run: | | ||
echo "HELLO_TESTSUITE ${{ inputs.process }} FPTYPE=${{ matrix.fptype }}! $(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 codegencache keys (start)" | ||
gh actions-cache list -R $REPO --sort created-at --order asc --key codegencache-${{ runner.os }}-${{ inputs.process }} | ||
echo "List codegencache keys (end)" | ||
echo "List buildcache keys (start)" | ||
gh actions-cache list -R $REPO --sort created-at --order asc --key buildcache-${{ runner.os }}-${{ inputs.process }}-${{ matrix.fptype }} | ||
echo "List buildcache keys (end)" | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
- name: restore_codegen_cache | ||
id: codegen-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: | | ||
epochX/cudacpp/${{ inputs.process }} | ||
key: codegencache-${{ runner.os }}-${{ inputs.process }}-${{ github.run_id }} | ||
restore-keys: | ||
codegencache-${{ runner.os }}-${{ inputs.process }} | ||
- name: restore_build_cache | ||
id: build-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: buildcache-${{ runner.os }}-${{ inputs.process }}-${{ matrix.fptype }}-${{ github.run_id }} | ||
restore-keys: | ||
buildcache-${{ runner.os }}-${{ inputs.process }}-${{ matrix.fptype }} | ||
- name: before_build | ||
run: .github/workflows/testsuite_oneprocess.sh before_build ${{ inputs.process }} | ||
env: [ FPTYPE=${{ matrix.fptype }} ] | ||
- name: build | ||
run: .github/workflows/testsuite_oneprocess.sh build ${{ inputs.process }} | ||
env: [ FPTYPE=${{ matrix.fptype }} ] | ||
- name: after_build | ||
run: .github/workflows/testsuite_oneprocess.sh after_build ${{ inputs.process }} | ||
env: [ FPTYPE=${{ matrix.fptype }} ] | ||
- name: update_build_cache # update build caches after the builds but before the tests (which may fail even if builds succeed) | ||
id: build-cache-update | ||
# See https://github.com/actions/cache | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: | | ||
CCACHE_DIR | ||
DOWNLOADS | ||
test/googletest | ||
key: buildcache-${{ runner.os }}-${{ inputs.process }}-${{ matrix.fptype }}-${{ github.run_id }} | ||
- name: tput_test | ||
run: .github/workflows/testsuite_oneprocess.sh tput_test ${{ inputs.process }} | ||
env: [ FPTYPE=${{ matrix.fptype }} ] | ||
- name: tput_test_fpe | ||
run: .github/workflows/testsuite_oneprocess.sh tput_test_fpe ${{ inputs.process }} | ||
if: ${{ inputs.enableFPE }} | ||
env: [ FPTYPE=${{ matrix.fptype }} ] | ||
- name: GOODBYE_TESTSUITE | ||
run: | | ||
echo "GOODBYE_TESTSUITE ${{ inputs.process }} FPTYPE=${{ matrix.fptype }}! $(date)" | ||
echo "Current directory is $(pwd)" | ||
echo "Current git commit is $(git log --oneline -n1 | cut -d' ' -f1)" | ||
REPO=${{ github.repository }} | ||
echo "List codegencache keys (start)" | ||
gh actions-cache list -R $REPO --sort created-at --order asc --key codegencache-${{ runner.os }}-${{ inputs.process }} | ||
echo "List codegencache keys (end)" | ||
echo "List buildcache keys (start)" | ||
gh actions-cache list -R $REPO --sort created-at --order asc --key buildcache-${{ runner.os }}-${{ inputs.process }}-${{ matrix.fptype }} | ||
echo "List buildcache keys (end)" | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
#---------------------------------------------------------------------------------------------------------------------------------- |