Skip to content

Prepare for testing multiple ISAs #809

Prepare for testing multiple ISAs

Prepare for testing multiple ISAs #809

Workflow file for this run

name: CI test
# Controls when the action will run.
on:
pull_request:
branches: [ '**' ]
push:
branches: [ '**' ]
workflow_dispatch:
# Triggers the action 2am every day
schedule:
- cron: "0 2 * * *"
jobs:
generate-matrix:
name: Generate Matrix
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.matrix-gen.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: matrix-gen
run: echo "matrix={\"file\":$(cd .github/isa_templates/ && ls *.yaml | jq -R -s -c 'split("\n")[:-1]')}" >> "$GITHUB_OUTPUT"
ACT-sail-spike:
name: ACT-sail-spike ${{ matrix.file }})
needs: generate-matrix
runs-on: ubuntu-22.04
# Set a 60-minute time limit for this job
timeout-minutes: 60
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Set Environment Variables
run: |
xlen=$(echo "${{ matrix.file }}" | cut -c 3-4)
echo "xlen=$xlen" >> $GITHUB_ENV
- name: Checkout source
uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3 python3-pip python3-venv
sudo apt-get install -y gcc git autoconf automake libtool curl make unzip
sudo apt-get install -y autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev pkg-config
sudo apt-get install -y device-tree-compiler libboost-regex-dev libboost-system-dev
pip3 install git+https://github.com/riscv/riscof.git
- name: Build RISCV-GNU Toolchain (${{ env.xlen }} bit)
run: |
wget -c https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2024.09.03/riscv${{ env.xlen }}-elf-ubuntu-20.04-gcc-nightly-2024.09.03-nightly.tar.gz
tar -xzf riscv${{ env.xlen }}-elf-ubuntu-20.04-gcc-nightly-2024.09.03-nightly.tar.gz
mv riscv riscv${{ env.xlen }}
echo $GITHUB_WORKSPACE/riscv${{ env.xlen }}/bin >> $GITHUB_PATH
- name: Install riscv-isac
run: |
cd riscv-isac
pip3 install --editable .
- name: Install riscv-ctg
run: |
cd riscv-ctg
pip3 install --editable .
- name: Get Latest Spike Commit
run: |
SPIKE_HASH=$(git ls-remote https://github.com/riscv/riscv-isa-sim.git HEAD | awk '{ print $1}')
echo "SPIKE_HASH=$SPIKE_HASH" >> "$GITHUB_ENV"
- name: Restore cached Spike
id: cache-spike-restore
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/spike
key: spike-${{ env.SPIKE_HASH }}-RV${{ env.xlen }}
- name: Install Spike
if: steps.cache-spike-restore.outputs.cache-hit != 'true'
run: |
git clone https://github.com/riscv/riscv-isa-sim.git
cd riscv-isa-sim
mkdir build
cd build
../configure --prefix=$GITHUB_WORKSPACE/spike
make -j$(nproc)
make install
- name: Save cached Spike
if: steps.cache-spike-restore.outputs.cache-hit != 'true'
id: cache-spike-save
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}/spike
key: ${{ steps.cache-spike-restore.outputs.cache-primary-key }}
- name: Get Latest Sail Commit
run: |
SAIL_HASH=$(git ls-remote https://github.com/riscv/sail-riscv.git HEAD | awk '{ print $1}')
echo "SAIL_HASH=$SAIL_HASH" >> "$GITHUB_ENV"
- name: Restore cached Sail
id: cache-sail-restore
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/sail
key: sail-${{ env.SAIL_HASH }}-RV${{ env.xlen }}
- name: Install Sail
if: steps.cache-sail-restore.outputs.cache-hit != 'true'
run: |
sudo mkdir -p /usr/local
curl --location https://github.com/rems-project/sail/releases/download/0.18-linux-binary/sail.tar.gz | sudo tar xvz --directory=/usr/local --strip-components=1
git clone https://github.com/riscv/sail-riscv.git
cd sail-riscv
ARCH=RV${{ env.xlen }} make
mkdir -p $GITHUB_WORKSPACE/sail
mv c_emulator/riscv_sim_RV${{ env.xlen }} $GITHUB_WORKSPACE/sail/riscv_sim_RV${{ env.xlen }}
- name: Save cached Sail
if: steps.cache-sail-restore.outputs.cache-hit != 'true'
id: cache-sail-save
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}/sail
key: ${{ steps.cache-sail-restore.outputs.cache-primary-key }}
- name: Set PATH
run: |
echo $GITHUB_WORKSPACE/spike/bin >> $GITHUB_PATH
echo $GITHUB_WORKSPACE/sail >> $GITHUB_PATH
- name: Config and run riscof for ${{ matrix.file }}
run: |
cd riscof-plugins/rv${{ env.xlen }}
sed -i "/^ispec=/c\ispec=${{ github.workspace }}/.github/isa_templates/${{ matrix.file }}" config.ini
riscof run --config config.ini --suite ../../riscv-test-suite/rv${{ env.xlen }}i_m/ --env ../../riscv-test-suite/env
#Check the existance of the riscof work folder, and add the PATH to environment variable
- name: Check size and determine upload path
if: always()
id: check_size
run: |
work_folder="${{ github.workspace }}/riscof-plugins/rv${{ env.xlen }}/riscof_work/"
report_file="$work_folder/report.html"
if [ -d "$work_folder" ]; then
folder_size=$(du -sm "$work_folder" | cut -f1)
echo "Folder size: ${folder_size} MB"
if [ "$folder_size" -gt 1000 ]; then
echo "Size exceeds 1 GB. Checking if report exists."
if [ -f "$report_file" ]; then
echo "Uploading RISCOF generated report only."
echo "upload_path=$report_file" >> $GITHUB_ENV
else
echo "No report found. Skipping upload."
echo "upload_path=" >> $GITHUB_ENV
fi
else
echo "Size is within limit. Uploading complete RISCOF_WORK Folder."
echo "upload_path=$work_folder" >> $GITHUB_ENV
fi
else
echo "Folder does not exist. Skipping upload."
echo "upload_path=" >> $GITHUB_ENV
fi
# Upload the appropriate artifact (folder or report) and skip in case not exists
- name: Upload riscof artifact for rv${{ matrix.file }}
if: always() && env.upload_path != ''
uses: actions/upload-artifact@v4
with:
name: riscof-test-report-rv${{ matrix.file }}
path: /home/runner/work/riscv-arch-test/riscv-arch-test/riscof-plugins/rv${{ env.xlen }}/riscof_work/
if-no-files-found: warn
retention-days: 3
compression-level: 6
overwrite: true