Skip to content

Commit

Permalink
Merge pull request #42 from clash-lang/add-all-check
Browse files Browse the repository at this point in the history
Add all check to CI
  • Loading branch information
martijnbastiaan authored Dec 4, 2024
2 parents 2eced42 + e697bfd commit 5921511
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
35 changes: 35 additions & 0 deletions .github/scripts/all_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
"""
Makes sure:
* All jobs are listed in the 'all' job
* Only existing tests are listed
"""

# SPDX-FileCopyrightText: 2022 Google LLC
#
# SPDX-License-Identifier: Apache-2.0

import sys
import yaml

CI_PATH = ".github/workflows/ci.yml"
ALL_TEST = "all"

def main():
ci_yml_fp = open(CI_PATH, "r")
ci_yml_parsed = yaml.load(ci_yml_fp, Loader=yaml.FullLoader)

all_jobs = set(ci_yml_parsed['jobs'].keys()) - {ALL_TEST}
all_needs = set(ci_yml_parsed["jobs"][ALL_TEST]["needs"])

if all_jobs - all_needs:
sys.exit(f"Not all jobs mentioned in {ALL_TEST}.needs: {all_jobs - all_needs}")

if all_needs - all_jobs:
sys.exit(f"Non-existing jobs found in {ALL_TEST}.needs: {all_needs - all_jobs}")


if __name__ == '__main__':
main()
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,36 @@ jobs:
- name: Run `clash-vexriscv-sim` HDL test
run: |
cabal run clash-vexriscv-sim:hdl-test
all:
name: All jobs finished
if: ${{ !cancelled() }}
needs: [
'license-check',
'rust-checks',
'vex-riscv',
'rust-build-programs'
]
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check dependencies for failures
run: |
# Test all dependencies for success/failure
set -x
success="${{ contains(needs.*.result, 'success') }}"
fail="${{ contains(needs.*.result, 'failure') }}"
set +x
# Test whether success/fail variables contain sane values
if [[ "${success}" != "true" && "${success}" != "false" ]]; then exit 1; fi
if [[ "${fail}" != "true" && "${fail}" != "false" ]]; then exit 1; fi
# We want to fail if one or more dependencies fail. For safety, we introduce
# a second check: if no dependencies succeeded something weird is going on.
if [[ "${fail}" == "true" || "${success}" == "false" ]]; then
echo "One or more dependency failed, or no dependency succeeded."
exit 1
fi
6 changes: 3 additions & 3 deletions clash-vexriscv/src/ffi/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void set_comb_inputs(VVexRiscv *top, const COMB_INPUT *input)
}

// Set all outputs
void set_ouputs(VVexRiscv *top, OUTPUT *output)
void set_outputs(VVexRiscv *top, OUTPUT *output)
{
output->iBusWishbone_CYC = top->iBusWishbone_CYC;
output->iBusWishbone_STB = top->iBusWishbone_STB;
Expand Down Expand Up @@ -129,7 +129,7 @@ void vexr_init_stage1(VerilatedVcdC *vcd, VVexRiscv *top, const NON_COMB_INPUT *
if (vcd != NULL) {
vcd->dump(contextp->time());
}
set_ouputs(top, output);
set_outputs(top, output);

// Advance time by 50 nanoseconds. This is an arbitrary value. Ideally, we would
// do something similar to Clash's template tag "~LONGESTPERIOD".
Expand Down Expand Up @@ -166,7 +166,7 @@ void vexr_step_rising_edge(VerilatedVcdC *vcd, VVexRiscv *top, uint64_t time_add
}

// Set all outputs
set_ouputs(top, output);
set_outputs(top, output);
}

void vexr_step_falling_edge(VerilatedVcdC *vcd, VVexRiscv *top, uint64_t time_add, const COMB_INPUT *input)
Expand Down

0 comments on commit 5921511

Please sign in to comment.