Skip to content

Commit

Permalink
Github action to run tests on commit and PR (#5)
Browse files Browse the repository at this point in the history
Add github action for running tests on each PR and commit to main
  • Loading branch information
christophe0606 authored Jun 18, 2024
1 parent 8161660 commit ca2d16b
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 15 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/runtest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Compile and Run
on:
workflow_dispatch:
pull_request:
branches: [main]
push:
branches: [main]

permissions:
actions: read
security-events: write

jobs:
CI_test_run:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install system packages
run: |
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get install libpython3.9 libtinfo5
- name: Activate vcpkg
uses: ARM-software/cmsis-actions/vcpkg@v1

- name: Activate Arm tool license
uses: ARM-software/cmsis-actions/armlm@v1

- name: Prepare framework
run: |
cd Testing/board
echo "Install missing python packages"
pip install -r requirements.txt
echo "Generate reference patterns"
python runall.py --gen --norun --nobuild
echo "Load missing pack"
csolution list packs -s cmsiscv.csolution.yml -m > required_packs.txt
cat required_packs.txt
cpackget add -a -f required_packs.txt
- name: Execute
run: |
cd Testing/board
echo "Running tests"
python runall.py -avh $AVH_FVP_PLUGINS/../bin
- name: Upload test report
uses: actions/upload-artifact@v4
with:
name: test-report
path: Testing/board/summary.html


- name: Check error
run: |
cd Testing/board
echo "Checking output..."
test "$(grep "Error" summary.html | wc -l)" -eq 0
70 changes: 55 additions & 15 deletions Testing/board/runall.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import os
import glob
import sys
from os import environ


# Description of all configurations compiler / cores are defined
# in this file
Expand All @@ -27,6 +29,11 @@
Path("inputs").mkdir(parents=True, exist_ok=True)
Path("results/img").mkdir(parents=True, exist_ok=True)

GHACTION = False

if "AVH_FVP_PLUGINS" in os.environ:
GHACTION = True

parser = argparse.ArgumentParser(description='Parse test description')
parser.add_argument('-avh', nargs='?',type = str, default="C:/Keil_v5/ARM/VHT", help="AVH folder")
parser.add_argument('-d', action='store_true', help="Debug log for command launch")
Expand Down Expand Up @@ -82,6 +89,7 @@ def getError(l,s):
def getMessage(l,s):
return(f"\n[bold cyan]{s}[/bold cyan]")


class Result:
def __init__(self,msg,error=False):
self._error = error
Expand Down Expand Up @@ -140,7 +148,19 @@ def run(*args,mustPrint=False,dumpStdErr=True,live=None):
# Windows executable
# (At some point this script will also support
# unix)
avhExe={
avhUnixExe={
"CS310":"FVP_Corstone_SSE-310_Ethos-U65",
"CS300":"FVP_Corstone_SSE-300_Ethos-U55",
"M55":"FVP_MPS2_Cortex-M55",
"M33_DSP_FP":"FVP_MPS2_Cortex-M33",
"M7DP":"FVP_MPS2_Cortex-M7",
"M4FP":"FVP_MPS2_Cortex-M4",
"M3":"FVP_MPS2_Cortex-M3",
"M23":"FVP_MPS2_Cortex-M23",
"M0plus":"FVP_MPS2_Cortex-M0plus",
}

avhWindowsExe={
"CS310":"VHT_Corstone_SSE-310.exe",
"CS300":"VHT_Corstone_SSE-300_Ethos-U55.exe",
"M55":"VHT_MPS2_Cortex-M55.exe",
Expand All @@ -164,7 +184,18 @@ def runAVH(live,build,core):
if os.path.exists(elf):
app = elf
config = os.path.join("fvp_configs",configFiles[core])
avh = os.path.join(AVHROOT,avhExe[core])

if AVHROOT:
avhAttempt = os.path.join(AVHROOT,avhWindowsExe[core])
if os.path.exists(avhAttempt):
avh = avhAttempt

avhAttempt = os.path.join(AVHROOT,avhUnixExe[core])
if os.path.exists(avhAttempt):
avh = avhAttempt
else:
avh = avhUnixExe[core]

res=run(avh,"-f",config,app,live=live)
return(res)

Expand Down Expand Up @@ -245,6 +276,11 @@ def gen_table(the_list):

# Run the tests and log the result
# in a summary.html file
#

def live_display(live,latest):
if not GHACTION:
live.update(renderable=gen_table(latest))

MAX_ROWS=4
latest=[]
Expand Down Expand Up @@ -307,41 +343,41 @@ def gen_table(the_list):
#live.console.print("Incremental build")
msg += " Incremental build"
latest[-1][-1]=msg
live.update(renderable=gen_table(latest))
live_display(live,latest)
res=run("cbuild","-O" ,"cprj",'cmsiscv.csolution.yml',"--toolchain" ,c,"-c",buildFile,live=live)
else:
#live.console.print("Rebuild all (and RTE update)")
msg += " Rebuild all (and RTE update)"
latest[-1][-1]=msg
live.update(renderable=gen_table(latest))
live_display(live,latest)
res=run("cbuild","-O" ,"cprj",'cmsiscv.csolution.yml',"--update-rte","-r","--toolchain" ,c,"-c",buildFile,live=live)
else:
#live.console.print("Incremental build")
msg += " Incremental build"
latest[-1][-1]=msg
live.update(renderable=gen_table(latest))
live_display(live,latest)
res=run("cbuild","-O" ,"cprj",'cmsiscv.csolution.yml',"--toolchain" ,c,"-c",buildFile,live=live)


if res.error:
latest[-1][-1]="[red]Error cbuild"
live.update(renderable=gen_table(latest))
live_display(live,latest)
#printError(live,"Error cbuild")
print(f'<p><font color="red">Error building {testSuite["name"]}</font></p><PRE>',file=f)
print(res.msg,file=f)
print("</PRE>",file=f)
continue
if not args.norun and (not core is None):
latest[-1][-1]="Run AVH"
live.update(renderable=gen_table(latest))
live_display(live,latest)
#printSubTitle(live,"Run AVH")
clean_old_results()
res=runAVH(live,build,core)
if res.error:
latest[-1][-1]="[red]Error running AVH"
live.update(renderable=gen_table(latest))
live_display(live,latest)
#printError(live,"Error running AVH")
print(f'<p><font color="red">Error running {testSuite["name"]} with {avhExe[core]}</font></p><PRE>',file=f)
print(f'<p><font color="red">Error running {testSuite["name"]} with {avhUnixExe[core]}</font></p><PRE>',file=f)
print(res.msg,file=f)
print("</PRE>",file=f)
continue
Expand All @@ -350,23 +386,27 @@ def gen_table(the_list):
if had_error:
ERROR_OCCURED = True
latest[-1][-1]="[red]Failed"
live.update(renderable=gen_table(latest))
live_display(live,latest)
continue
# In case of no issue, we drop the status
# Status table only contain failure
latest=latest[:-1]
live.update(renderable=gen_table(latest))
live_display(live,latest)


print(HTMLFOOTER,file=f)

# Refresh cursor
oldprint('\033[?25h', end="")

if ERROR_OCCURED:
sys.exit("Error occurred")
else:
sys.exit(0)
# When github action, error is tested by greping the summary html
# like that the github action is not interrupted before uploading the
# test report as an artifact.
if not GHACTION:
if ERROR_OCCURED:
sys.exit("Error occurred")
else:
sys.exit(0)



19 changes: 19 additions & 0 deletions vcpkg-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"registries": [
{
"name": "arm",
"kind": "artifact",
"location": "https://artifacts.tools.arm.com/vcpkg-registry"
}
],
"requires": {
"arm:tools/open-cmsis-pack/cmsis-toolbox": "2.4.0",
"arm:tools/kitware/cmake": "3.28.4",
"arm:tools/ninja-build/ninja": "1.12.0",
"arm:compilers/arm/armclang": "6.22.0",
"arm:compilers/arm/arm-none-eabi-gcc": "^13.2.1",
"arm:models/arm/avh-fvp": "^11.22.39",
"arm:debuggers/arm/armdbg": "6.1.2"
}
}

0 comments on commit ca2d16b

Please sign in to comment.