Skip to content

Commit 7510445

Browse files
Refactor: Organize pipelines.
1 parent 6b529ed commit 7510445

5 files changed

Lines changed: 102 additions & 91 deletions

File tree

.github/workflows/check.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: _Check
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
lint:
8+
name: Clippy & Shear
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Cache Rust
15+
uses: Swatinem/rust-cache@v2
16+
with:
17+
workspaces: compiler
18+
19+
- uses: dtolnay/rust-toolchain@stable
20+
with:
21+
components: clippy
22+
23+
- name: Install cargo-shear
24+
run: cargo install cargo-shear
25+
working-directory: compiler
26+
27+
# Detects declared but unused dependencies.
28+
- name: Shear (unused deps)
29+
run: cargo shear
30+
working-directory: compiler
31+
32+
# Lint for native targets (windows, linux, macos).
33+
- name: Clippy (native)
34+
run: cargo clippy --all-targets -- -D warnings
35+
working-directory: compiler
36+
37+
# Lint for wasm target.
38+
- name: Install wasm target
39+
run: rustup target add wasm32-unknown-unknown
40+
working-directory: compiler
41+
42+
- name: Clippy (wasm)
43+
run: cargo clippy --lib --target wasm32-unknown-unknown --features wasm -- -D warnings
44+
working-directory: compiler

.github/workflows/demo.yml

Lines changed: 17 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
name: Demo Sandbox
1+
name: _Demo Deploy
22

33
on:
44
workflow_call:
55

6+
# Los permisos efectivos los otorga pipeline.yml en el job "demo".
7+
# Se declaran aquí también para documentar qué necesita este workflow.
68
permissions:
79
contents: read
810
pages: write
@@ -14,82 +16,39 @@ concurrency:
1416

1517
jobs:
1618
deploy:
19+
name: GitHub Pages
1720
environment:
1821
name: github-pages
1922
url: ${{ steps.deployment.outputs.page_url }}
2023
runs-on: ubuntu-latest
24+
2125
steps:
22-
- uses: actions/checkout@v5
26+
- uses: actions/checkout@v4
2327

24-
- name: Cache Rust
25-
uses: Swatinem/rust-cache@v2
28+
# Download the .wasm already compiled and optimized by _wasm.yml.
29+
- name: Download wasm artifact
30+
uses: actions/download-artifact@v4
2631
with:
27-
workspaces: compiler
28-
29-
- uses: dtolnay/rust-toolchain@stable
30-
31-
- name: Install wasm target
32-
run: rustup target add wasm32-unknown-unknown
33-
working-directory: compiler
34-
35-
- name: Install wasm-opt
36-
run: |
37-
curl -sSL https://github.com/WebAssembly/binaryen/releases/download/version_121/binaryen-version_121-x86_64-linux.tar.gz \
38-
| tar -xz --strip-components=2 -C /usr/local/bin binaryen-version_121/bin/wasm-opt
39-
wasm-opt --version
40-
41-
- name: Build wasm
42-
run: cargo build --target wasm32-unknown-unknown --features wasm --lib --release
43-
working-directory: compiler
44-
45-
- name: Size (unoptimized)
46-
run: ls -lh target/wasm32-unknown-unknown/release/compiler_lib.wasm
47-
working-directory: compiler
48-
49-
- name: Optimize wasm
50-
run: |
51-
INPUT=compiler/target/wasm32-unknown-unknown/release/compiler_lib.wasm
52-
53-
wasm-opt -Oz --converge \
54-
--generate-global-effects \
55-
--strip-debug --strip-producers \
56-
--enable-bulk-memory-opt \
57-
--enable-nontrapping-float-to-int \
58-
--enable-sign-ext \
59-
-tnh \
60-
-o /tmp/wasm_stage1.wasm "$INPUT"
61-
62-
wasm-opt --flatten --rereloop -Oz -Oz \
63-
--enable-bulk-memory-opt \
64-
--enable-nontrapping-float-to-int \
65-
--enable-sign-ext \
66-
-o "$INPUT" /tmp/wasm_stage1.wasm
67-
68-
rm /tmp/wasm_stage1.wasm
32+
name: compiler_lib_wasm
33+
path: demo/
6934

7035
- name: Write version manifest
7136
run: |
72-
HASH=$(sha256sum compiler/target/wasm32-unknown-unknown/release/compiler_lib.wasm \
73-
| cut -c1-12)
37+
HASH=$(sha256sum demo/compiler_lib.wasm | cut -c1-12)
7438
printf '{"v":"%s"}\n' "$HASH" > demo/version.json
7539
76-
- name: Size (optimized)
77-
run: ls -lh target/wasm32-unknown-unknown/release/compiler_lib.wasm
78-
working-directory: compiler
79-
80-
- name: Stage wasm
81-
run: cp compiler/target/wasm32-unknown-unknown/release/compiler_lib.wasm demo/
82-
8340
- name: Build Tailwind CSS
8441
working-directory: demo
85-
run: echo "@tailwind base;@tailwind components;@tailwind utilities;" | npx tailwindcss@3 --input - --output tailwind.css --minify
42+
run: |
43+
echo "@tailwind base;@tailwind components;@tailwind utilities;" \
44+
| npx tailwindcss@3 --input - --output tailwind.css --minify
8645
8746
- name: Setup Pages
88-
uses: actions/configure-pages@v5
47+
uses: actions/configure-pages@v4
8948
with:
9049
enablement: true
9150

92-
- name: Upload artifact
51+
- name: Upload Pages artifact
9352
uses: actions/upload-pages-artifact@v3
9453
with:
9554
path: demo

.github/workflows/native.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Native Builds
1+
name: _Native Builds
22

33
on:
44
workflow_call:
@@ -33,16 +33,14 @@ jobs:
3333
contents: write
3434

