Add build-and-release task and rust-toolchain file

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/2/head
trivernis 4 years ago
parent 9d1f6d0ac9
commit 14862990f2
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -0,0 +1,47 @@
name: "Build and Release"
on:
push:
tags:
- "v*"
workflow_dispatch:
jobs:
build-release:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Cache cargo builds
uses: actions/cache@v2
with:
path: |
target
~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build Release
uses: actions-rs/cargo@v1
with:
use-cross: false
command: build
args: --release --all-features -Zmultitarget --target x86_64-unknown-linux-gnu --target x86_64-pc-windows-gnu
- name: Move binaries
run: mv target/x86_64-unknown-linux-gnu/release/snekdown target/snekdown-linux-x86_64 && mv target/x86_64-pc-windows-gnu/release/snekdown.exe target/snekdown-windows-x86_64.exe
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: snekdown
path: target/snekdown*
- name: publish release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
LICENSE.txt
target/snekdown*

@ -0,0 +1,6 @@
[toolchain]
channel = "nightly"
targets = [
"x86_64-unknown-linux-gnu",
"x86_64-pc-windows-gnu",
]

@ -1,92 +0,0 @@
use snekdown::parse;
use snekdown::parser::elements::Block;
use snekdown::Parser;
macro_rules! count_block_elements {
($document:expr, $filter:expr) => {
$document
.elements
.iter()
.filter($filter)
.collect::<Vec<&Block>>()
.len()
};
}
#[test]
fn it_parses_sections() {
let document = parse!("# Section\n## Subsection\n# Section");
assert_eq!(
count_block_elements!(document, |e| if let Block::Section(_) = e {
true
} else {
false
}),
2
)
}
#[test]
fn it_parses_tables() {
let document = parse!("|header|header|\n|---|---|\n|col|col|");
assert_eq!(
count_block_elements!(document, |e| if let Block::Table(_) = e {
true
} else {
false
}),
1
)
}
#[test]
fn it_parses_paragraphs() {
let document = parse!("**Bold***Italic*_Underline_`Monospace`^super^~strike~");
assert_eq!(
count_block_elements!(document, |e| if let Block::Paragraph(_) = e {
true
} else {
false
}),
1
)
}
#[test]
fn it_parses_lists() {
let document = parse!("- item1\n- item2\n\n* item\n+ item\n\no item\n1. item");
assert_eq!(
count_block_elements!(document, |e| if let Block::List(l) = e {
l.items.len() == 2
} else {
false
}),
3
)
}
#[test]
fn it_parses_code_blocks() {
let document = parse!("```\ncode\n```\n```rust\ncode\n``````");
assert_eq!(
count_block_elements!(document, |e| if let Block::CodeBlock(_) = e {
true
} else {
false
}),
2
)
}
#[test]
fn it_parses_quotes() {
let document = parse!("> quote\n\n[meta]> quote\n>hm");
assert_eq!(
count_block_elements!(document, |e| if let Block::Quote(_) = e {
true
} else {
false
}),
2
)
}
Loading…
Cancel
Save