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

release/v1.0.0 #12

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
201 changes: 201 additions & 0 deletions .github/workflows/simulate-with-verilator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
name: Simulated testing using verilator

on:
push:
branches: [ "main", "release/**" ]
pull_request:
branches: [ "main", "release/**" ]

permissions:
actions: write

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
REPORT_ARTIFACT_NAME: ecap5-wbuart-report-${{github.run_number}}-${{github.run_attempt}}
SPEC_ARTIFACT_NAME: ecap5-wbuart-spec-${{github.run_number}}-${{github.run_attempt}}
BUILD_CACHE_KEY: build-directory-${{ github.run_id }}-${{ github.run_attempt }}

jobs:
prepare:
runs-on: self-hosted

steps:
- uses: actions/[email protected]

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -GNinja

- name: Cache build directory
if: always()
uses: actions/cache/[email protected]
env:
cache-folder-path: ${{github.workspace}}/build
with:
path: ${{ env.cache-folder-path }}
key: ${{ runner.os }}-${{env.BUILD_CACHE_KEY}}

documentation:
runs-on: self-hosted
needs: prepare

steps:
- uses: actions/[email protected]

- name: Import build directory
uses: actions/cache/[email protected]
env:
cache-folder-path: ${{github.workspace}}/build
with:
path: ${{ env.cache-folder-path }}
key: ${{ runner.os }}-${{env.BUILD_CACHE_KEY}}

- name: Generate documentation
run: ninja -C ${{github.workspace}}/build docs

- name: Upload documentation
uses: actions/upload-artifact@v4
with:
name: ${{env.SPEC_ARTIFACT_NAME}}
path: ${{github.workspace}}/build/docs/documentation/build/html

lint:
runs-on: self-hosted
needs: prepare

steps:
- uses: actions/[email protected]

- name: Import build directory
id: import-build
uses: actions/cache/[email protected]
env:
cache-folder-path: ${{github.workspace}}/build
with:
path: ${{ env.cache-folder-path }}
key: ${{ runner.os }}-${{env.BUILD_CACHE_KEY}}

- name: Lint
run: ninja -C ${{github.workspace}}/build lint

- name: Delete Previous Cache
if: ${{ always() && steps.import-build.outputs.cache-hit == 'true'}}
run: gh cache delete "${{ runner.os }}-${{env.BUILD_CACHE_KEY}}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Cache build directory
if: always()
uses: actions/cache/[email protected]
env:
cache-folder-path: ${{github.workspace}}/build
with:
path: ${{ env.cache-folder-path }}
key: ${{ runner.os }}-${{env.BUILD_CACHE_KEY}}

simulate:
runs-on: self-hosted
needs: lint

steps:
- uses: actions/[email protected]

- name: Import build directory
id: import-build
uses: actions/cache/[email protected]
env:
cache-folder-path: ${{github.workspace}}/build
with:
path: ${{ env.cache-folder-path }}
key: ${{ runner.os }}-${{env.BUILD_CACHE_KEY}}

- name: Build simulation
run: ninja -C ${{github.workspace}}/build build

