try 12 to fix CI #83
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
- push | |
jobs: | |
smoke-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up the Ocaml toolchain | |
uses: ocaml/setup-ocaml@v3 | |
with: | |
ocaml-compiler: 5 | |
- name: Fetch the generator sources | |
uses: actions/checkout@v4 | |
with: | |
path: generator | |
- name: Get the hash of the riscv sail model to fetch | |
id: sail-riscv-model-get-hash | |
run: cd generator && echo "h=$(cat conf/hash.txt)" >> "$GITHUB_OUTPUT" && echo "Fetching version $(cat sail.hash.txt) of the riscv sail model" | |
- name: Fetch the riscv sail model | |
uses: actions/checkout@v4 | |
with: | |
repository: riscv/sail-riscv | |
ref: ${{ steps.sail-riscv-model-get-hash.outputs.h }} | |
path: sail-riscv/ | |
sparse-checkout: model | |
- name: Install generator dependencies | |
run: | | |
cd generator && source ~/.bash_profile | |
export OPAMCONFIRMLEVEL=yes | |
echo "-------------------------------------" | |
opam switch list | |
echo "-------------------------------------" | |
opam update | |
sudo apt-get install build-essential libgmp-dev z3 pkg-config | |
opam install sail=0.19 | |
sudo apt-get install z3 | |
opam install . --deps-only | |
#DEBUGGING | |
eval $(opam config env) | |
echo "-------------------------------------" | |
opam switch list | |
echo "-------------------------------------" | |
sail --version | |
ls ~/.opam && echo "-------------------------" && ls ~/.opam/default && echo "---------------------------" && ls ~/.opam/default/share | |
echo "-----------------------------------" && ls ~/.opam/default/share/sail | |
- name: Running the generator | |
run: | | |
cd generator && source ~/.bash_profile | |
mv riscv_disasm old_output | |
eval $(opam config env) | |
ls ~/.opam && echo "-------------------------" && ls ~/.opam/default && echo "---------------------------" && ls ~/.opam/default/share | |
echo "-----------------------------------" && ls ~/.opam/default/share/sail | |
dune build --profile release | |
OCAMLRUNPARAM=b dune exec --profile release -- capstone_autosync_sail -f conf/sail-files-paths.txt | |
- name: Installing clang-format to automatically format the generated source code | |
run: | | |
python -m pip install clang-format | |
- name: Checking the generated code compiles and is identical to the committed generated code | |
run: | | |
cd generator/riscv_disasm | |
touch test_main.c | |
echo '#include "riscv_decode.gen.inc"' >> test_main.c | |
echo >> test_main.c | |
echo '#include "riscv_decode_compressed.gen.inc"' >> test_main.c | |
echo >> test_main.c | |
echo '#include "riscv_ast2str.gen.inc"' >> test_main.c | |
echo >> test_main.c | |
echo '#include "riscv_insn_mapping.gen.inc"' >> test_main.c | |
echo >> test_main.c | |
echo 'void main() {}' >> test_main.c | |
mv ../old_output/riscv_helpers_ast2str.h riscv_helpers_ast2str.h | |
mv ../old_output/riscv_helpers_rvconf.h riscv_helpers_rvconf.h | |
gcc test_main.c || { echo "Failure: Trying to compile the tool-generated C code failed."; exit 1; } | |
clang-format -i * | |
if ! diff -q riscv_ast.gen.inc ../old_output/riscv_ast.gen.inc > /dev/null 2>&1; then | |
echo "Failure: The tool-generated ast definition differ from the one committed in the repo." | |
exit 1 | |
fi | |
if ! diff -q riscv_decode.gen.inc ../old_output/riscv_decode.gen.inc > /dev/null 2>&1; then | |
echo "Failure: The tool-generated decoding logic differ from the one committed in the repo." | |
exit 1 | |
fi | |
if ! diff -q riscv_decode_compressed.gen.inc ../old_output/riscv_decode_compressed.gen.inc > /dev/null 2>&1; then | |
echo "Failure: The tool-generated compressed (16-bit) decoding logic differ from the one committed in the repo." | |
exit 1 | |
fi | |
if ! diff -q riscv_ast2str_tbls.gen.inc ../old_output/riscv_ast2str_tbls.gen.inc > /dev/null 2>&1; then | |
echo "Failure: The tool-generated stringification helpers differ from the one committed in the repo" | |
exit 1 | |
fi | |
if ! diff -q riscv_ast2str.gen.inc ../old_output/riscv_ast2str.gen.inc > /dev/null 2>&1; then | |
echo "Failure: The tool-generated ast stringification logic differ from the one committed in the repo" | |
exit 1 | |
fi | |
if ! diff -q riscv_insn_mapping.gen.inc ../old_output/riscv_insn_mapping.gen.inc > /dev/null 2>&1; then | |
echo "Failure: The tool-generated ast-id->instruction-id mapping logic differ from the one committed in the repo" | |
exit 1 | |
fi | |
if ! diff -q riscv_insn.gen.inc ../old_output/riscv_insn.gen.inc > /dev/null 2>&1; then | |
echo "Failure: The tool-generated instruction ids differ from the one committed in the repo" | |
exit 1 | |
fi | |
echo "Success: The tool generates compiling C code that is identical to the files committed." | |