Skip to content

Commit

Permalink
Support ip ci (#19)
Browse files Browse the repository at this point in the history
* Add a flag to run_IP to handle if the CI is IP CI or EF_UVM CI

* Rename is-ip to is_ip

* Fix if condition

* Test setup workspace

* Fix syntax errors

* Remove duplicate declaration of name

* Rename upload upload-artifact

* Use uploaded workspace

* Remove extra run:

* Fix Typo when copy and paste

* Use upload artifcat while running test

* Uses action file

* Test

* Source file directly from the repo

* ??

* Source folder for action?

* Set more env variables

* Correct paths again

* Debug

* Debug

* Fix workspace creation

* Fix paths of commits

* Download workspace after maximizing disk space

* Remove debug prints

* Add get-bus action

* Iterate over buses

* Fix syntax error

* Do mapping

* Remove extra space

* Extract all bus types

* Check step output

* Set outputs

* + Alias run_gl_all_tests to run_all_gl_tests
~ Repo URL not required for CI

* Fix wrong bus type in get-bus action

* Attempt to wrap job name in quotes to avoid missing name in the job
header

* Remove extra space?

* Prefix uploaded artifact with sim status

* Make the status more verbose and global

* Rename artifact name

* Typo fix

* Rename artifacts

* More renames

* Always run set artifact_name

* Rename test-error to sim-error

* Test support-ip-ci branch

* Fix typo in new target

* Clone master branch

* Clean up unneeded code
  • Loading branch information
kareefardi authored Apr 30, 2024
1 parent 3464fd5 commit 38ae15e
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 25 deletions.
38 changes: 38 additions & 0 deletions .github/actions/get-bus/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: 'Get Bus Type'
description: 'Get Bus Type'
outputs:
buses:
description: "Buses"
value: ${{ steps.get_buses.outputs.output }}
runs:
using: "composite"
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Extract Info from IP Yaml File
uses: mikefarah/yq@master
id: get_bus_info
with:
cmd: yq '.info.bus.[]' './${{ github.event.repository.name }}.yaml'
- name: Map to Make options
shell: bash
id: get_buses
run: |
buses=(${{ steps.get_bus_info.outputs.result }})
output=""
for bus in "${buses[@]}"
do
if [[ "$bus" == "generic" ]]; then
output="WISHBONE APB AHB $output"
elif [[ "$bus" == "APB" ]]; then
output="APB $output"
elif [[ "$bus" == "AHBL" ]]; then
output="AHB $output"
elif [[ "$bus" == "WB" ]]; then
output="WISHBONE $output"
else
echo "Unknown bus type $bus"
exit 1
fi
done
echo "output=$output" >> $GITHUB_OUTPUT
120 changes: 95 additions & 25 deletions .github/workflows/run_IP.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ name: 'Run IP'
on:
workflow_call:
inputs:
is-ip:
description: 'Flag if the CI is an IP CI'
required: false
type: boolean
default: false
url:
description: 'IP Repo URL'
required: true
required: false
default: "n/a"
type: string
test-names:
description: 'Test Names'
Expand All @@ -19,43 +25,97 @@ on:
required: true
type: string
jobs:
Setup-Work-Space:
runs-on: ubuntu-latest
outputs:
artifact_name: ${{ steps.set_artifact_name.outputs.artifact_name }}
steps:
- name: Setup Env Vars
run: |
echo "EF_UVM_PATH=${{ github.workspace }}/${{ inputs.name }}/verify/uvm-python/EF_UVM" >> $GITHUB_ENV
echo "IP_PATH=${{ github.workspace }}/${{ inputs.name }}" >> $GITHUB_ENV
echo "MY_WORKSPACE=${{ github.workspace }}/${{ inputs.name }}" >> $GITHUB_ENV
- name: Install IP (EF_UVM)
if: ${{ !inputs.is-ip }}
run: git clone ${{ inputs.url }} ${{ env.IP_PATH }}
- name: Install EF_UVM (EF_UVM)
if: ${{ !inputs.is-ip }}
uses: actions/checkout@v4
with:
path: ${{ env.EF_UVM_PATH }}
- name: Install IP (IP)
uses: actions/checkout@v4
if: ${{ inputs.is-ip }}
with:
path: ${{ env.IP_PATH }}
- name: Install EF_UVM (EF_UVM)
if: ${{ inputs.is-ip }}
run: |
git clone https://github.com/efabless/EF_UVM.git ${{ env.EF_UVM_PATH }}
- name: Set Artifact Name
id: set_artifact_name
run: |
wrap_name () {
echo "❲$1❳"
}
artifact_name=$(wrap_name "workspace")-$(wrap_name "${{ inputs.name }}")
echo "artifact_name=$artifact_name" >> $GITHUB_OUTPUT
- name: Upload Workspace
uses: actions/upload-artifact@v4
with:
path: ${{ env.MY_WORKSPACE }}
name: ${{ steps.set_artifact_name.outputs.artifact_name }}

Prepare-Tests-Matrix:
needs: ["Setup-Work-Space"]
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.set-tests-matrix.outputs.tests }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Setup Env Vars
run: |
echo "EF_UVM_PATH=${{ github.workspace }}/${{ inputs.name }}/verify/uvm-python/EF_UVM" >> $GITHUB_ENV
echo "IP_PATH=${{ github.workspace }}/${{ inputs.name }}" >> $GITHUB_ENV
echo "MY_WORKSPACE=${{ github.workspace }}/${{ inputs.name }}" >> $GITHUB_ENV
- name: Download Workspace
uses: actions/download-artifact@v4
with:
name: ${{ needs.Setup-Work-Space.outputs.artifact_name }}
path: ${{ env.MY_WORKSPACE }}
- 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: |
python3 ${{ env.EF_UVM_PATH }}/.github/scripts/get_tests_matrix.py --tests ${{ inputs.test-names }} --buses ${{ inputs.buses }}
echo "tests=$(python3 ${{ env.EF_UVM_PATH }}/.github/scripts/get_tests_matrix.py --tests ${{ inputs.test-names }} --buses ${{ inputs.buses }})" >> "$GITHUB_OUTPUT"
Run-IP:
needs: [Prepare-Tests-Matrix]
needs: [Setup-Work-Space, 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 }}
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
echo "EF_UVM_PATH=${{ github.workspace }}/${{ inputs.name }}/verify/uvm-python/EF_UVM" >> $GITHUB_ENV
echo "IP_PATH=${{ github.workspace }}/${{ inputs.name }}" >> $GITHUB_ENV
echo "MY_WORKSPACE=${{ github.workspace }}/${{ inputs.name }}" >> $GITHUB_ENV
echo "STATUS=env-error" >> $GITHUB_ENV
- name: Set More Env Variables
shell: bash
run: |
echo "WORKING_DIRECTORY=${{ env.IP_PATH }}/verify/uvm-python" >> $GITHUB_ENV
echo "SIM_DIRECTORY=${{ env.IP_PATH }}/verify/uvm-python/sim" >> $GITHUB_ENV
- name: Setup OpenLane
uses: efabless/EF_UVM/.github/actions/setup-openlane-nix@main
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: Download Workspace
uses: actions/download-artifact@v4
with:
name: ${{ needs.Setup-Work-Space.outputs.artifact_name }}
path: ${{ env.MY_WORKSPACE }}
- name: Install Docker Image
run: docker pull efabless/dv:cocotb
- name: Run Test
Expand All @@ -67,6 +127,7 @@ jobs:
make run_$test SIM_TAG=${{ matrix.tests.tag }} BUS_TYPE=${{ matrix.tests.bus }}
done
- name: Check Test Results
id: check_results
shell: bash
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
Expand All @@ -80,34 +141,43 @@ jobs:
if [ "$passed_count" -eq 0 ]; then
echo "Error: No passed test results found"
echo "STATUS=env-error" >> $GITHUB_ENV
exit 1
elif [ "$failed_count" -ne 0 ] || [ "$unknown_count" -ne 0 ]; then
echo "Error: There are failed or unknown test results"
echo "STATUS=sim-error" >> $GITHUB_ENV
exit 1
else
echo "All tests passed successfully"
echo "STATUS=success" >> $GITHUB_ENV
fi
- name: Save IP Commit Hash
if: always()
shell: bash
working-directory: ${{ env.WORKING_DIRECTORY }}
working-directory: ${{ env.IP_PATH }}
run: git rev-parse --verify HEAD > ${{ env.SIM_DIRECTORY }}/ip-commit-hash.txt
- name: Save EF_UVM Commit Hash
if: always()
shell: bash
working-directory: ${{ env.EF_UVM_PATH }}
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: Set Artifact Name
if: always()
id: set_artifact_name
run: |
wrap_name () {
echo "❲$1❳"
}
artifact_name=$(wrap_name "${{ env.STATUS }}")-$(wrap_name "${{ inputs.name }}")-$(wrap_name "${{ matrix.tests.bus }}")-$(wrap_name "${{ matrix.tests.test }}")
echo "artifact_name=$artifact_name" >> $GITHUB_OUTPUT
- 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




name: ${{ steps.set_artifact_name.outputs.artifact_name }}
3 changes: 3 additions & 0 deletions Makefile.test
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ ifeq ($(RUN_MERGE_COVERAGE),true)
$(MAKE) run_merge_coverage
endif

.PHONY: run_gl_all_tests
run_gl_all_tests: run_all_gl_tests

# Target to run all tests in parallel
run_all_gl_tests:
@$(MAKE) generate_gl
Expand Down

0 comments on commit 38ae15e

Please sign in to comment.