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

Extend CI matrix #956

Merged
merged 1 commit into from
Sep 26, 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
26 changes: 26 additions & 0 deletions .github/scripts/parse_testlist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import sys
from json import dumps
from yaml import load, Loader
from typing import Generator


def parse_yaml(path: str) -> Generator[str, None, None]:
with open(path, 'rb') as fd:
tests = load(fd, Loader=Loader)
for test in tests:
if 'import' in test:
import_path = test['import'].split('/', 1)[1]
yield from parse_yaml(import_path)
elif 'test' in test:
yield test['test']


if __name__ == "__main__":
if len(sys.argv) == 2:
testlist = parse_yaml(f'target/{sys.argv[1]}/testlist.yaml')
else:
testlist = parse_yaml('yaml/base_testlist.yaml')
testlist = list(testlist)
# remove, will cause incomplete sim, need customized RTL
testlist.remove("riscv_csr_test")
print(dumps(testlist))
138 changes: 117 additions & 21 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,119 @@ on:
push:
pull_request:

env:
RISCV_TARGET: rv32imc

jobs:
build-spike:
uses: ./.github/workflows/build-spike.yml
test-pyflow:

generate-config:
runs-on: ubuntu-latest
outputs:
test-types: ${{ steps.test-types.outputs.tests }}
hash: ${{ steps.hash.outputs.files-hash }}
steps:
- uses: actions/checkout@v4
- id: test-types
name: Prepare test types
run: |
python3 -m pip install pyyaml
echo "tests=$(python3 .github/scripts/parse_testlist.py $RISCV_TARGET)" | tee -a $GITHUB_OUTPUT
- id: hash
name: Prepare files' hash
run: |
echo "files-hash=$(sha256sum **/*.sv **/*.py **/*.yml **/*.yaml | cut -d\ -f1 | sha256sum | cut -d\ -f1)" | tee -a $GITHUB_OUTPUT


generate-code:
runs-on: [ self-hosted, Linux, X64, gcp-custom-runners ]
container: centos:8
needs: generate-config
strategy:
fail-fast: false
matrix:
test:
- riscv_arithmetic_basic_test
test: ${{ fromJSON(needs.generate-config.outputs.test-types) }}
version: [ uvm ]
include:
- test: riscv_arithmetic_basic_test
version: pyflow
env:
GHA_EXTERNAL_DISK: additional-tools
CACHE_HASH: ${{ needs.generate-config.outputs.hash }}
steps:
- uses: actions/checkout@v3

- name: Setup Cache Metadata
id: cache_metadata
run: |
cache_code=cache_${{ matrix.test }}_${{ matrix.version }}
echo "cache_code=${cache_code}_${{ env.CACHE_HASH }}" | tee -a "$GITHUB_ENV"

- name: Cache Code
uses: actions/cache@v3
id: cache-code
timeout-minutes: 60
with:
path: test/asm_test
key: ${{ env.cache_code }}

- name: Prepare Environment
if: steps.cache-code.outputs.cache-hit != 'true'
run: _secret_environment

- name: Setup Python 3.9
if: steps.cache-code.outputs.cache-hit != 'true'
run: |
yum update -y
yum install -y python39
python3.9 -m pip install -r requirements.txt

- name: Generate UVM Tests
if: steps.cache-code.outputs.cache-hit != 'true' && matrix.version == 'uvm'
run: _secret_riscv
env:
RISCV_TEST: ${{ matrix.test }}
RISCV_TARGET: ${{ env.RISCV_TARGET }}

- name: Generate PyFlow Tests
if: steps.cache-code.outputs.cache-hit != 'true' && matrix.version == 'pyflow'
run: |
set -eo pipefail
python3 run.py --simulator pyflow \
--test ${{ matrix.test }} --iss spike \
--start_seed 999 --iterations 1 --batch_size 1 \
--isa $RISCV_TARGET --mabi ilp32 --steps gen -v -o test 2>&1 | tee test/generate.log

