diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/deploy-pages.yml new file mode 100644 index 00000000..db897826 --- /dev/null +++ b/.github/workflows/deploy-pages.yml @@ -0,0 +1,54 @@ +name: Deploy docs to GitHub Pages + +on: + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +# Skip queued runs, but never interrupt an in-flight deploy: it can leave the site partial. +concurrency: + group: pages + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 30 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Zig + uses: mlugg/setup-zig@v2 + with: + version: 0.16.0 + + - name: Build documentation + run: zig build docs + + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Upload Pages artifact + uses: actions/upload-pages-artifact@v3 + with: + path: zig-out/docs + + deploy: + needs: build + runs-on: ubuntu-latest + timeout-minutes: 10 + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 00000000..4dc56e74 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,67 @@ +name: Tests + +on: + push: + branches: [main, dev] + pull_request: + branches: [main, dev] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build_and_test: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + + steps: + - uses: actions/checkout@v4 + + - name: Setup Zig + uses: mlugg/setup-zig@v2 + with: + version: 0.16.0 + + - name: Build library + run: zig build + + - name: Build documentation + if: matrix.os == 'ubuntu-latest' + run: zig build docs + + - name: Run Zig tests + run: zig test -O ReleaseSafe ./src/test_min.zig + + python_tests: + runs-on: ubuntu-latest + timeout-minutes: 30 + + steps: + - uses: actions/checkout@v4 + + - name: Reclaim runner disk space + run: | + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc + df -h / + + - name: Setup Zig + uses: mlugg/setup-zig@v2 + with: + version: 0.16.0 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install package + run: pip install . + + - name: Run Python tests + run: python -m pytest --pyargs riley.pytests diff --git a/.gitignore b/.gitignore index 7cae8828..859a5a8e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ out/ bin/ .* !.gitignore +!.github/ # Do not keep any large output directories with images or other output in them out/ diff --git a/build.zig b/build.zig index 7cc21f45..75c91edd 100644 --- a/build.zig +++ b/build.zig @@ -51,11 +51,11 @@ pub fn build(b: *std.Build) void { optimize, build_options_module, ); - b.installArtifact(shared_lib); - _ = b.addInstallHeaderFile( + shared_lib.installHeader( b.path("src/riley/cyth/riley.h"), "riley.h", ); + b.installArtifact(shared_lib); const tests = [_]TestEntry{ .{ @@ -237,6 +237,30 @@ pub fn build(b: *std.Build) void { install_step.dependOn(&install_artifact.step); bench_bins_step.dependOn(&install_artifact.step); } + + // Rooted at the public API module, not shared_lib, whose generated wrapper + // root keeps its entry source private where autodoc cannot follow. A + // separate object also keeps doc generation out of normal builds. No + // build_options is injected here, so the -D config options have no effect: + // docs always describe the f64 / SIMD-on / fast-Newton build. + const docs_obj = b.addObject(.{ + .name = "riley", + .root_module = b.createModule(.{ + .root_source_file = b.path("src/riley/zig/riley.zig"), + .target = target, + .optimize = optimize, + .link_libc = true, + }), + }); + + const docs_install = b.addInstallDirectory(.{ + .source_dir = docs_obj.getEmittedDocs(), + .install_dir = .prefix, + .install_subdir = "docs", + }); + + const docs_step = b.step("docs", "Generate API documentation"); + docs_step.dependOn(&docs_install.step); } fn addRileySharedLibrary(