Merge pull request #2 from Trivernis/actions

Actions
pull/4/head v0.30.1
Trivernis 4 years ago committed by GitHub
commit 169e062d29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,52 @@
name: "Build and Release"
on:
push:
tags:
- "v*"
workflow_dispatch:
jobs:
build-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Set up MinGW
uses: egor-tensin/setup-mingw@v1
with:
platform: x64
- 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
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