Skip to content

Commit

Permalink
Merge pull request #4 from ursm/cargo-component
Browse files Browse the repository at this point in the history
Use cargo-component to build WASM binary
  • Loading branch information
ursm authored Aug 26, 2024
2 parents b8b4f97 + cd49af8 commit b7dcdca
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 10 deletions.
2 changes: 0 additions & 2 deletions .cargo/config.toml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:

env:
CARGO_TERM_COLOR: always

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: cargo test

clippy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: cargo clippy

fmt:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: cargo fmt --check
9 changes: 6 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ on:
release:
types: [published]

env:
CARGO_TERM_COLOR: always

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- run: rustup target add wasm32-wasi
- run: cargo build --release
- run: cargo install cargo-component
- run: cargo component build --release

- uses: softprops/action-gh-release@v2
with:
files: target/wasm32-wasi/release/zellij-foreman.wasm
files: target/wasm32-wasip1/release/zellij-foreman.wasm
fail_on_unmatched_files: true
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ zellij-tile = "0.40.1"

[profile.release]
codegen-units = 1
opt-level = "s"
debug = false
strip = true
lto = true
strip = "symbols"
25 changes: 21 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,26 @@ impl ZellijPlugin for ZellijForeman {
fn parse_procfile(procfile: &str) -> Vec<(&str, &str)> {
let re = Regex::new(r"(?m)^([\w-]+):\s*(.+)$").unwrap();

re.captures_iter(procfile).map(|c| {
let (_, [name, command]) = c.extract();
re.captures_iter(procfile)
.map(|c| {
let (_, [name, command]) = c.extract();

(name, command)
}).collect()
(name, command)
})
.collect()
}

#[test]
fn test_parse_procfile() {
let procfile = r#"
web: npm start
api: npm run api
# comment one
comment two
"#;

let entries = parse_procfile(procfile);

assert_eq!(entries, vec![("web", "npm start"), ("api", "npm run api"),]);
}

0 comments on commit b7dcdca

Please sign in to comment.