- name: Upload Artifacts
uses: actions/upload-artifact@v3
if: always()
with:
path: |
test/asm_test/*.S


run-tests:
runs-on: ubuntu-latest
needs: [build-spike]
needs: [ build-spike, generate-code, generate-config ]
strategy:
fail-fast: false
matrix:
test: ${{ fromJSON(needs.generate-config.outputs.test-types) }}
version:
- uvm
include:
- test: riscv_arithmetic_basic_test
version: pyflow
env:
TOOL_VERSION: d70ea67d
CACHE_HASH: ${{ needs.generate-config.outputs.hash }}

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: sudo apt-get -qqy update && sudo apt-get -qqy install gcc-riscv64-linux-gnu device-tree-compiler
run: sudo apt-get -qqy update && sudo apt-get -qqy install gcc-riscv64-unknown-elf device-tree-compiler

- name: Setup python
# python dependencies cannot be properly downloaded with new versions of python
Expand All @@ -36,10 +133,12 @@ jobs:
date=$(date +"%Y_%m_%d")
time=$(date +"%Y%m%d_%H%M%S_%N")
cache_spike_restore_key=cache_spike_
cache_spike_key=${cache_spike_restore_key}d70ea67d_${date}
cache_spike_key=${cache_spike_restore_key}${{ env.TOOL_VERSION }}_${date}
cache_code=cache_${{ matrix.test }}_${{ matrix.version }}

echo "cache_spike_restore_key=$cache_spike_restore_key" | tee -a "$GITHUB_ENV"
echo "cache_spike_key=$cache_spike_key" | tee -a "$GITHUB_ENV"
echo "cache_code=${cache_code}_${{ env.CACHE_HASH }}" | tee -a "$GITHUB_ENV"

- name: Restore Spike cache
id: cache-spike-restore
Expand All @@ -53,31 +152,28 @@ jobs:

- name: Set variables
run: |
echo "RISCV_GCC=riscv64-linux-gnu-gcc" >> $GITHUB_ENV
echo "RISCV_OBJCOPY=riscv64-linux-gnu-objcopy" >> $GITHUB_ENV
echo "RISCV_GCC=riscv64-unknown-elf-gcc" >> $GITHUB_ENV
echo "RISCV_OBJCOPY=riscv64-unknown-elf-objcopy" >> $GITHUB_ENV
echo "SPIKE_PATH=/opt/spike/bin" >> $GITHUB_ENV
echo "PYTHONPATH=pygen" >> $GITHUB_ENV

- name: Generate Tests
run: |
set -eo pipefail
python3 run.py --simulator pyflow \
--test ${{ matrix.test }} --iss spike \
--start_seed 999 --iterations 1 --batch_size 1 \
--isa rv32imc --mabi ilp32 --steps gen -v -o test 2>&1 | tee test/generate.log

- name: Patch Tests
run: find test/asm_test -name "*.S" -exec python3 .github/scripts/code_fixup.py -i {} -o {} \;
- name: Cache Code Restore
uses: actions/cache/restore@v3
id: cache-code-restore
timeout-minutes: 60
with:
path: test/asm_test
key: ${{ env.cache_code }}

- name: Run tests
- name: Run Tests
run: |
set -eo pipefail
python3 run.py --simulator pyflow \
--test ${{ matrix.test }} --iss spike --iss_timeout 60 \
--start_seed 999 --iterations 1 --batch_size 1 \
--isa rv32imc --mabi ilp32 --steps gcc_compile,iss_sim -v -o test 2>&1 | tee -a test/generate.log
--isa $RISCV_TARGET --mabi ilp32 --steps gcc_compile,iss_sim -v -o test 2>&1 | tee -a test/generate.log

- name: Upload logs
- name: Upload Artifacts
uses: actions/upload-artifact@v3
if: always()
with:
Expand Down
1 change: 1 addition & 0 deletions scripts/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def run_cmd(cmd, timeout_s=999, exit_on_error=1, check_return_code=True,
executable='/bin/bash',
universal_newlines=True,
start_new_session=True,
env=os.environ,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError:
Expand Down
1 change: 1 addition & 0 deletions yaml/simulator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- "vcs -file <cwd>/vcs.compile.option.f
+incdir+<setting>
+incdir+<user_extension>
+vcs+lic+wait
-f <cwd>/files.f -full64
-l <out>/compile.log
-LDFLAGS '-Wl,--no-as-needed'
Expand Down