Skip to content

Commit

Permalink
CI Enhancements (#17)
Browse files Browse the repository at this point in the history
* Better matrix attempt

* Remove uses

* Fix indentation

* Fix indent

* Only run alt

* Fix matrix input

* Fix test matrix

* Array to string

* fromJSON ?

* Use single string

* Matrix value

* ??

* Syntax error

* Checkout

* Naming

* typo

* Better names

* Fix old script name

* More typos and renames

* Debug

* Fix wrong output name

* Attempt to run GL sims

* Include action folder

* Cannot have runs-on

* Run openlane smoke-test in setup
Pull Container before running test
Fix passing CLI arguments to nix run

* Add shell

* Move things around size maximizing
Fix openlane config path

* Checkout because we are using custom file

* Change run dir for GL and RTL

* Separat GL and RTL Sims

* Only setup openlane for GL sims

* Single quotes

* update ci test set with supported buses

* ~ Adjust matrices to pass bus

* ~ Set BUS_TYPE
~ Rename artifacts to use bus type

* correct bus type syntax

* Declare env variables

* Add commit-hashes to the other Artifact upload

* Always tar

* Add extra space in job name

---------

Co-authored-by: M0stafaRady <[email protected]>
Co-authored-by: Mostafa Rady <[email protected]>
  • Loading branch information
3 people authored Apr 22, 2024
1 parent 7a60229 commit d9a2492
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 139 deletions.
24 changes: 24 additions & 0 deletions .github/actions/setup-openlane-nix/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'Setup OpenLane'
description: 'Install Nix and Setup OpenLane cachix'
runs:
using: "composite"
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
remove-dotnet: "true"
remove-android: "true"
remove-haskell: "true"
remove-codeql: "true"
remove-docker-images: "true"
root-reserve-mb: 20480

- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
with:
extra-conf: |
extra-substituters = https://openlane.cachix.org
extra-trusted-public-keys = openlane.cachix.org-1:qqdwh+QMNGmZAuyeQJTH9ErW57OWSvdtuwfBKdS254E=
- name: Run OpenLane Smoke Test
shell: bash
run: nix run github:efabless/openlane2 -- --smoke-test
29 changes: 29 additions & 0 deletions .github/scripts/get_IPs_matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import yaml
import json


def main():
test_set_yaml = ".github/test_set.yaml"
output_matrix = {"IPs": []}
test_set_stream = open(test_set_yaml)
data = yaml.load(test_set_stream, Loader=yaml.Loader)
for item in data:
tests = item["tests"]
name = item["name"]
url = item["url"]
bus = item["bus"]
output_matrix["IPs"].append(
{
"name": name,
"url": url,
"test-names": ",".join(tests),
"buses": " ".join(bus),
}
)

print(json.dumps(output_matrix))
test_set_stream.close()


if __name__ == "__main__":
main()
33 changes: 19 additions & 14 deletions .github/scripts/get_tests_matrix.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import yaml
import json
import argparse


def main():
test_set_yaml = ".github/test_set.yaml"
parser = argparse.ArgumentParser()
parser.add_argument("--tests", nargs="*")
parser.add_argument("--buses", nargs="*")
args = parser.parse_args()
tests = args.tests
buses = args.buses
tests = " ".join(tests).split(",")
output_matrix = {"tests": []}
test_set_stream = open(test_set_yaml)
data = yaml.load(test_set_stream, Loader=yaml.Loader)
for item in data:
tests = item["tests"]
name = item["name"]
url = item["url"]
for test in tests:
output_matrix["tests"].append(
{"name": name, "url": url, "test-names": test}
)
for test in tests:
output_matrix["tests"].append({"test": test, "tag": "RTL"})
gl_tests = []
for name in test.split():
gl_tests.append(f"gl_{name}")
output_matrix["tests"].append({"test": " ".join(gl_tests), "tag": "GL"})

print(json.dumps(output_matrix))
test_set_stream.close()
output_matrix_with_buses = {"tests": []}
for bus in buses:
for test in output_matrix["tests"]:
output_matrix_with_buses["tests"].append({**test, **{"bus": bus}})
print(json.dumps(output_matrix_with_buses))


if __name__ == "__main__":
Expand Down
30 changes: 23 additions & 7 deletions .github/test_set.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
- name: EF_GPIO8
url: https://github.com/efabless/EF_GPIO8.git
tests:
- gpio8_all_out_test gpio8_all_in_test
- gpio8_all_out_test gpio8_all_in_test
bus:
- APB
- AHB
- WISHBONE
- name: EF_UART
url: https://github.com/efabless/EF_UART.git
tests:
- TX_StressTest RX_StressTest LoopbackTest PrescalarStressTest
- LengthParityTXStressTest LengthParityRXStressTest WriteReadRegsTest
- TX_StressTest RX_StressTest LoopbackTest PrescalarStressTest
- LengthParityTXStressTest LengthParityRXStressTest WriteReadRegsTest
bus:
- APB
- AHB
- WISHBONE
- name: EF_TMR32
url: https://github.com/efabless/EF_TMR32.git
tests:
- pwm_actions_test time_vary_test
- pwm_pr_test pwm_tmr_test
- pwm_actions_test time_vary_test
- pwm_pr_test pwm_tmr_test
bus:
- APB
- AHB
- WISHBONE
- name: MS_QSPI_XIP_CACHE
url: https://github.com/efabless/MS_QSPI_XIP_CACHE.git
tests:
- flashReadTest flashResetTest flashRdWrTest
- flashReadTest flashResetTest flashRdWrTest
bus:
- AHB
- name: OL-DFFRAM
url: https://github.com/efabless/OL-DFFRAM.git
tests:
- dffram_wr_rd_test dffram_corners_test
- dffram_wr_rd_test dffram_corners_test
bus:
- AHB
50 changes: 18 additions & 32 deletions .github/workflows/action.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
name: Test IPs
name: Run Tests for IPs
on: [push]
jobs:
Prepare-Tests-Matrix:
Prepare-IPs-Matrix:
runs-on: ubuntu-latest
outputs:
test: ${{ steps.set-tests-matrix.outputs.test }}
IPs: ${{ steps.set-IPs-matrix.outputs.IPs }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set Tests Matrix
id: set-tests-matrix
run: echo "test=$(python3 ./.github/scripts/get_tests_matrix.py)" >> "$GITHUB_OUTPUT"

Test1:
runs-on: ubuntu-latest
needs: [Prepare-Tests-Matrix]
name: ${{ matrix.tests.name }}/${{ matrix.tests.test-names }}
- name: Set IPs Matrix
id: set-IPs-matrix
run: |
python3 ./.github/scripts/get_IPs_matrix.py
echo "IPs=$(python3 ./.github/scripts/get_IPs_matrix.py)" >> "$GITHUB_OUTPUT"
IPs:
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.Prepare-Tests-Matrix.outputs.test) }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Run Test
uses: ./.github/actions/run-test
with:
url: ${{ matrix.tests.url }}
test-names: ${{ matrix.tests.test-names }}
name: ${{ matrix.tests.name }}
# Test2:
# strategy:
# fail-fast: false
# matrix: ${{ fromJSON(needs.Prepare-Tests-Matrix.outputs.test) }}
# needs: [Prepare-Tests-Matrix]
# name: Run Test (Separate workflow)
# uses: ./.github/workflows/run_test.yaml
# with:
# url: ${{ matrix.tests.url }}
# test-names: ${{ matrix.tests.test-names }}
# name: ${{ matrix.tests.name }}
matrix: ${{ fromJSON(needs.Prepare-IPs-Matrix.outputs.IPs) }}
needs: [Prepare-IPs-Matrix]
name: ${{ matrix.IPs.name }}
uses: ./.github/workflows/run_IP.yaml
with:
url: ${{ matrix.IPs.url }}
test-names: "${{ matrix.IPs.test-names }}"
name: ${{ matrix.IPs.name }}
buses: ${{ matrix.IPs.buses }}
113 changes: 113 additions & 0 deletions .github/workflows/run_IP.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: 'Run IP'
on:
workflow_call:
inputs:
url:
description: 'IP Repo URL'
required: true
type: string
test-names:
description: 'Test Names'
required: true
type: string
name:
description: 'IP Name'
required: true
type: string
buses:
description: 'Bus Types'
required: true
type: string
jobs:
Prepare-Tests-Matrix:
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.set-tests-matrix.outputs.tests }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set Tests Matrix
id: set-tests-matrix
run: echo "tests=$(python3 ./.github/scripts/get_tests_matrix.py --tests ${{ inputs.test-names }} --buses ${{ inputs.buses }})" >> "$GITHUB_OUTPUT"

