diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml new file mode 100644 index 0000000..465e8eb --- /dev/null +++ b/.github/workflows/build-and-release.yml @@ -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* diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..bd0f0f5 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1,6 @@ +[toolchain] +channel = "nightly" +targets = [ + "x86_64-unknown-linux-gnu", + "x86_64-pc-windows-gnu", +] \ No newline at end of file diff --git a/tests/parsing_tests.rs b/tests/parsing_tests.rs deleted file mode 100644 index 65abcc9..0000000 --- a/tests/parsing_tests.rs +++ /dev/null @@ -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::>() - .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 - ) -}