Skip to content

Commit

Permalink
Add ci/cd compile tests
Browse files Browse the repository at this point in the history
  • Loading branch information
islas committed Jun 27, 2024
1 parent d26ad02 commit 0ec9b82
Show file tree
Hide file tree
Showing 2 changed files with 196 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Regression Suite
run-name : ${{ github.event_name == 'push' && 'CI' || github.event.label.name }} (${{ github.event_name }})

on:
push:
branches: [ master ]
pull_request:
types: [ labeled ]


# Write our tests out this way for easier legibility
# testsSet :
# - key : value
# key : value
# tests :
# - value
# - value
# - < next test >
# Specify accounts specific to each HPC resource
# https://stackoverflow.com/a/68940067
jobs:
buildtests:
if : ${{ github.event.label.name == 'compile-tests' || github.event.label.name == 'all-tests' || github.event_name == 'push' }}
strategy:
max-parallel: 4
fail-fast: false
matrix:

testSet :
- host : derecho
archive : /glade/work/aislas/github/runners/mpas/derecho/logs/
account : NMMM0012
name : "Make Compilation Tests"
id : make-tests
fileroot : mpas_compilation
args : -j='{"node_select":{"-l ":{"select":1}}}'
pool : 8
tpool : 1
mkdirs : true
tests :
- make-gnu
- make-intel
- make-pgi

uses : ./.github/workflows/test_workflow.yml
with :
label : compile-tests
archive : ${{ matrix.testSet.archive }}
name : ${{ matrix.testSet.name }}
id : ${{ matrix.testSet.id }}
host : ${{ matrix.testSet.host }}
fileroot : ${{ matrix.testSet.fileroot }}
account : ${{ matrix.testSet.account }}
tests : ${{ toJson( matrix.testSet.tests ) }}
mkdirs : ${{ matrix.testSet.mkdirs }}
args : ${{ matrix.testSet.args }}
pool : ${{ matrix.testSet.pool }}
tpool : ${{ matrix.testSet.tpool }}
permissions:
contents: read
pull-requests: write
name : Test ${{ matrix.testSet.name }} on ${{ matrix.testSet.host }}
134 changes: 134 additions & 0 deletions .github/workflows/test_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@


on :
workflow_call :
inputs :
label :
required : true
type : string
archive :
required : true
type : string

name :
required : true
type : string
id :
required : true
type : string
host :
required : true
type : string
fileroot :
required : true
type : string
account :
required : true
type : string
tests :
required : true
type : string
mkdirs :
required : true
type : boolean
args :
required : false
type : string
default : ""
pool :
required : false
type : number
default : 1
tpool :
required : false
type : number
default : 1



jobs:
test_workflow :

# Is 5 days a reasonable wait time for testing?
timeout-minutes: 7200
name: Test ${{ inputs.name }} on ${{ inputs.host }}
runs-on: ${{ inputs.host }}
env :
LOG_SUFFIX : ${{ github.event_name == 'push' && 'master' || github.event.number }}
steps:
- uses: actions/checkout@v4
with:
path : main
submodules: true

# Immediately copy out to # of tests to do
- name: Create testing directories
if : ${{ inputs.mkdirs }}
id : cpTestDirs
run : |
for testDir in ${{ join( fromJson( inputs.tests ), ' ' ) }}; do
echo "Creating duplicate directory for $testDir"
# Remove if it exists to get a fresh start
rm -rf $testDir
rsync -a --exclude '.git' main/ $testDir
done
- name: Test ${{ inputs.name }}
id : runTest
run: |
if [ "${{ inputs.mkdirs }}" = "true" ]; then
ALT_DIRS="-alt ../${{ join( fromJson( inputs.tests ), '/.ci ../' ) }}/.ci"
fi
./main/hpc-workflows/.ci/runner.py \
./main/.ci/${{ inputs.fileroot }}.json \
-t ${{ join( fromJson( inputs.tests ), ' ' ) }} \
-a "${{ inputs.account }}" \
-p ${{ inputs.pool}} -tp ${{ inputs.tpool }} \
${{ inputs.args }} $ALT_DIRS
- name: Report failed tests and steps
if : ${{ failure() }}
run : |
# move log files to safe location
./main/hpc-workflows/.ci/relocator.py ./main/.ci/${{ inputs.fileroot }}.log ${{ inputs.archive }}/$LOG_SUFFIX/${{ inputs.id }}
# report on them - alt dirs need extra help
if [ "${{ inputs.mkdirs }}" = "true" ]; then
masterlogLoc=main/.ci
fi
./main/hpc-workflows/.ci/reporter.py ${{ inputs.archive }}/$LOG_SUFFIX/${{ inputs.id }}/$masterlogLoc/${{ inputs.fileroot }}.log \
-e ./hpc-workflows/.ci/runner.py \
-o GITHUB -m # only mark fail steps with gh syntax
# report on them
echo "# Summary for ${{ join( fromJson( inputs.tests ), ' ' ) }}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
./main/hpc-workflows/.ci/reporter.py ${{ inputs.archive }}/$LOG_SUFFIX/${{ inputs.id }}/$masterlogLoc/${{ inputs.fileroot }}.log \
-e ./hpc-workflows/.ci/runner.py \
-s >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
- name: Clean up testing directories
if : ${{ success() }}
id : rmTestDirs
run : |
for testDir in ${{ join( fromJson( inputs.tests ), ' ' ) }}; do
echo "Removing duplicate directory for $testDir"
rm -rf $testDir
done
- name : Remove '${{ inputs.label }}' label
if : ${{ !cancelled() && github.event.label.name == inputs.label }}
env:
PR_NUMBER: ${{ github.event.number }}
run: |
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
-H 'Authorization: token ${{ github.token }}' \
https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/labels/${{ inputs.label }}



0 comments on commit 0ec9b82

Please sign in to comment.