Run-IP:
needs: [Prepare-Tests-Matrix]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.Prepare-Tests-Matrix.outputs.tests) }}
name: ${{ matrix.tests.bus }} / ${{ matrix.tests.test }}
steps:
- name: Set Env Variables
shell: bash
run: |
echo "WORKING_DIRECTORY=/home/runner/work/${{ inputs.name }}/verify/uvm-python" >> $GITHUB_ENV
echo "SIM_DIRECTORY=/home/runner/work/${{ inputs.name }}/verify/uvm-python/sim" >> $GITHUB_ENV
- name: Check out repository code
uses: actions/checkout@v4
- name: Setup OpenLane
if: ${{ matrix.tests.tag == 'GL' }}
uses: ./.github/actions/setup-openlane-nix
- name: Clone IP
shell: bash
run: git clone ${{ inputs.url }} /home/runner/work/${{ inputs.name }}
- name: Check out repository code
uses: actions/checkout@v4
- name: Copy EF_UVM to verify/uvm-python (workaround)
shell: bash
run: cp -r $(pwd) ${{ env.WORKING_DIRECTORY }}
- name: Install Docker Image
run: docker pull efabless/dv:cocotb
- name: Run Test
shell: bash
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
for test in ${{ matrix.tests.test }}; do
echo "Running Test $test"
make run_$test SIM_TAG=${{ matrix.tests.tag }} BUS_TYPE=${{ matrix.tests.bus }}
done
- name: Check Test Results
shell: bash
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
passed_count=$(find ${{ env.SIM_DIRECTORY }}/* -type f -name 'passed' | wc -l)
failed_count=$(find ${{ env.SIM_DIRECTORY }}/* -type f -name 'failed' | wc -l)
unknown_count=$(find ${{ env.SIM_DIRECTORY }}/* -type f -name 'unknown' | wc -l)
echo "Passed: $passed_count"
echo "Failed: $failed_count"
echo "Unknown: $unknown_count"
if [ "$passed_count" -eq 0 ]; then
echo "Error: No passed test results found"
exit 1
elif [ "$failed_count" -ne 0 ] || [ "$unknown_count" -ne 0 ]; then
echo "Error: There are failed or unknown test results"
exit 1
else
echo "All tests passed successfully"
fi
- name: Save IP Commit Hash
if: always()
shell: bash
working-directory: ${{ env.WORKING_DIRECTORY }}
run: git rev-parse --verify HEAD > ${{ env.SIM_DIRECTORY }}/ip-commit-hash.txt
- name: Save EF_UVM Commit Hash
if: always()
shell: bash
run: git rev-parse --verify HEAD > ${{ env.SIM_DIRECTORY }}/EF_UVM-commit-hash.txt
- name: Tar Sim Directory
if: always()
shell: bash
working-directory: ${{ env.WORKING_DIRECTORY }}
run: tar -czf sim.tar.gz sim
- name: Upload Logs and Artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ inputs.name }}-${{ matrix.tests.bus }}-${{ matrix.tests.test }}-sim
path: ${{ env.WORKING_DIRECTORY }}/*.tar.gz




Loading

0 comments on commit d9a2492

Please sign in to comment.