Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
Kijewski committed Aug 14, 2024
0 parents commit a769e12
Show file tree
Hide file tree
Showing 27 changed files with 949 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
147 changes: 147 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: CI

on:
push:
branches:
- main
pull_request:
schedule:
- cron: "32 4 * * 5"

permissions:
contents: read
pages: write
id-token: write

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

jobs:
Fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: rustfmt

- name: fmt
run: cargo fmt -- --check

CargoSort:
name: Check order in Cargo.toml
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@v2
with:
tool: cargo-sort
- run: cargo sort --workspace --grouped --check --check-format

Build:
needs:
- Fmt
- CargoSort
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable

- uses: Swatinem/rust-cache@v2

- name: Compile project
run: cargo build --bench template-benchmark --release

Clippy:
needs:
- Fmt
- CargoSort
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy

- uses: Swatinem/rust-cache@v2

- name: clippy
run: cargo clippy -- -D warnings

Audit:
needs:
- Fmt
- CargoSort
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Audit
uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

DevSkim:
needs:
- Fmt
- CargoSort
runs-on: ubuntu-20.04
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@v4

- name: Run DevSkim scanner
uses: microsoft/DevSkim-Action@v1

- name: Upload DevSkim scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: devskim-results.sarif

deploy:
if: github.ref == 'refs/heads/main'
needs:
- Build
- Clippy
- Audit
- DevSkim
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable

- name: Run benchmarks
run: cargo bench --bench template-benchmark

- name: Fixup paths
run: sed -e 's,href="../,href=",' < target/criterion/report/index.html > target/criterion/index.html

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'target/criterion'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target
Cargo.lock
8 changes: 8 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
edition = "2021"
group_imports = "StdExternalCrate"
imports_granularity = "Module"
newline_style = "Unix"
normalize_comments = true
unstable_features = true
use_field_init_shorthand = true
version = "Two"
43 changes: 43 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[workspace]
members = [
".",
"tmpls",
"tmpls/askama",
"tmpls/markup",
"tmpls/minijinja",
"tmpls/rinja",
"tmpls/tinytemplate",
]
resolver = "2"

[package]
name = "template-benchmark"
version = "0.1.0"
edition = "2021"
publish = false
license = "Apache-2.0"

[features]
default = ["askama", "markup", "minijinja", "rinja", "tinytemplate"]
askama = ["dep:askama"]
markup = ["dep:markup"]
minijinja = ["dep:minijinja"]
rinja = ["dep:rinja"]
tinytemplate = ["dep:tinytemplate"]

[dependencies]
tmpls = { version = "*", path = "tmpls" }

askama = { version = "*", optional = true, path = "tmpls/askama", package = "tmpl-askama" }
markup = { version = "*", optional = true, path = "tmpls/markup", package = "tmpl-markup" }
minijinja = { version = "*", optional = true, path = "tmpls/minijinja", package = "tmpl-minijinja" }
rinja = { version = "*", optional = true, path = "tmpls/rinja", package = "tmpl-rinja" }
tinytemplate = { version = "*", optional = true, path = "tmpls/tinytemplate", package = "tmpl-tinytemplate" }

ahash = { version = "0.8.11", features = ["no-rng"] }
criterion = { version = "0.5.1", features = ["html_reports"] }
quanta = "0.12.3"

[[bench]]
name = "template-benchmark"
harness = false
Loading

0 comments on commit a769e12

Please sign in to comment.