3535
steps:
36-
- uses: actions/checkout@v5
36+
- uses: actions/checkout@v4
3737

3838
- name: Cache Rust
3939
uses: Swatinem/rust-cache@v2
4040
with:
4141
workspaces: compiler
4242

4343
- uses: dtolnay/rust-toolchain@stable
44-
with:
45-
components: rust-src, clippy
4644

4745
- name: Install target
4846
run: rustup target add ${{ matrix.target }}
@@ -53,23 +51,19 @@ jobs:
5351
working-directory: compiler
5452

5553
- name: Size
56-
run: ls -lh target/${{ matrix.target }}/release/${{ matrix.binary }}
5754
shell: bash
55+
run: ls -lh target/${{ matrix.target }}/release/${{ matrix.binary }}
5856
working-directory: compiler
5957

6058
- name: Test
6159
run: cargo test
6260
working-directory: compiler
6361

64-
- name: Install CLI Tools
65-
run: cargo install cargo-shear cargo-bloat
66-
working-directory: compiler
67-
68-
- name: Unused Code
69-
run: cargo shear && cargo clippy --target ${{ matrix.target }}
62+
- name: Install cargo-bloat
63+
run: cargo install cargo-bloat
7064
working-directory: compiler
7165

72-
- name: Bloat
66+
- name: Bloat report
7367
run: cargo bloat --release --target ${{ matrix.target }} --crates -n 7
7468
working-directory: compiler
7569

.github/workflows/pipeline.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,43 @@
1-
name: Deployment Pipeline
1+
name: CI / CD
22

33
on:
44
push:
5-
branches: [ main ]
6-
tags: [ "v*" ]
5+
branches: [main]
6+
tags: ["v*"]
77
pull_request:
8-
branches: [ main ]
8+
branches: [main]
99

1010
jobs:
11+
# Lint and check the codebase, including running clippy and checking for unused code.
12+
check:
13+
name: Lint & Check
14+
uses: ./.github/workflows/_check.yml
15+
secrets: inherit
16+
17+
# Build releases for native architectures (windows, linux, macos) and webassembly.
1118
native:
1219
name: Native Builds
20+
needs: check
1321
permissions:
1422
contents: write
15-
uses: ./.github/workflows/native.yml
23+
uses: ./.github/workflows/_native.yml
1624
secrets: inherit
1725

1826
wasm:
1927
name: WebAssembly
28+
needs: check
2029
permissions:
2130
contents: write
22-
uses: ./.github/workflows/wasm.yml
31+
uses: ./.github/workflows/_wasm.yml
2332
secrets: inherit
2433

34+
# Build the demo after the wasm build, since it depends on the wasm artifacts.
2535
demo:
26-
name: Deploy Demo (GitHub Pages)
27-
uses: ./.github/workflows/demo.yml
36+
name: Build Demo
37+
needs: wasm
38+
permissions:
39+
contents: read
40+
pages: write
41+
id-token: write
42+
uses: ./.github/workflows/_demo.yml
2843
secrets: inherit

.github/workflows/wasm.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: WebAssembly Build
1+
name: _WebAssembly Build
22

33
on:
44
workflow_call:
@@ -11,42 +11,35 @@ jobs:
1111
contents: write
1212

1313
steps:
14-
- uses: actions/checkout@v5
14+
- uses: actions/checkout@v4
1515

1616
- name: Cache Rust
1717
uses: Swatinem/rust-cache@v2
1818
with:
1919
workspaces: compiler
2020

2121
- uses: dtolnay/rust-toolchain@stable
22-
with:
23-
components: clippy
2422

25-
- name: Install target
23+
- name: Install wasm target
2624
run: rustup target add wasm32-unknown-unknown
2725
working-directory: compiler
2826

29-
- name: Install CLI Tools
27+
- name: Install wasm-opt
3028
run: |
31-
cargo install cargo-shear
3229
curl -sSL https://github.com/WebAssembly/binaryen/releases/download/version_121/binaryen-version_121-x86_64-linux.tar.gz \
3330
| tar -xz --strip-components=2 -C /usr/local/bin binaryen-version_121/bin/wasm-opt
3431
wasm-opt --version
35-
working-directory: compiler
3632
3733
- name: Build
3834
run: cargo build --target wasm32-unknown-unknown --features wasm --lib --release
3935
working-directory: compiler
4036

41-
- name: Unused Code
42-
run: cargo shear && cargo clippy --lib --target wasm32-unknown-unknown --features wasm
43-
working-directory: compiler
44-
4537
- name: Size (unoptimized)
4638
run: ls -lh target/wasm32-unknown-unknown/release/compiler_lib.wasm
4739
working-directory: compiler
4840

4941
- name: Optimize
42+
working-directory: compiler
5043
run: |
5144
INPUT=target/wasm32-unknown-unknown/release/compiler_lib.wasm
5245
@@ -66,7 +59,6 @@ jobs:
6659
-o "$INPUT" /tmp/wasm_stage1.wasm
6760
6861
rm /tmp/wasm_stage1.wasm
69-
working-directory: compiler
7062
7163
- name: Size (optimized)
7264
run: ls -lh target/wasm32-unknown-unknown/release/compiler_lib.wasm
@@ -76,6 +68,13 @@ jobs:
7668
run: cargo test --features wasm-tests
7769
working-directory: compiler
7870

71+
- name: Upload wasm artifact
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: compiler_lib_wasm
75+
path: compiler/target/wasm32-unknown-unknown/release/compiler_lib.wasm
76+
retention-days: 1
77+
7978
- name: Upload WASM Release
8079
uses: softprops/action-gh-release@v2
8180
if: startsWith(github.ref, 'refs/tags/')

0 commit comments

Comments
 (0)