Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Haunt for Scheme as a provider #1198

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/pages/docs/providers/scheme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
Siarune marked this conversation as resolved.
Show resolved Hide resolved
title: Scheme
---

# {% $markdoc.frontmatter.title %}

Scheme via [haunt](https://dthompson.us/projects/haunt.html) is detected is there is a `haunt.scm` file found.

## Install

Installs the basic dependencies

## Build

Build the project based on your `haunt.scm`.

## Start

Uses `haunt serve` to serve the project
1 change: 1 addition & 0 deletions docs/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const sidebarItems: ISidebarSection[] = [
{ href: "/docs/providers/python", text: "Python" },
{ href: "/docs/providers/ruby", text: "Ruby" },
{ href: "/docs/providers/rust", text: "Rust" },
{ href: "/docs/providers/scheme", text: "Scheme"},
{ href: "/docs/providers/staticfile", text: "Staticfile" },
{ href: "/docs/providers/swift", text: "Swift" },
{ href: "/docs/providers/scala", text: "Scala" },
Expand Down
14 changes: 14 additions & 0 deletions examples/scheme/haunt.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(use-modules (haunt asset)
(haunt builder blog)
(haunt builder assets)
(haunt reader commonmark)
(haunt site))

(site #:title "Built with Guile"
#:domain "example.com"
#:default-metadata
'((author . "siarune")
(email . "aidan.sharp@siarune.dev"))
#:readers (list commonmark-reader)
#:builders (list )
)
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ use providers::{
fsharp::FSharpProvider, gleam::GleamProvider, go::GolangProvider,
haskell::HaskellStackProvider, java::JavaProvider, lunatic::LunaticProvider,
node::NodeProvider, php::PhpProvider, python::PythonProvider, ruby::RubyProvider,
rust::RustProvider, scala::ScalaProvider, staticfile::StaticfileProvider, swift::SwiftProvider,
zig::ZigProvider, Provider,
rust::RustProvider, scala::ScalaProvider, scheme::HauntProvider,
staticfile::StaticfileProvider, swift::SwiftProvider, zig::ZigProvider, Provider,
};
use std::process::Command;

Expand All @@ -62,6 +62,7 @@ pub fn get_providers() -> &'static [&'static (dyn Provider)] {
&GleamProvider {},
&GolangProvider {},
&HaskellStackProvider {},
&HauntProvider {},
&JavaProvider {},
&LunaticProvider {},
&ScalaProvider {},
Expand Down
1 change: 1 addition & 0 deletions src/providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub mod python;
pub mod ruby;
pub mod rust;
pub mod scala;
pub mod scheme;
pub mod staticfile;
pub mod swift;
pub mod zig;
Expand Down
33 changes: 33 additions & 0 deletions src/providers/scheme.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use super::Provider;
use crate::nixpacks::{
app::App,
environment::Environment,
nix::pkg::Pkg,
plan::{
phase::{Phase, StartPhase},
BuildPlan,
},
};
use anyhow::Result;

pub struct HauntProvider {}

impl Provider for HauntProvider {
fn name(&self) -> &str {
"scheme"
}

fn detect(&self, app: &App, _env: &Environment) -> Result<bool> {
Ok(app.includes_file("haunt.scm"))
}

fn get_build_plan(&self, app: &App, _env: &Environment) -> Result<Option<BuildPlan>> {
let setup = Phase::setup(Some(vec![Pkg::new("haunt")]));
let build = Phase::build(Some("haunt build".to_string()));
let start = StartPhase::new("haunt serve".to_string());

let plan = BuildPlan::new(&vec![setup, build], Some(start));

Ok(Some(plan))
}
}
7 changes: 7 additions & 0 deletions tests/docker_run_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1480,3 +1480,10 @@ async fn test_config_toml_file() {
let output = run_image(&name, None).await;
assert!(output.contains("hey there"));
}

#[tokio::test]
async fn test_scheme() {
let name = simple_build("./examples/scheme").await.unwrap();
let output = run_image(&name, None).await;
assert!(output.contains("serving site on port 8080"));
}