Skip to content

Commit

Permalink
Merge patch-axel-3
Browse files Browse the repository at this point in the history
  • Loading branch information
axel-h committed Apr 12, 2024
2 parents 537f7b9 + a6178de commit 486192e
Show file tree
Hide file tree
Showing 16 changed files with 607 additions and 376 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,37 @@ jobs:
- uses: seL4/ci-actions/link-check@master
with:
exclude: '/node_modules/'

mypy:
name: MyPy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install mypy
run: pip3 install mypy
- name: Run mypy
#run: mypy --explicit-package-bases ./
run: |
mypy seL4-platforms
mypy seL4-platforms camkes-hw
mypy seL4-platforms camkes-test
mypy seL4-platforms camkes-vm
mypy seL4-platforms camkes-vm-hw
mypy seL4-platforms cparser-run
mypy seL4-platforms dashboard
mypy seL4-platforms l4v-deploy
mypy seL4-platforms march-of-platform
mypy seL4-platforms rump-hello
mypy seL4-platforms rump-hello-hw
mypy seL4-platforms sel4bench
mypy seL4-platforms sel4bench-hw
mypy seL4-platforms sel4bench-web
mypy seL4-platforms sel4test-hw
mypy seL4-platforms sel4test-hw-matrix
mypy seL4-platforms sel4test-hw-run
mypy seL4-platforms sel4test-sim
mypy seL4-platforms thylint
mypy seL4-platforms trigger
mypy seL4-platforms tutorials
mypy seL4-platforms webserver
mypy seL4-platforms webserver-hw
105 changes: 64 additions & 41 deletions camkes-test/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
Expects seL4-platforms/ to be co-located or otherwise in the PYTHONPATH.
"""

from builds import Build, run_build_script, run_builds, load_builds, release_mq_locks, SKIP
from pprint import pprint
from typing import List, Union

import json
import os
import sys
import os
import argparse
import json

import builds
import platforms
import pprint

from platforms import load_yaml, gh_output

# See also builds.yml for how builds are split up in this test. We use the build
# matrix and filtering for the hardware builds, and an explicit list for the
Expand All @@ -33,27 +33,30 @@ def __init__(self, sim: dict):
self.name = sim['match'] + post
self.__dict__.update(**sim)

def __repr__(self):
def __repr__(self) -> str:
return f"SimBuild('{self.name}', " '{' \
f" 'match': '{self.match}'," \
f" 'exclude': '{self.exclude}'," \
f" 'iterator': '{self.iterator}'" \
' })'


def run_build(manifest_dir: str, build: Union[Build, SimBuild]):
def run_build(manifest_dir: str, build: builds.Build | SimBuild) -> int:
"""Run one CAmkES test. Can be either Build or SimBuild."""

if isinstance(build, Build):
if isinstance(build, builds.Build):
app = apps[build.app]
build.files = build.get_platform().image_names(build.get_mode(), "capdl-loader")
build.settings['CAMKES_APP'] = build.app
del build.settings['BAMBOO'] # not used in this test, avoid warning

if app.get('has_cakeml'):
build.settings['CAKEMLDIR'] = '/cakeml'
build.settings['CAKEML_BIN'] = f"/cake-x64-{build.get_mode()}/cake"

# remove parameters from setting that CMake does not use and thus would
# raise a nasty warning
del build.settings['BAMBOO']

script = [
["../init-build.sh"] + build.settings_args(),
["ninja"],
Expand All @@ -73,23 +76,23 @@ def run_build(manifest_dir: str, build: Union[Build, SimBuild]):
else:
print(f"Warning: unknown build type for {build.name}")

return run_build_script(manifest_dir, build, script)
return builds.run_build_script(manifest_dir, build, script)


def hw_run(manifest_dir: str, build: Build):
def hw_run(manifest_dir: str, build: builds.Build) -> int:
"""Run one hardware test."""

if build.is_disabled():
print(f"Build {build.name} disabled, skipping.")
return SKIP
return builds.SKIP

build.success = apps[build.app]['success']
script, final = build.hw_run('log.txt')

return run_build_script(manifest_dir, build, script, final_script=final)
return builds.run_build_script(manifest_dir, build, script, final_script=final)


def build_filter(build: Build):
def build_filter(build: builds.Build) -> bool:
if not build.app:
return False

Expand All @@ -106,37 +109,57 @@ def build_filter(build: Build):
return True


def sim_build_filter(build: SimBuild):
def sim_build_filter(build: SimBuild) -> bool:
name = os.environ.get('INPUT_NAME')
plat = os.environ.get('INPUT_PLATFORM')
return (not name or build.name == name) and (not plat or plat == 'sim')


def to_json(builds: List[Build]) -> str:
"""Return a GitHub build matrix as GitHub output assignment."""
def gh_output_matrix(param_name: str, build_list: list[builds.Build]) -> None:
matrix_builds = [{"name": b.name,
"platform": b.get_platform().name
}
for b in build_list]
# GitHub output assignment
matrix_json = json.dumps({"include": matrix_builds})
platforms.gh_output(f"{param_name}={matrix_json}")


def main(params: list) -> int:
parser = argparse.ArgumentParser()
g = parser.add_mutually_exclusive_group()
g.add_argument('--dump', action='store_true')
g.add_argument('--matrix', action='store_true')
g.add_argument('--hw', action='store_true')
g.add_argument('--post', action='store_true')
g.add_argument('--build', action='store_true')
args = parser.parse_args(params)

builds_yaml_file = os.path.join(os.path.dirname(__file__), "builds.yml")
yml = platforms.load_yaml(builds_yaml_file)
apps = yml['apps']
sim_builds = [SimBuild(s) for s in yml['sim']]
hw_builds = builds.load_builds(None, build_filter, yml)
build_list = [b for b in sim_builds if sim_build_filter(b)] + hw_builds

if args.dump:
pprint.pprint(build_list)
return 0

if args.matrix:
gh_output_matrix("matrix", build_list)
return 0

if args.hw:
return builds.run_builds(build_list, hw_run)

matrix = {"include": [{"name": b.name, "platform": b.get_platform().name} for b in builds]}
return "matrix=" + json.dumps(matrix)
if args.post:
builds.release_mq_locks(build_list)
return 0

# perform args.build as default
return builds.run_builds(build_list, run_build)


# If called as main, run all builds from builds.yml
if __name__ == '__main__':
yml = load_yaml(os.path.dirname(__file__) + "/builds.yml")
apps = yml['apps']
sim_builds = [SimBuild(s) for s in yml['sim']]
hw_builds = load_builds(None, build_filter, yml)
builds = [b for b in sim_builds if sim_build_filter(b)] + hw_builds

if len(sys.argv) > 1 and sys.argv[1] == '--dump':
pprint(builds)
sys.exit(0)
elif len(sys.argv) > 1 and sys.argv[1] == '--matrix':
gh_output(to_json(builds))
sys.exit(0)
elif len(sys.argv) > 1 and sys.argv[1] == '--hw':
sys.exit(run_builds(builds, hw_run))
elif len(sys.argv) > 1 and sys.argv[1] == '--post':
release_mq_locks(builds)
sys.exit(0)

sys.exit(run_builds(builds, run_build))
sys.exit(main(sys.argv[1:]))
70 changes: 44 additions & 26 deletions camkes-vm/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
Expects seL4-platforms/ to be co-located or otherwise in the PYTHONPATH.
"""

