Skip to content

Commit 0d2ba41

Browse files
authored
ci: improving testing workflow (#46)
* test: add ci workflow for testing the bundler * ci: enhance testing workflow * ci: add `typos` action * fix: rustfmt * fix: typos
1 parent 349bc0e commit 0d2ba41

File tree

21 files changed

+549
-113
lines changed

21 files changed

+549
-113
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Bundler Tests
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
bundler-tests:
16+
name: Bundler Integration Tests
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Build Docker image
24+
run: docker build -f Dockerfile.dev -t metassr-test .
25+
26+
- name: Run bundler tests in Docker
27+
run: |
28+
docker run --rm -v $(pwd)/tests/web-app/dist:/root/tests/web-app/dist metassr-test bash -c "
29+
# Run the build
30+
cd /root/tests/web-app
31+
npm run build
32+
33+
# Copy the test script into the container and run it
34+
cp /root/tests/test-bundle.sh ./
35+
chmod +x test-bundle.sh
36+
./test-bundle.sh
37+
"
38+
39+
- name: Upload dist artifacts
40+
if: always()
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: bundler-dist-output
44+
path: tests/web-app/dist/
45+
retention-days: 7

.github/workflows/clippy.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Rust Clippy
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
clippy:
16+
name: Run Clippy
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Install Rust
24+
uses: dtolnay/rust-toolchain@stable
25+
with:
26+
components: clippy
27+
28+
- name: Cache Rust dependencies
29+
uses: actions/cache@v4
30+
with:
31+
path: |
32+
~/.cargo/bin/
33+
~/.cargo/registry/index/
34+
~/.cargo/registry/cache/
35+
~/.cargo/git/db/
36+
target/
37+
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
38+
39+
- name: Run clippy
40+
run: cargo clippy --all-targets --all-features -- -D warnings

.github/workflows/fmt.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Rust Formatting
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
fmt:
16+
name: Check Formatting
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Install Rust
24+
uses: dtolnay/rust-toolchain@stable
25+
with:
26+
components: rustfmt
27+
28+
- name: Check formatting
29+
run: cargo fmt --check

.github/workflows/test.yml

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

.github/workflows/typos.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Spell Checker action
2+
on: [pull_request, push]
3+
4+
jobs:
5+
run:
6+
name: Start Spell Checking with Typos
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout Actions Repository
10+
uses: actions/checkout@v2
11+
12+
- name: Check spelling of * Files
13+
uses: crate-ci/typos@master
14+
with:
15+
files: ./*

.github/workflows/unit-tests.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Rust Tests
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
test:
16+
name: Run Rust Tests
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Build Docker image
24+
run: docker build -f Dockerfile.dev -t metassr-test .
25+
26+
- name: Run Rust tests in Docker
27+
run: |
28+
docker run --rm metassr-test bash -c "
29+
cd /root
30+
cargo test --verbose
31+
"

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## TODO
22

33
#### Main features
4-
- [x] Serving staic files are located in ``./static/**``
4+
- [x] Serving static files are located in ``./static/**``
55

66
- [x] the HTML builder
77

crates/metassr-build/src/server/manifest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl ManifestGenerator {
119119
}
120120
}
121121
pub fn generate<H: AsRef<OsStr> + ?Sized>(&self, head: &H) -> Result<Manifest> {
122-
let cache_path = self.cache.path();
122+
let cache_path = self.cache.path();
123123
let global = GlobalEntry::new(head, cache_path)?;
124124
let mut manifest = Manifest::new(global);
125125

crates/metassr-build/src/server/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ impl Build for ServerSideBuilder {
7979
};
8080

8181
let bundling_targets = targets.ready_for_bundling(&self.dist_path);
82-
let bundler = WebBundler::new(
83-
&bundling_targets,
84-
&self.dist_path,
85-
)?;
82+
let bundler = WebBundler::new(&bundling_targets, &self.dist_path)?;
8683

8784
if let Err(e) = bundler.exec() {
8885
return Err(anyhow!("Bundling failed: {e}"));

crates/metassr-build/src/server/renderer/head.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ impl HeadRenderer {
5151
let bundling_targets = self.bundling_target()?;
5252
let bundler = WebBundler::new(&bundling_targets, self.cache_dir.path())?;
5353

54-
if let Err(e) = bundler.exec()
55-
{
54+
if let Err(e) = bundler.exec() {
5655
return Err(anyhow!("Cannot bundling head: {e}"));
5756
}
5857
Ok(())

0 commit comments

Comments
 (0)