diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..1206493 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,85 @@ +# Gitea act_runner. Labels: change `runs-on` to whatever label your runner +# advertises (a self hosted act_runner usually shows `ubuntu-latest` unless you +# gave it custom labels). +# +# push / PR : the 11 bit baseline (ctest, ~10 s) + every width in the matrix. +# nightly : the same width sweep for a wider range, plus a cold cache run that +# proves the synthesizer still finds the committed blocks. +name: ci + +on: + push: + pull_request: + schedule: + - cron: "17 3 * * *" # nightly + workflow_dispatch: + +jobs: + baseline: + name: baseline (11 bit) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: configure + run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + - name: build + run: cmake --build build -j"$(nproc)" + - name: ctest + run: ctest --test-dir build -j"$(nproc)" --output-on-failure + + widths: + # A build of another cell width is one configure away (-DR8FORGE_CELL_SIZE). + # Only the `widthfree` tests are required here: examples/ pins 2047 style + # values and byte_op_test drives the 8/11 bit word macros, so neither means + # anything at 7 or 32 bits. + name: cell ${{ matrix.cell }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + cell: [8, 16, 32] + steps: + - uses: actions/checkout@v4 + - name: configure + run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DR8FORGE_CELL_SIZE=${{ matrix.cell }} + - name: build + run: cmake --build build -j"$(nproc)" + - name: width free tests + run: ctest --test-dir build -L widthfree -j"$(nproc)" --output-on-failure + + nightly: + name: nightly sweep + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + cell: [1, 2, 4, 7, 8, 11, 12, 16, 24, 32] + steps: + - uses: actions/checkout@v4 + - name: configure + run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DR8FORGE_CELL_SIZE=${{ matrix.cell }} + - name: build + run: cmake --build build -j"$(nproc)" + - name: width free tests + run: ctest --test-dir build -L widthfree -j"$(nproc)" --output-on-failure + + cold-cache: + # The committed .r8forge_cache is trusted by every build, so once a night we + # throw it away and let the searcher find the blocks again. A failure here + # means the cache no longer matches what the current model searches for. + name: cold cache + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: configure + run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + - name: build + run: cmake --build build -j"$(nproc)" + - name: forget the cache + run: rm -rf .r8forge_cache + - name: search again + run: ctest --test-dir build -R 'flagship|synth_full_add' --output-on-failure + - name: the fresh results are what we ship + run: git status --short .r8forge_cache && test -d .r8forge_cache diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e0ee96..5450877 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,3 +53,31 @@ target_link_libraries(r8forge_cost_par r8forge_core) add_executable(r8forge_cost_search tests/cost_search.cc) target_link_libraries(r8forge_cost_search r8forge_core) +# ---- tests ------------------------------------------------------------------ +# `ctest --test-dir build -j` runs the whole baseline. Every entry is a program +# under tests/ that exits non zero on failure; the working directory is the repo +# root because the drivers use relative paths. +# +# Labels: `widthfree` means "true at any cell width" (bit level slices, the +# synthesizer, the looping demo, the macro comment format). Everything else +# assumes the default 11 bit geometry -- examples/ fixes 2047 style values and +# byte_op_test drives the 8/11 bit word macros -- so a CI matrix over +# -DR8FORGE_CELL_SIZE runs only the widthfree set. +enable_testing() +set(R8FORGE_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + +add_test(NAME flagship COMMAND r8forge asm/test.r8asm) +add_test(NAME byte_ops COMMAND r8forge_byte_op_test) +add_test(NAME examples COMMAND r8forge_examples_test examples) +add_test(NAME synth_full_add COMMAND r8forge_synth_test examples/full_add.r8asm) +add_test(NAME bit_add_slice COMMAND r8forge verify_clb_bit_add_nc.r8asm) +add_test(NAME bit_inc_slice COMMAND r8forge verify_clb_bit_inc_nc.r8asm) +add_test(NAME loop_derive COMMAND r8forge_derive verify_loop.r8asm -1 0=5) +add_test(NAME macro_docs COMMAND r8forge_macro_docs_test) + +set_tests_properties(flagship byte_ops examples PROPERTIES LABELS "default-width") +set_tests_properties(synth_full_add bit_add_slice bit_inc_slice loop_derive + macro_docs PROPERTIES LABELS "widthfree") +set_tests_properties(flagship byte_ops examples synth_full_add bit_add_slice + bit_inc_slice loop_derive macro_docs + PROPERTIES WORKING_DIRECTORY ${R8FORGE_TEST_DIR}) \ No newline at end of file