from builds import Build, run_build_script, run_builds, load_builds, release_mq_locks, SKIP, sim_script
from pprint import pprint

import os
import sys
import os
import argparse

from builds import Build, run_build_script, run_builds, load_builds, release_mq_locks, SKIP
from pprint import pprint


# See also builds.yml for how builds are split up in this test. We use the build
Expand All @@ -21,22 +22,24 @@

# The only thing this really has in common with a "Build" is the "name" field.

def run_build(manifest_dir: str, build: Build):
def run_build(manifest_dir: str, build: builds.Build) -> int:
"""Run one CAmkES VM test."""

plat = build.get_platform()

build.files = plat.image_names(build.get_mode(), "capdl-loader")
build.settings['CAMKES_VM_APP'] = build.app or build.name
del build.settings['BAMBOO'] # not used in this test, avoid warning

if plat.arch == 'x86':
del build.settings['PLATFORM'] # not used for x86 in this test, avoid warning

# if vm_platform is set, the init-build.sh script expects a different platform name.
if build.vm_platform:
build.settings['PLATFORM'] = build.vm_platform

# remove parameters from setting that CMake does not use and thus would
# raise a nasty warning
del build.settings['BAMBOO']
if plat.arch == 'x86':
del build.settings['PLATFORM']

script = [
["../init-build.sh"] + build.settings_args(),
["ninja"],
Expand All @@ -46,35 +49,50 @@ def run_build(manifest_dir: str, build: Build):
if plat.has_simulation and plat.name != 'PC99':
script.append(sim_script(build.success, failure=build.error))

return run_build_script(manifest_dir, build, script)
return builds.run_build_script(manifest_dir, build, script)


def hw_run(manifest_dir: str, build: Build):
def hw_run(manifest_dir: str, build: builds.Build) -> int:
"""Run one hardware test."""

if build.is_disabled():
print(f"Build {build.name} disabled, skipping.")
return SKIP
return builds.SKIP

plat = build.get_platform()
build.files = plat.image_names(build.get_mode(), "capdl-loader")

script, final = build.hw_run('log.txt')

return run_build_script(manifest_dir, build, script, final_script=final)
return builds.run_build_script(manifest_dir, build, script, final_script=final)


def main(params: list) -> int:
parser = argparse.ArgumentParser()
g = parser.add_mutually_exclusive_group()
g.add_argument('--dump', action='store_true')
g.add_argument('--hw', action='store_true')
g.add_argument('--post', action='store_true')
g.add_argument('--build', action='store_true')
args = parser.parse_args(params)

builds_yaml_file = os.path.join(os.path.dirname(__file__), "builds.yml")
build_list = builds.load_builds(builds_yaml_file)

if args.dump:
pprint.pprint(build_list)
return 0

if args.hw:
return builds.run_builds(build_list, hw_run)

if args.post:
builds.release_mq_locks(build_list)
return 0

# perform args.build as default
return builds.run_builds(build_list, run_build)


# If called as main, run all builds from builds.yml
if __name__ == '__main__':
builds = load_builds(os.path.dirname(__file__) + "/builds.yml")

if len(sys.argv) > 1 and sys.argv[1] == '--dump':
pprint(builds)
sys.exit(0)
elif len(sys.argv) > 1 and sys.argv[1] == '--hw':
sys.exit(run_builds(builds, hw_run))
elif len(sys.argv) > 1 and sys.argv[1] == '--post':
release_mq_locks(builds)
sys.exit(0)

sys.exit(run_builds(builds, run_build))
sys.exit(main(sys.argv[1:]))
32 changes: 22 additions & 10 deletions cparser-run/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
Expects seL4-platforms/ to be co-located or otherwise in the PYTHONPATH.
"""

import sys
import os
import argparse

from builds import run_build_script, run_builds, load_builds
from pprint import pprint

import os
import sys


def run_cparser(manifest_dir: str, build):
def run_cparser(manifest_dir: str, build) -> int:
"""Single run of the C Parser test, for one build definition"""

script = [
Expand All @@ -28,12 +29,23 @@ def run_cparser(manifest_dir: str, build):
return run_build_script(manifest_dir, build, script)


# If called as main, run all builds from builds.yml
if __name__ == '__main__':
builds = load_builds(os.path.dirname(__file__) + "/builds.yml")
def main(params: list) -> int:
parser = argparse.ArgumentParser()
g = parser.add_mutually_exclusive_group()
g.add_argument('--dump', action='store_true')
g.add_argument('--build', action='store_true')
args = parser.parse_args(params)

builds_yaml_file = os.path.join(os.path.dirname(__file__), "builds.yml")
builds = load_builds(builds_yaml_file)

if len(sys.argv) > 1 and sys.argv[1] == '--dump':
if args.dump:
pprint(builds)
sys.exit(0)
return 0

# perform args.build as default
return run_builds(builds, run_cparser)

sys.exit(run_builds(builds, run_cparser))

if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
4 changes: 2 additions & 2 deletions l4v-deploy/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ def loud_command(*args, **kwargs):
return run_command(*args, **kwargs)


def indent(s, indent=' '):
def indent(s, indent=' ') -> str:
'''Indent all lines in a string'''
return '\n'.join(indent + line for line in s.splitlines())


def format_commit_message(msg):
def format_commit_message(msg: str) -> str:
'''Add a standard header and footer to a commit message'''
msg = "[CI] " + msg
return msg
Expand Down
Loading

0 comments on commit 486192e

Please sign in to comment.