- name: Simulate
id: simulate
# Enable -k option to simulate every module even if one fails
# Checks if there is any testdata
# Check if there is any fail in that testdata
run: >-
ninja -C ${{github.workspace}}/build -k 0 tests &&
ls -A1q ${{github.workspace}}/build/tests/testdata/ | grep -q . &&
(! grep -qe "[^;]*;0" ${{github.workspace}}/build/tests/testdata/*)

- name: Delete Previous Cache
if: ${{ always() && steps.import-build.outputs.cache-hit == 'true'}}
run: gh cache delete "${{ runner.os }}-${{env.BUILD_CACHE_KEY}}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Cache build directory
if: always()
uses: actions/cache/[email protected]
env:
cache-folder-path: ${{github.workspace}}/build
with:
path: ${{ env.cache-folder-path }}
key: ${{ runner.os }}-${{env.BUILD_CACHE_KEY}}

report:
runs-on: self-hosted
needs: simulate
if: always()

steps:
- uses: actions/[email protected]

- name: Import build directory
uses: actions/cache/[email protected]
env:
cache-folder-path: ${{github.workspace}}/build
with:
path: ${{ env.cache-folder-path }}
key: ${{ runner.os }}-${{env.BUILD_CACHE_KEY}}

- name: Generate report
run: >-
ninja -C ${{github.workspace}}/build report_markdown &&
ninja -C ${{github.workspace}}/build report

- name: Write summary
run: cat ${{github.workspace}}/build/report.md >> $GITHUB_STEP_SUMMARY

- name: Upload report
uses: actions/upload-artifact@v4
with:
name: ${{env.REPORT_ARTIFACT_NAME}}
path: ${{github.workspace}}/build/report.html

- name: Check for report errors
run: (! grep -qe "\[\!CAUTION\]" ${{github.workspace}}/build/report.md)

- name: Generate badges
if: ${{ github.ref == 'refs/heads/main' }}
run: ninja -C ${{github.workspace}}/build badges;

- name: Check generated badges
if: ${{ always() && github.ref == 'refs/heads/main' }}
run: >-
if [ ! -f "build/test-result-badge.json" ]; then
mkdir -p build &&
echo "{\"schemaVersion\": 1, \"label\": \"Test result\", \"message\": \"Failed\", \"color\": \"red\"}" > build/test-result-badge.json;
fi

- name: Upload test result badge
if: ${{ always() && github.ref == 'refs/heads/main' }}
uses: exuanbo/[email protected]
with:
token: ${{ secrets.GIST_SECRET }}
gist_id: 32195ea7fa70c0218ef3f9952504c59e
file_path: build/test-result-badge.json
file_type: text

- name: Upload traceability result badge
if: ${{ always() && github.ref == 'refs/heads/main' }}
uses: exuanbo/[email protected]
with:
token: ${{ secrets.GIST_SECRET }}
gist_id: 32195ea7fa70c0218ef3f9952504c59e
file_path: build/traceability-result-badge.json
file_type: text
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build/
.DS_Store
**/.DS_Store
**/*.drawio.bkp
73 changes: 73 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# __ _
# ________/ / ___ _(_)__ ___
# / __/ __/ _ \/ _ `/ / _ \/ -_)
# \__/\__/_//_/\_,_/_/_//_/\__/
#
# Copyright (C) Clément Chaine
# This file is part of ECAP5-DWBUART <https://github.com/cchaine/ECAP5-DWBUART>
#
# ECAP5-DWBUART is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ECAP5-DWBUART is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ECAP5-DWBUART. If not, see <http://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 3.12)
include(FetchContent)

project(ECAP5_DWBUART VERSION 1.0.0)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

# Create python virtual env
message(STATUS "Creating python venv")
set(VENV_DIR ${CMAKE_BINARY_DIR}/venv)
if(NOT EXISTS "${VENV_DIR}")
find_package(Python3 COMPONENTS Interpreter)
execute_process(COMMAND "${Python3_EXECUTABLE}" -m venv ${VENV_DIR})
set(Python3_FIND_VIRTUALENV ONLY)
unset(Python3_EXECUTABLE)
endif()
set(ENV{VIRTUAL_ENV} "${VENV_DIR}")
find_package(Python3 COMPONENTS Interpreter Development)

# Dependencies

message(STATUS "Collecting dependencies")
include(${CMAKE_CURRENT_LIST_DIR}/cmake/dependency.cmake)

add_dependency(ECAP5_TREQ
GIT ecap5/ecap5-treq
TAG release/v2.2.0
BINARY ecap5-treq)

add_dependency(ECAP5_DTLIB
GIT ecap5/ecap5-dtlib
TAG main)

add_dependency(sphinx-cmake
GIT ecap5/sphinx-cmake
TAG tags/v1.0.1)

add_dependency(verilator-cmake
GIT ecap5/verilator-cmake
TAG tags/v1.0.1)

# Configure dependencies

include(${verilator_cmake_SOURCE_DIR}/cmake/verilator-config.cmake)
include(${ecap5_treq_SOURCE_DIR}/config.cmake)
list(APPEND CMAKE_MODULE_PATH "${sphinx_cmake_SOURCE_DIR}/cmake")

# Include subdirectories

add_subdirectory(docs)
add_subdirectory(tests)
26 changes: 26 additions & 0 deletions cmake/dependency.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
macro(add_dependency id)
cmake_parse_arguments(ARG ""
"GIT;TAG;BINARY"
""
${ARGN})
string(MAKE_C_IDENTIFIER "${id}" name)
string(TOLOWER "${name}" name)

FetchContent_Declare(${name}
GIT_REPOSITORY https://github.com/${ARG_GIT}
GIT_TAG ${ARG_TAG}
SOURCE_SUBDIR __none__
)
FetchContent_MakeAvailable(${name})

if(NOT DEFINED ${name}_EXECUTABLE)
if(EXISTS "${${name}_SOURCE_DIR}/pyproject.toml")
message(STATUS "Configuring ${name}")
execute_process(COMMAND ${Python3_EXECUTABLE} -m pip install ${${name}_SOURCE_DIR} OUTPUT_QUIET RESULT_VARIABLE rv)
if("${rv}" STREQUAL "0")
set(${name}_EXECUTABLE ${VENV_DIR}/bin/${ARG_BINARY} CACHE STRING "path to the ${name} executable")
endif()
endif()
endif()

endmacro()
Loading
Loading