Skip to content

Commit 34d4bcc

Browse files
committed
chore: update to use submodule in build in ci
1 parent 741daa9 commit 34d4bcc

File tree

12 files changed

+94
-527
lines changed

12 files changed

+94
-527
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,39 @@ env:
1111
RUST_VERSION: 1.81.0
1212

1313
jobs:
14+
build-explorer:
15+
runs-on: ubuntu-latest
16+
needs: [fmt, cairofmt]
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
submodules: true
21+
- uses: oven-sh/setup-bun@v1
22+
with:
23+
bun-version: latest
24+
- name: Build Explorer UI
25+
run: |
26+
cd crates/katana/explorer/ui
27+
bun install
28+
bun run build
29+
- uses: actions/upload-artifact@v4
30+
with:
31+
name: explorer-dist
32+
path: crates/katana/explorer/ui/dist
33+
1434
build:
1535
runs-on: ubuntu-latest-4-cores
16-
needs: [fmt, cairofmt]
36+
needs: [fmt, cairofmt, build-explorer]
1737
container:
1838
image: ghcr.io/dojoengine/dojo-dev:v1.2.1
1939
steps:
2040
- uses: actions/checkout@v3
41+
with:
42+
submodules: true
43+
- uses: actions/download-artifact@v4
44+
with:
45+
name: explorer-dist
46+
path: crates/katana/explorer/ui/dist
2147
- uses: Swatinem/rust-cache@v2
2248
- run: |
2349
cargo build -r --bin katana

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ examples/spawn-and-move/manifests/saya/**
2424
**/*.log
2525

2626
artifacts/
27+
28+
# Explorer build output
29+
crates/katana/explorer/ui/dist/

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44
[submodule "crates/katana/contracts/piltover"]
55
path = crates/katana/contracts/piltover
66
url = https://github.com/keep-starknet-strange/piltover.git
7+
[submodule "crates/katana/explorer/ui"]
8+
path = crates/katana/explorer/ui
9+
url = https://github.com/ayushtom/dojo-explorer
10+
branch = dist

crates/katana/cli/src/args.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,16 @@ impl NodeArgs {
243243
};
244244

245245
let mut cors_origins = self.server.http_cors_origins.clone();
246-
246+
247247
// Add explorer URL to CORS origins if explorer is enabled
248248
if self.explorer.explorer {
249+
// Add both http://127.0.0.1:PORT and http://localhost:PORT
250+
cors_origins.push(
251+
HeaderValue::from_str(&format!("http://127.0.0.1:{}", self.explorer.explorer_port))
252+
.context("Failed to create CORS header")?,
253+
);
249254
cors_origins.push(
250-
HeaderValue::from_str(&format!("{}", self.explorer.addr()))
255+
HeaderValue::from_str(&format!("http://localhost:{}", self.explorer.explorer_port))
251256
.context("Failed to create CORS header")?,
252257
);
253258
}

crates/katana/explorer/Cargo.toml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
[package]
2-
build = "build.rs"
3-
description = "Embedded explorer UI for Katana"
4-
edition.workspace = true
5-
include = [ "Cargo.toml", "build.rs", "dist/**/*", "src/**/*" ]
6-
license.workspace = true
72
name = "katana-explorer"
8-
repository.workspace = true
93
version.workspace = true
4+
edition.workspace = true
5+
repository.workspace = true
6+
license-file.workspace = true
107

118
[dependencies]
129
anyhow.workspace = true
13-
tracing.workspace = true
1410
url.workspace = true
11+
tiny_http.workspace = true
12+
tracing.workspace = true
1513

16-
rust-embed = "6.8.1"
17-
tiny_http = "0.12"
18-
urlencoding = "2.1.2"
14+
[build-dependencies]
15+
anyhow.workspace = true

crates/katana/explorer/README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,50 @@
11
# Katana Explorer
22

3-
This crate embeds the Katana Explorer UI files directly into the binary, eliminating the need for users to build the explorer themselves.
3+
This crate provides the Katana Explorer UI server functionality. The UI code is maintained in a separate repository and included here as a git submodule.
44

55
## Structure
66

7-
The explorer build files are expected to be in the `dist` directory within this crate. These files are embedded at compile time using the `rust-embed` crate.
7+
The explorer UI code is located in the `ui` directory as a git submodule. The built files must be present in `ui/dist` directory for the explorer to work.
8+
9+
## Building the Explorer
10+
11+
### In CI
12+
13+
The explorer UI is automatically built in CI before building Katana. This ensures that the explorer UI is always available when building official releases.
14+
15+
### Building Locally
16+
17+
If you need to build the explorer UI locally:
18+
19+
1. Initialize the submodule:
20+
21+
```bash
22+
git submodule update --init --recursive
23+
```
24+
25+
2. Build the UI:
26+
27+
```bash
28+
cd ui
29+
bun install
30+
bun run build
31+
```
32+
33+
The build output will be placed in `ui/dist`. This directory must exist and contain the built files for the explorer to work.
34+
35+
## Runtime Behavior
36+
37+
The explorer will fail to start if the UI build files are not found. This is intentional to prevent running with missing or outdated UI files.
38+
39+
## Development
40+
41+
For local development of the UI:
42+
43+
1. Initialize the submodule as described above
44+
2. Navigate to the UI directory: `cd ui`
45+
3. Start the development server: `bun run dev`
46+
47+
Note: The `ui/dist` directory is gitignored to prevent committing built files.
848

949
## Utilities
1050

crates/katana/explorer/build.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

crates/katana/explorer/dist/assets/index-CGNy37mg.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)