Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce CI and basic checks #99

Merged
merged 7 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Bao component base workflow

on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:

jobs:

gitlint:
runs-on: ubuntu-latest
container: baoproject/bao:latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- run: git config --global --add safe.directory $(realpath .)
- if: ${{ github.event_name == 'pull_request' }}
run: make gitlint GITLINT_BASE=${{ github.event.pull_request.base.sha }}
- if: ${{ github.event_name == 'push' }}
run: make gitlint GITLINT_BASE=${{ github.event.before }}
- if: ${{ github.event_name == 'workflow_dispatch' }}
run: make gitlint GITLINT_BASE=HEAD

license:
runs-on: ubuntu-latest
container: baoproject/bao:latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- run: >
make license-check
30 changes: 30 additions & 0 deletions .github/workflows/build-arm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Arm Build

on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:

jobs:

build-arm:
runs-on: ubuntu-latest
container: baoproject/bao:latest
strategy:
matrix:
platform: [
"fvp-a",
"fvp-a-aarch32",
"fvp-r",
"fvp-r-aarch32"
]
gic: [
"GICV2",
"GICV3",
]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- run: make PLATFORM=${{ matrix.platform }} GIC_VERSION=${{ matrix.gic }} CONFIG=null
27 changes: 27 additions & 0 deletions .github/workflows/build-riscv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: RISC-V Build

on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:

jobs:

build-riscv:
runs-on: ubuntu-latest
container: baoproject/bao:latest
strategy:
matrix:
platform: [
"qemu-riscv64-virt",
]
irqc: [
"PLIC",
"APLIC",
]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- run: make PLATFORM=${{ matrix.platform }} IRQC=${{ matrix.irqc }} CONFIG=null
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ configs/*
!configs/configs.mk
!configs/linker.ld
!configs/example/

!configs/null/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "ci"]
path = ci
url = [email protected]:bao-project/bao-ci.git
40 changes: 33 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ PLATFORM=

version:= baoversion_$(subst -,_,$(shell git describe --always --dirty --tag --match "v*\.*\.*"))

# List existing submakes
submakes:=config

# Directories
cur_dir:=$(current_directory)
src_dir:=$(cur_dir)/src
Expand All @@ -47,11 +44,22 @@ platforms_dir=$(src_dir)/platform
configs_dir=$(cur_dir)/configs
CONFIG_REPO?=$(configs_dir)
scripts_dir:=$(cur_dir)/scripts
ci_dir:=$(cur_dir)/ci
src_dirs:=

#Plataform must be defined excpet for clean target
include $(ci_dir)/ci.mk

targets:=$(MAKECMDGOALS)
ifeq ($(targets),)
targets:=all
endif
non_build_targets+=ci clean
build_targets:=$(strip $(foreach target, $(targets), \
$(if $(findstring $(target),$(non_build_targets)),,$(target))))

#Plataform must be defined excpet for non-build-targets
ifeq ($(PLATFORM),)
ifneq ($(MAKECMDGOALS), clean)
ifneq ($(build_targets),)
$(error Target platform argument (PLATFORM) not specified)
endif
endif
Expand Down Expand Up @@ -142,7 +150,7 @@ gens+=$(platform_defs) $(platform_def_generator)
inc_dirs+=$(platform_build_dir)


ifneq ($(MAKECMDGOALS), clean)
ifneq ($(build_targets),)
ifeq ($(CONFIG),)
$(error Configuration (CONFIG) not defined.)
endif
Expand Down Expand Up @@ -185,6 +193,8 @@ override LDFLAGS+=-build-id=none -nostdlib --fatal-warnings \
-z common-page-size=$(PAGE_SIZE) -z max-page-size=$(PAGE_SIZE) \
$(arch-ldflags) $(platform-ldflags)

ifneq ($(build_targets),)

.PHONY: all
all: $(targets-y)

Expand All @@ -204,7 +214,7 @@ $(ld_script_temp):
@$(cc) -E $(addprefix -I, $(inc_dirs)) -x assembler-with-cpp $(CPPFLAGS) \
$(ld_script) | grep -v '^\#' > $(ld_script_temp)

ifeq (, $(findstring $(MAKECMDGOALS), clean $(submakes)))
ifneq ($(build_targets),)
-include $(deps)
endif

Expand Down Expand Up @@ -279,10 +289,26 @@ $(directories):
@echo "Creating directory $(patsubst $(cur_dir)/%, %, $@)"
@mkdir -p $@

endif

#Clean all object, dependency and generated files

.PHONY: clean
clean:
@echo "Erasing directories..."
-rm -rf $(build_dir)
-rm -rf $(bin_dir)

# Instantiate CI rules

all_files= $(realpath \
$(cur_dir)/Makefile \
$(call list_dir_files_recursive, $(src_dir), *) \
$(call list_dir_files_recursive, $(scripts_dir), *) \
$(call list_dir_files_recursive, $(config_dir)/example, *) \
)

$(call ci, license, "Apache-2.0", $(all_files))

.PHONY: ci
ci: license-check
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Bao - a lightweight static partitioning hypervisor

![arm build workflow](https://github.com/bao-project/bao-hypervisor/actions/workflows/build-arm.yaml/badge.svg)
![riscv build workflow](https://github.com/bao-project/bao-hypervisor/actions/workflows/build-riscv.yaml/badge.svg)

Introduction
------------
Expand Down
1 change: 1 addition & 0 deletions ci
Submodule ci added at 715fb5
23 changes: 23 additions & 0 deletions configs/null/config.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) Bao Project and Contributors. All rights reserved.
*/

/* THIS CONFIG IS DEFINED FOR TESTING PURPOSES ONLY */

#include <config.h>

struct config config = {

/**
* This configuration has no VMs. It is used to test build the
* hypervisor with an empty configuration. We have to set
* `vmlist_size` to 1, because the build scripts will generate
* a macro to define an array size from it which automatically
* triggers a set of `array subscript i is outside array bounds`
* errors and the build which we are testing in the first place
* will fail.
*/
.vmlist_size = 1,

};