Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
name: Simulated testing using verilator
name: ECAP5-DTESTLIB continuous integration

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

permissions:
actions: write

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
REPORT_ARTIFACT_NAME: ecap5-dtlib-report-${{github.run_number}}-${{github.run_attempt}}
ARCH_ARTIFACT_NAME: ecap5-dtlib-arch-${{github.run_number}}-${{github.run_attempt}}
BUILD_CACHE_KEY: build-directory-${{ github.run_id }}-${{ github.run_attempt }}
REPORT_ARTIFACT_NAME: ecap5-dtestlib-report-${{github.run_number}}-${{github.run_attempt}}
DOCUMENTATION_ARTIFACT_NAME: ecap5-dtestlib-docs-${{github.run_number}}-${{github.run_attempt}}
BUILD_CACHE_KEY: simulation-build-directory-${{ github.run_id }}-${{ github.run_attempt }}

jobs:
prepare:
Expand All @@ -24,41 +24,21 @@ jobs:
- uses: actions/checkout@v4.1.1

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build
run: cmake -B ${{github.workspace}}/build -GNinja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} 2>&1 | tee ${{github.workspace}}/cmake.log

- name: Check versions
if: github.event.pull_request.base.ref == 'main'
run: (! grep -e "Using .* with unreleased version" ${{github.workspace}}/cmake.log)

- name: Cache build directory
if: always()
uses: actions/cache/save@v4.0.1
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/checkout@v4.1.1

- name: Import build directory
uses: actions/cache/restore@v4.0.1
uses: actions/cache/save@v4.3.0
env:
cache-folder-path: ${{github.workspace}}/build
with:
path: ${{ env.cache-folder-path }}
key: ${{ runner.os }}-${{env.BUILD_CACHE_KEY}}

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

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

lint:
runs-on: self-hosted
needs: prepare
Expand All @@ -68,25 +48,25 @@ jobs:

- name: Import build directory
id: import-build
uses: actions/cache/restore@v4.0.1
uses: actions/cache/restore@v4.3.0
env:
cache-folder-path: ${{github.workspace}}/build
with:
path: ${{ env.cache-folder-path }}
key: ${{ runner.os }}-${{env.BUILD_CACHE_KEY}}

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

- name: Delete Previous Cache
if: steps.import-build.outputs.cache-hit == 'true'
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/save@v4.0.1
uses: actions/cache/save@v4.3.0
env:
cache-folder-path: ${{github.workspace}}/build
with:
Expand All @@ -102,35 +82,35 @@ jobs:

- name: Import build directory
id: import-build
uses: actions/cache/restore@v4.0.1
uses: actions/cache/restore@v4.3.0
env:
cache-folder-path: ${{github.workspace}}/build
with:
path: ${{ env.cache-folder-path }}
key: ${{ runner.os }}-${{env.BUILD_CACHE_KEY}}

- name: Build simulation
run: make -C ${{github.workspace}}/build build
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: >-
make -C ${{github.workspace}}/build -k tests &&
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: steps.import-build.outputs.cache-hit == 'true'
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/save@v4.0.1
uses: actions/cache/save@v4.3.0
env:
cache-folder-path: ${{github.workspace}}/build
with:
Expand All @@ -146,7 +126,8 @@ jobs:
- uses: actions/checkout@v4.1.1

- name: Import build directory
uses: actions/cache/restore@v4.0.1
id: import-build
uses: actions/cache/restore@v4.3.0
env:
cache-folder-path: ${{github.workspace}}/build
with:
Expand All @@ -155,8 +136,8 @@ jobs:

- name: Generate report
run: >-
make -C ${{github.workspace}}/build report_markdown &&
make -C ${{github.workspace}}/build report
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
Expand All @@ -170,32 +151,61 @@ jobs:
- name: Check for report errors
run: (! grep -qe "\[\!CAUTION\]" ${{github.workspace}}/build/report.md)

- name: Generate badges
if: ${{ github.ref == 'refs/heads/main' }}
run: make -C ${{github.workspace}}/build badges;
- 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: 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/actions-deploy-gist@v1.1.4
- name: Cache build directory
if: always()
uses: actions/cache/save@v4.3.0
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: report

steps:
- uses: actions/checkout@v4.1.1

- name: Import build directory
uses: actions/cache/restore@v4.3.0
env:
cache-folder-path: ${{github.workspace}}/build
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/actions-deploy-gist@v1.1.4
path: ${{ env.cache-folder-path }}
key: ${{ runner.os }}-${{env.BUILD_CACHE_KEY}}

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

- uses: actions/upload-pages-artifact@v3.0.1
with:
name: ${{env.DOCUMENTATION_ARTIFACT_NAME}}
path: ${{github.workspace}}/build/docs/documentation/build/html

deploy:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: self-hosted

needs: documentation

permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- uses: actions/deploy-pages@v4.0.4
id: deployment
with:
token: ${{ secrets.GIST_SECRET }}
gist_id: 32195ea7fa70c0218ef3f9952504c59e
file_path: build/traceability-result-badge.json
file_type: text
artifact_name: ${{env.DOCUMENTATION_ARTIFACT_NAME}}
preview: true
49 changes: 31 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@
# You should have received a copy of the GNU General Public License
# along with ECAP5-DTESTLIB. If not, see <http://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.21)
include(FetchContent)

project(ECAP5_DTESTLIB VERSION 1.0.0)
project(ECAP5_DTESTLIB)

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)
Expand All @@ -41,30 +40,44 @@ 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 tags/v2.2.0
BINARY ecap5-treq)

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

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

# Configure dependencies
add_dependency(
GIT ecap5/ecap5-treq
TAG 109-use-cmake-interface-libraries
BINARY ecap5-treq)

# Define an interface library

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")
add_library(ecap5_dtestlib INTERFACE)
target_sources(ecap5_dtestlib INTERFACE
${CMAKE_CURRENT_LIST_DIR}/src/instr_wb_slave.sv
)

# Include subdirectories
# Only perform if the project will be tested

add_subdirectory(docs)
add_subdirectory(tests)
if(PROJECT_IS_TOP_LEVEL)
# Configure dependencies

list(APPEND CMAKE_MODULE_PATH "${ecap5_sphinx_cmake_SOURCE_DIR}/cmake")
include(${ecap5_verilator_cmake_SOURCE_DIR}/cmake/verilator-config.cmake)
include(${ecap5_ecap5_treq_SOURCE_DIR}/config.cmake)

# Include local cmake configuration files

include(${CMAKE_CURRENT_LIST_DIR}/cmake/lint.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/testbench.cmake)

# Include subdirectories

add_subdirectory(docs)
add_subdirectory(tests)
endif()
Loading
Loading