Skip to content

Commit

Permalink
Generate rust docs and publish
Browse files Browse the repository at this point in the history
- Fix compilation by adding RUSTDOCFLAGS
- Add CI job to publish docs (modified from hotshot)
- Add a just recipe
- Update README

Close #1517
  • Loading branch information
sveitser committed May 29, 2024
1 parent 2316c78 commit 691ed10
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 6 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Documentation
on:
push:
branches:
- "main"
- "release-*"
pull_request:
schedule:
- cron: "0 0 * * 1"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ (github.ref == 'refs/heads/main' && github.run_number) || github.ref }}
cancel-in-progress: true

env:
RUSTDOCFLAGS: --cfg async_executor_impl="async-std" --cfg async_channel_impl="async-std"

jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Just
run: sudo apt-get install -y just

- uses: Swatinem/rust-cache@v2
name: Enable Rust Caching

- name: Build Docs
run: |
just doc
- name: Create documentation
if: ${{ github.ref == 'refs/heads/main' }}
run: |
cp -R target/doc public
echo '<meta http-equiv="refresh" content="0; url=sequencer">' > public/index.html
- name: Deploy
uses: peaceiris/actions-gh-pages@v4
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
cname: sequencer.docs.espressosys.com
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Espresso Sequencer

[![Build](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/build.yml/badge.svg)](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/build.yml)
[![Docs](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/doc.yml/badge.svg)](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/doc.yml)
[![Contracts](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/contracts.yml/badge.svg)](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/contracts.yml)
[![Lint](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/lint.yml/badge.svg)](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/lint.yml)
[![Audit](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/audit.yml/badge.svg)](https://github.com/EspressoSystems/espresso-sequencer/actions/workflows/audit.yml)
Expand Down Expand Up @@ -28,6 +29,15 @@ a dockerized Espresso Sequencer network with an example Layer 2 rollup applicati
- Activate the environment with `nix-shell`, or `nix develop`, or `direnv allow` if using [direnv](https://direnv.net/).
- For installation without nix please see [ubuntu.md](./doc/ubuntu.md).

## Documentation
The rust code documentation can be found at
[http://sequencer.docs.espressosys.com](http://sequencer.docs.espressosys.com).
Please note the disclaimer about API stability at the end of the readme.

To generate the documentation locally and view it in the browser, run

just doc --open

## Run the tests

just pull # to pull docker images
Expand Down
13 changes: 7 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
# node=error: disable noisy anvil output
RUST_LOG = "info,libp2p=off,isahc=error,surf=error,node=error";
RUST_BACKTRACE = 1;
RUSTFLAGS =
" --cfg async_executor_impl=\"async-std\" --cfg async_channel_impl=\"async-std\" --cfg hotshot_example";
ASYNC_FLAGS = " --cfg async_executor_impl=\"async-std\" --cfg async_channel_impl=\"async-std\" ";
RUSTFLAGS = "${ASYNC_FLAGS} --cfg hotshot_example";
RUSTDOCFLAGS = ASYNC_FLAGS;
# Use a distinct target dir for builds from within nix shells.
CARGO_TARGET_DIR = "target/nix";

Expand Down Expand Up @@ -92,7 +93,7 @@
in
import ./cross-shell.nix {
inherit pkgs;
inherit RUST_LOG RUST_BACKTRACE RUSTFLAGS CARGO_TARGET_DIR;
inherit RUST_LOG RUST_BACKTRACE RUSTFLAGS RUSTDOCFLAGS CARGO_TARGET_DIR;
};
in
with pkgs; {
Expand Down Expand Up @@ -231,7 +232,7 @@
'' + self.checks.${system}.pre-commit-check.shellHook;
RUST_SRC_PATH = "${stableToolchain}/lib/rustlib/src/rust/library";
FOUNDRY_SOLC = "${solc}/bin/solc";
inherit RUST_LOG RUST_BACKTRACE RUSTFLAGS CARGO_TARGET_DIR;
inherit RUST_LOG RUST_BACKTRACE RUSTFLAGS RUSTDOCFLAGS CARGO_TARGET_DIR;
};
devShells.crossShell =
crossShell { config = "x86_64-unknown-linux-musl"; };
Expand All @@ -252,7 +253,7 @@
protobuf # to compile libp2p-autonat
toolchain
];
inherit RUST_LOG RUST_BACKTRACE RUSTFLAGS CARGO_TARGET_DIR;
inherit RUST_LOG RUST_BACKTRACE RUSTFLAGS RUSTDOCFLAGS CARGO_TARGET_DIR;
};
devShells.coverage =
let
Expand Down Expand Up @@ -291,7 +292,7 @@
protobuf # to compile libp2p-autonat
stableToolchain
];
inherit RUST_LOG RUST_BACKTRACE RUSTFLAGS CARGO_TARGET_DIR;
inherit RUST_LOG RUST_BACKTRACE RUSTFLAGS RUSTDOCFLAGS CARGO_TARGET_DIR;
};
});
}
3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
default:
just --list

doc *args:
cargo doc --no-deps --document-private-items {{args}}

demo *args:
docker compose up {{args}}

Expand Down

0 comments on commit 691ed10

Please sign in to comment.