Skip to content

Fixes

Fixes #2808

Workflow file for this run

# Copyright 2020 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# Run regression tests on Snitch's Docker container.
# Pull requests from forks cannot deploy the Docker container due to missing
# secrets, thus we only enable this workflow on push triggers.
name: ci
on: [push]
env:
FORCE_COLOR: 1
jobs:
##########################
# Build Docker Container #
##########################
build-docker:
name: Deploy Docker image
runs-on: ubuntu-22.04
# Export Docker image name used by dependent jobs
outputs:
image_name: ${{ steps.image_name.outputs.image_name }}
steps:
- name: Define Docker image name
id: image_name
# To satisfy Docker tag naming requirements, we replace all slashes
# in the ref name with dashes.
run: |
SANITIZED_REF_NAME="${GITHUB_REF_NAME//\//-}"
echo "Sanitized GITHUB_REF_NAME: $SANITIZED_REF_NAME"
IMAGE_NAME="ghcr.io/${GITHUB_REPOSITORY}:${SANITIZED_REF_NAME}"
echo "Image name: $IMAGE_NAME"
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
docker-images: false
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: GHCR Log-in
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max`
file: util/container/Dockerfile
push: true
tags: ${{ steps.image_name.outputs.image_name }}
########
# Docs #
########
build-docs:
name: Build documentation
runs-on: ubuntu-22.04
needs: build-docker
container:
image: ${{ needs.build-docker.outputs.image_name }}
steps:
- uses: actions/checkout@v2
- name: Build docs
run: make docs
deploy-docs:
name: Deploy documentation
runs-on: ubuntu-22.04
needs: build-docker
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
container:
image: ${{ needs.build-docker.outputs.image_name }}
steps:
- uses: actions/checkout@v2
# For some reason, the checkout is done by a different user
# than that deploying to Github (root, possibly due to Docker).
# So we need to set the repository as a safe directory.
- name: Git config safe.directory
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Generate documentation sources
run: |
make doc-srcs
make doxygen-docs
- name: Build and deploy documentation
run: mkdocs gh-deploy --force
#####################
# Python unit tests #
#####################
pytest:
name: Python unit tests
runs-on: ubuntu-22.04
needs: build-docker
container:
image: ${{ needs.build-docker.outputs.image_name }}
steps:
- uses: actions/checkout@v2
- name: Run pytest
run: pytest
##############################################
# Simulate SW on Snitch Cluster w/ Verilator #
##############################################
sw-snitch-cluster-vlt:
name: Simulate SW on Snitch Cluster w/ Verilator
runs-on: ubuntu-22.04
needs: build-docker
container:
image: ${{ needs.build-docker.outputs.image_name }}
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Hash Verilator prerequisites
id: verilator-hash
uses: colluca/list-make-prerequisites@v1.0.3
with:
working-directory: target/snitch_cluster
target: verilator
flags: --recursive
- name: Set up cache for Verilator build
id: verilator-cache
uses: actions/cache@v3
with:
path: target/snitch_cluster/bin
key: verilator-${{ steps.verilator-hash.outputs.hash }}
restore-keys: |
verilator-
- name: Build Hardware
if: steps.verilator-cache.outputs.cache-hit != 'true'
working-directory: target/snitch_cluster
run: |
make CFG_OVERRIDE=cfg/github-ci.json VLT_JOBS=1 verilator
- name: Build Software
working-directory: target/snitch_cluster
run: |
make CFG_OVERRIDE=cfg/github-ci.json sw
- name: Run Tests
working-directory: target/snitch_cluster
run: |
./util/run.py sw/run.yaml --simulator verilator -j
./util/run.py sw/riscv_tests_isa.yaml --simulator verilator -j
- name: Annotate traces
working-directory: target/snitch_cluster
run: |
make SIM_DIR=./runs/simple annotate -j
######################
# Sources Up-to-Date #
######################
sources-up-to-date:
name: Check Sources Up-to-Date
runs-on: ubuntu-22.04
needs: build-docker
container:
image: ${{ needs.build-docker.outputs.image_name }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Generate opcodes
run: |
./util/generate-opcodes.sh
- name: Generate RTL sources
working-directory: target/snitch_cluster
run: |
make rtl
# For some reason, the checkout is done by a different user,
# than that running `git diff` (root, possibly due to Docker).
# So we need to set the repository as a safe directory.
- name: Git config safe.directory
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Diff porcelain
uses: mmontes11/diff-porcelain@v0.0.1
with:
message: Found differences, please update all sources