Skip to content

Commit

Permalink
v0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienrousseau committed Oct 7, 2024
1 parent 3b87c76 commit dbe4be7
Show file tree
Hide file tree
Showing 14 changed files with 1,137 additions and 17 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/document.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: hecrj/setup-rust-action@v2.0.1
- uses: hecrj/setup-rust-action@v2
with:
rust-version: nightly

- uses: actions/checkout@v4.1.7
- uses: actions/checkout@v4

- name: Update libssl
run: |
Expand All @@ -38,7 +38,7 @@ jobs:
echo '<html><head><meta http-equiv="refresh" content="0; url=/html_generator/"></head><body></body></html>' > ./target/doc/index.html
- name: Deploy
uses: actions/upload-artifact@v4.4.0
uses: actions/upload-artifact@v4
with:
name: documentation
path: target/doc
Expand All @@ -49,7 +49,7 @@ jobs:
run: echo 'doc.html-generator.co' > ./target/doc/CNAME

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4.0.0
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./target/doc
Expand Down
127 changes: 127 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: 🧪 Release

on:
push:
branches: [main, feat/html-gen]
pull_request:
branches: [feat/html-gen]
release:
types: [created]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_API_TOKEN }}

jobs:
build:
name: Build 🛠
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: windows-latest
target: aarch64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --verbose --release --target ${{ matrix.target }}
- name: Package
run: |
if [ ! -d "target/package" ]; then
mkdir -p target/package
fi
cd target/${{ matrix.target }}/release
tar czf ../../package/${{ matrix.target }}.tar.gz *
shell: bash

- name: Package (Windows)
if: matrix.os == 'windows-latest'
run: |
if (!(Test-Path "target/package")) {
mkdir target/package
}
cd target/${{ matrix.target }}/release
tar -czf ../../package/${{ matrix.target }}.tar.gz *
shell: pwsh

- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: target/package/${{ matrix.target }}.tar.gz

release:
name: Release 🚀
needs: build
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set version
run: echo "VERSION=$(grep -m 1 '^version =' Cargo.toml | cut -d '"' -f 2)" >> $GITHUB_ENV
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Generate Changelog
run: |
echo "## Release v${VERSION} - $(date +'%Y-%m-%d')" > CHANGELOG.md
cat TEMPLATE.md >> CHANGELOG.md
git log --pretty=format:'%s' --reverse HEAD >> CHANGELOG.md
echo "" >> CHANGELOG.md
- uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.VERSION }}
release_name: HTML Generator 🦀 v${{ env.VERSION }}
body_path: CHANGELOG.md
draft: true
prerelease: false
- name: Upload Release Assets
run: |
for asset in artifacts/*/*; do
gh release upload v${{ env.VERSION }} "$asset" --clobber
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

crate:
name: Publish to Crates.io 🦀
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Publish
run: cargo publish --token ${CARGO_REGISTRY_TOKEN}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_API_TOKEN }}
40 changes: 37 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,44 @@ criterion = "0.5"
# Examples
# -----------------------------------------------------------------------------

# [[example]]
# name = "error_example"
# path = "examples/error_example.rs"
[[example]]
name = "accessibility_example"
path = "examples/accessibility_example.rs"

[[example]]
name = "error_example"
path = "examples/error_example.rs"

[[example]]
name = "generator_example"
path = "examples/generator_example.rs"

[[example]]
name = "lib_example"
path = "examples/lib_example.rs"

[[example]]
name = "performance_example"
path = "examples/performance_example.rs"

[[example]]
name = "seo_example"
path = "examples/seo_example.rs"

[[example]]
name = "utils_example"
path = "examples/utils_example.rs"

# -----------------------------------------------------------------------------
# Criterion Benchmark
# -----------------------------------------------------------------------------

[[bench]]
name = "html_benchmark"
harness = false

[profile.bench]
debug = true

# -----------------------------------------------------------------------------
# Features
Expand Down
64 changes: 64 additions & 0 deletions benches/html_benchmark.rs
Original file line number Diff line number Diff line change
@@ -1 +1,65 @@
// benches/html_benchmark.rs
#![allow(missing_docs)]

use criterion::{
black_box, criterion_group, criterion_main, Criterion,
};
use html_generator::{
accessibility::add_aria_attributes, generate_html,
performance::minify_html, seo::generate_meta_tags,
utils::extract_front_matter,
};

fn benchmark_generate_html(c: &mut Criterion) {
let markdown_input = r#"# Benchmark Heading
This is a test content for benchmarking HTML generation."#;
let config = html_generator::HtmlConfig::default();
c.bench_function("generate_html", |b| {
b.iter(|| generate_html(black_box(markdown_input), &config))
});
}

fn benchmark_minify_html(c: &mut Criterion) {
let html_input =
r#"<html><head></head><body><h1>Test</h1></body></html>"#;
let temp_file = tempfile::NamedTempFile::new().unwrap();
std::fs::write(temp_file.path(), html_input).unwrap();
c.bench_function("minify_html", |b| {
b.iter(|| minify_html(black_box(temp_file.path())))
});
}

fn benchmark_add_aria_attributes(c: &mut Criterion) {
let html_input = r#"<button>Click Me</button>"#;
c.bench_function("add_aria_attributes", |b| {
b.iter(|| add_aria_attributes(black_box(html_input)))
});
}

fn benchmark_generate_meta_tags(c: &mut Criterion) {
let html_input = r#"<html><head><title>Page Title</title></head><body><p>Content</p></body></html>"#;
c.bench_function("generate_meta_tags", |b| {
b.iter(|| generate_meta_tags(black_box(html_input)))
});
}

fn benchmark_extract_front_matter(c: &mut Criterion) {
let input = r#"---
title: Test
---
# Content
This is the main content."#;
c.bench_function("extract_front_matter", |b| {
b.iter(|| extract_front_matter(black_box(input)))
});
}

criterion_group!(
benches,
benchmark_generate_html,
benchmark_minify_html,
benchmark_add_aria_attributes,
benchmark_generate_meta_tags,
benchmark_extract_front_matter
);
criterion_main!(benches);
Loading

0 comments on commit dbe4be7

Please sign in to comment.