Skip to content

Commit

Permalink
Deploy website with netlify (#70)
Browse files Browse the repository at this point in the history
* move everything into a single job to use github caching
  • Loading branch information
anp authored Nov 18, 2019
1 parent 1d7b163 commit fce2560
Show file tree
Hide file tree
Showing 14 changed files with 484 additions and 508 deletions.
6 changes: 3 additions & 3 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
core-flow = """
watch --clear
-x fmt
-x check-core
-x clippy-core
-x check-core
-x test-core
-x docs-all
"""
Expand All @@ -26,14 +26,14 @@ docs-all = "doc --all --no-deps"

dom-flow = """
watch --clear
-x clippy-dom
-x test-ssr-example
-x test-dom-lib
-x test-dom-drivertest
-x check-dom-hacking
-x check-dom-todo
-x build-dom-hacking
-x build-dom-todo
-x clippy-dom
"""

check-dom-lib = "check --package moxie-dom"
Expand Down Expand Up @@ -74,10 +74,10 @@ server = "watch -w ofl/ -x ofl"
ofl-flow = """
watch --clear -w ofl
-x fmt-ofl
-x clippy-ofl
-x check-ofl
-x test-ofl
-x docs-ofl
-x clippy-ofl
"""

check-ofl = "check --manifest-path ofl/Cargo.toml --all"
Expand Down
163 changes: 54 additions & 109 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,67 @@
on: push

jobs:
core:
main:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@master
- run: cargo test-core

dom:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@master
# TODO(https://github.com/anp/moxie/issues/37)
# - run: cargo test-dom-drivertest
# WALL'O'CACHE!
- name: cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
# - name: cache ofl target dir
# uses: actions/cache@v1
# with:
# path: ofl/target
# key: ${{ runner.os }}-ofl-target-dir-${{ hashFiles('ofl/Cargo.lock') }}
# - name: cache moxie target dir
# uses: actions/cache@v1
# with:
# path: target
# key: ${{ runner.os }}-target-dir-${{ hashFiles('*/Cargo.lock') }}

# tests
- run: cargo test-core
- run: cargo test-dom-lib
- run: cargo test-ssr-example
# TODO(https://github.com/anp/moxie/issues/37)
# run: cargo test-dom-drivertest

- name: build dom examples
if: runner.os == 'Linux'
run: |
cargo build-dom-hacking
cargo build-dom-todo
# examples
- run: cargo build-dom-hacking
- run: cargo build-dom-todo

- name: upload dom examples
# docs
- run: cargo docs-all
- run: cargo docs-ofl

- run: cargo build-website

- name: deploy preview
if: runner.os == 'Linux'
uses: actions/upload-artifact@master
with:
name: dom-examples
path: dom/examples
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
run: npx netlify-cli deploy

fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- run: rustup component add rustfmt
- run: cargo fmt -- --check
# FIXME https://github.com/anp/moxie/issues/27
# - run: cargo fmt-ofl -- --check
- name: promote website to prod, ensure crates published
if: github.ref == 'refs/heads/master' && runner.os == 'Linux'
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
run: |
npx netlify-cli deploy --prod
cargo login ${{ secrets.CARGO_API_TOKEN }}
cargo ofl published
clippy:
runs-on: ubuntu-latest
Expand All @@ -52,85 +70,12 @@ jobs:
- run: rustup component add clippy
- run: cargo clippy-core
- run: cargo clippy-dom
- run: cargo clippy-ofl

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- run: cargo docs-all
- run: cargo docs-ofl
- uses: actions/upload-artifact@master
with:
name: docs
path: target/doc

published:
needs: [core, dom, fmt, clippy, docs]
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: download dom examples
uses: actions/download-artifact@master
with:
name: dom-examples
path: dom/examples

- name: download docs
uses: actions/download-artifact@master
with:
name: docs
path: target/doc

- name: build website
run: |
cargo ofl website build target/website
echo 'moxie.rs' > target/website/CNAME
- name: upload website archive
uses: actions/upload-artifact@master
with:
name: website
path: target/website

- name: ensure crates published
if: github.ref == 'refs/heads/master'
run: |
cargo login ${{ secrets.CARGO_API_TOKEN }}
cargo ofl published
- name: checkout gh-pages branch
uses: actions/checkout@master
with:
ref: gh-pages

- name: prepare repo for unpacking website
env:
GLOBIGNORE: .git
run: |
git rm -rf *
git clean -fxd
git config --global user.name "docs builder"
git config --global user.email "[email protected]"
- name: download website
uses: actions/download-artifact@master
with:
name: website

- name: commit website updates
env:
GLOBIGNORE: .git
run: |
mv website/* ./
git add --force --all
git commit --allow-empty --message $GITHUB_SHA .
- name: push website
if: github.ref == 'refs/heads/master'
run: |
git remote rm origin
git remote add origin https://anp:[email protected]/anp/moxie.git
git push origin gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_PAT }}
- run: rustup component add rustfmt
- run: cargo fmt -- --check
- run: cargo fmt-ofl --check
3 changes: 3 additions & 0 deletions .netlify/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"telemetryDisabled": true
}
3 changes: 3 additions & 0 deletions .netlify/state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"siteId": "3ad3f9c1-495b-4558-987c-ab0363f47651"
}
8 changes: 4 additions & 4 deletions dom/augdom/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! As of today the `<web_sys::Element as Dom>::*_attribute` methods will panic if called on a text
//! node. This cost seems appropriate today because this is a dependency for other crates which
//! enforce this requirement themselves. `web_sys` enforces this restriction statically.
#![deny(missing_docs)]
#![deny(clippy::all, missing_docs)]

static_assertions::assert_cfg!(
any(feature = "webdom", feature = "rsdom"),
Expand Down Expand Up @@ -73,7 +73,7 @@ pub trait Dom: Sized {
fn pretty_outer_html(&self, indent: usize) -> String {
let mut buf: Cursor<Vec<u8>> = Cursor::new(Vec::new());
{
let mut writer = XmlWriter::new_with_indent(&mut buf, ' ' as u8, indent);
let mut writer = XmlWriter::new_with_indent(&mut buf, b' ', indent);
self.write_xml(&mut writer);
}
String::from_utf8(buf.into_inner()).unwrap()
Expand Down Expand Up @@ -170,10 +170,10 @@ impl Dom for Node {
fn create_element(&self, ty: &str) -> Self {
match self {
#[cfg(feature = "webdom")]
Node::Concrete(n) => Node::Concrete(n.create_element(ty).into()),
Node::Concrete(n) => Node::Concrete(n.create_element(ty)),

#[cfg(feature = "rsdom")]
Node::Virtual(n) => Node::Virtual(n.create_element(ty).into()),
Node::Virtual(n) => Node::Virtual(n.create_element(ty)),
}
}

Expand Down
3 changes: 1 addition & 2 deletions dom/examples/drivertest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ fn mini_list() {

assert_vnode_matches_element(&expected, &web_div);

let expected_html =
r#"<div><ul class="listywisty"><li>first</li><li class="item">second</li><li>third</li></ul></div>"#;
let expected_html = r#"<div><ul class="listywisty"><li>first</li><li class="item">second</li><li>third</li></ul></div>"#;

assert_eq!(
sys::Element::outer_html(&web_div),
Expand Down
4 changes: 2 additions & 2 deletions dom/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Tools for declaratively constructing and incrementally updating HTML DOM trees on the web. Based
//! on the [`moxie`] UI runtime.
#![deny(missing_docs, intra_doc_link_resolution_failure)]
#![deny(clippy::all, missing_docs, intra_doc_link_resolution_failure)]

#[doc(hidden)]
pub use moxie::*;
Expand Down Expand Up @@ -91,7 +91,7 @@ pub fn element<ChildRet>(
) -> ChildRet {
let elem = memo!(ty, |ty| parent.node.create_element(ty));
parent.ensure_child_attached(&elem);
let elem = MemoElement::new(elem.into());
let elem = MemoElement::new(elem);
with_elem(&elem)
}

Expand Down
4 changes: 4 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[build]
publish = "target/website"

## more info on configuring this file: https://www.netlify.com/docs/netlify-toml-reference/
19 changes: 10 additions & 9 deletions ofl/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ofl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ crossbeam = "0.7"
failure = "0.1"
futures01 = { version = "0.1", package = "futures" }
gumdrop = "0.6"
http = "0.1.19"
mdbook = "0.3.1"
notify = "5.0.0-pre.1"
opener = "0.4"
Expand Down
Loading

0 comments on commit fce2560

Please sign in to comment.