Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build website in Github Actions #84

Merged
merged 10 commits into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/build_website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build Website

on: [push, pull_request]

jobs:
deploy:
name: Deploy Draft
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown

- name: Install trunk
run: >
wget -qO- https://github.com/thedodd/trunk/releases/download/v0.10.0/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf- &&
sudo mv trunk /usr/bin/

- name: Install wasm-bindgen
run: >
wget https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.73/wasm-bindgen-0.2.73-x86_64-unknown-linux-musl.tar.gz &&
tar -xf wasm-bindgen-0.2.73-x86_64-unknown-linux-musl.tar.gz &&
sudo mv wasm-bindgen-0.2.73-x86_64-unknown-linux-musl/wasm-bindgen /usr/bin/

- name: Cargo cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('Cargo.lock') }}

- name: Build docs
run: >
cd docs/ &&
trunk build --release

- name: Build examples
run: |
output="$(pwd)/docs/dist"
mkdir "$output/example"
for path in examples/*; do
if [[ ! -d $path ]]; then
continue
fi
example=$(basename "$path")
echo "building: $example"
(
cd "$path"
dist_dir="$output/example/$example"
mkdir "$dist_dir"
trunk build --release --dist "$dist_dir" --public-url "/example/$example"
)
done

- name: Create .nojekyll file
run: touch docs/dist/.nojekyll

- name: Deploy to netlify
uses: netlify/actions/cli@master
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.DEV_NETLIFY_SITE_ID }}
with:
args: deploy
64 changes: 64 additions & 0 deletions .github/workflows/build_website_prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build Website Production

on:
push:
branches: [master]

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown

- name: Install trunk
run: >
wget -qO- https://github.com/thedodd/trunk/releases/download/v0.10.0/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf- &&
sudo mv trunk /usr/bin/

- name: Install wasm-bindgen
run: >
wget https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.73/wasm-bindgen-0.2.73-x86_64-unknown-linux-musl.tar.gz &&
tar -xf wasm-bindgen-0.2.73-x86_64-unknown-linux-musl.tar.gz &&
sudo mv wasm-bindgen-0.2.73-x86_64-unknown-linux-musl/wasm-bindgen /usr/bin/

- name: Build docs
run: >
cd docs/ &&
trunk build --release

- name: Build examples
run: |
output="$(pwd)/docs/dist"
mkdir "$output/example"
for path in examples/*; do
if [[ ! -d $path ]]; then
continue
fi
example=$(basename "$path")
echo "building: $example"
(
cd "$path"
dist_dir="$output/example/$example"
mkdir "$dist_dir"
trunk build --release --dist "$dist_dir"
)
done

- name: Create .nojekyll file
run: touch docs/dist/.nojekyll

- name: Deploy to netlify
uses: netlify/actions/cli@master
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.DEV_NETLIFY_SITE_ID }}
with:
args: deploy --prod
31 changes: 27 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ jobs:
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Build
run: cargo build
if: always()
- name: Cargo cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-test-${{ hashFiles('Cargo.lock') }}

- name: Run tests
run: cargo test
Expand All @@ -29,6 +34,24 @@ jobs:
run: wasm-pack test maple-core --firefox --chrome --headless
if: always()

clippy:
name: Clippy
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Cargo cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('Cargo.lock') }}

- name: Run clippy
run: cargo clippy
if: always()
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ Cargo.lock

# Trunk output
/**/dist

# Local Netlify folder
.netlify
3 changes: 1 addition & 2 deletions docs/markdown/contribute/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ Proc-macro related code is in `/maple-core-macro`.
- #### Reactivity

- All the reactivity primitives are defined in `/maple-core/src/reactive.rs`.
- `create_effect` is called by the internal DOM utilities in `/maple-core/src/internal.rs`.

- #### `template!`

- The template macro is defined in `/maple-core-macro/src/lib.rs`.
- Different DOM nodes are defined in separate files under the same directory.
- Different DOM node types are defined in separate files under the same directory.
- [`trybuild`](https://github.com/dtolnay/trybuild) is used for testing proc-macros.

- #### Components
Expand Down
12 changes: 10 additions & 2 deletions docs/markdown/contribute/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,24 @@ cd maple

## Testing

To run unit tests, use:
To run unit tests and non WASM integration tests, use:

```bash
cargo test
```

To run integration tests, you will need to have [wasm-pack](https://rustwasm.github.io/wasm-pack/) installed:
To run integration tests in the browser, you will need to have [wasm-pack](https://rustwasm.github.io/wasm-pack/) installed:

```bash
wasm-pack test maple-core --firefox # or --chrome
```

If you want to run the tests in a headless browser, pass the `--headless` flag as well.

#### PR Requirements

Before your PR can be merged, we ask that your code is properly formatted using `cargo fmt` and passes `cargo clippy`.

If your code introduces new functionality, we also ask you to write some unit tests and eventually some integration tests.

Thank you for taking the time to contribute to Maple!
18 changes: 18 additions & 0 deletions examples/ssr/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>SSR</title>

<style>
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
</style>
</head>
<body>
This example does not run in WASM. You must run it locally with "cargo run
--example ssr".
</body>
</html>
35 changes: 0 additions & 35 deletions scripts/netlify-build

This file was deleted.