From c0144a2fcf8dd7d7085106180a43f7a2288b47f9 Mon Sep 17 00:00:00 2001 From: dsh Date: Tue, 10 Nov 2026 19:09:03 +0800 Subject: [PATCH] ci: wire CTest and give the runner a pipeline `ctest --test-dir build -j` now runs the whole baseline (8 entries, 9 s) instead of six commands typed from memory, and .gitea/workflows/ci.yml drives it: baseline 11 bits, full ctest on every push widths -DR8FORGE_CELL_SIZE=8/16/32, the `widthfree` label only nightly the width sweep for cell 1..32 plus a cold cache run The tests carry labels for that reason: `widthfree` means "true at any width" (bit level slices, the synthesizer, the looping demo, the macro comment format), while flagship / byte_ops / examples pin the 11 bit word (2047 style values, 8 bit era pair counts) and are only meaningful at the default geometry. Cold cache job: throw .r8forge_cache away and let the searcher find the blocks again -- it fails if the fresh results no longer match what the repo ships, which is the cheap version of "the cache is only recomputed when the search changes". Labels in the workflow are `ubuntu-latest`; change them if the self hosted act_runner advertises something else. --- .gitea/workflows/ci.yml | 85 +++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 28 ++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 .gitea/workflows/ci.yml 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