Skip to content

Commit

Permalink
fix(mailcatcher): replace flox with devbox
Browse files Browse the repository at this point in the history
fix(mailcatcher): replace flox with devbox

fix(mailcatcher): replace flox with devbox
  • Loading branch information
tsirysndr committed Jul 21, 2024
1 parent 8ff8271 commit 13e3a9f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
25 changes: 6 additions & 19 deletions mailcatcher/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
use anyhow::Error;
use fluentci_pdk::dag;

pub fn setup_flox() -> Result<(), Error> {
let os = dag().get_os()?;
if os == "macos" {
dag()
.pipeline("setup-flox")?
.with_exec(vec![r#"type brew > /dev/null 2> /dev/null || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)""#])?
.with_exec(vec!["type flox > /dev/null 2> /dev/null || brew install flox"])?
.stdout()?;
}
Ok(())
}

pub fn setup() -> Result<String, Error> {
setup_flox()?;
dag()
.pipeline("setup")?
.with_exec(vec!["mkdir", "-p", ".fluentci/mailcatcher"])?
Expand All @@ -32,20 +19,20 @@ pub fn setup() -> Result<String, Error> {
}

let stdout = dag()
.flox()?
.devbox()?
.with_workdir(".fluentci/mailcatcher")?
.with_exec(vec![
"flox",
"install",
"devbox",
"add",
"ruby",
"overmind",
"tmux",
"pkg-config",
"openssl"
])?
.with_exec(vec!["gem", "install", "mailcatcher"])?
.with_exec(vec!["[ -d $HOME/.local/bin ] || mkdir -p $HOME/.local/bin"])?
.with_exec(vec!["ln -s `flox activate -- gem environment gemhome`/bin/mailcatcher $HOME/.local/bin/mailcatcher || true"])?
.with_exec(vec![
"grep -q mailcatcher: Procfile || echo -e 'mailcatcher: PATH=`flox activate -- gem environment gemhome`/bin:$PATH mailcatcher --http-port $MAILCATCHER_HTTP_PORT --smtp-port MAILCATCHER_SMTP_PORT -f \\n' >> Procfile",
"grep -q mailcatcher: Procfile || echo -e 'mailcatcher: devbox run mailcatcher --http-port $MAILCATCHER_HTTP_PORT --smtp-port $MAILCATCHER_SMTP_PORT -f \\n' >> Procfile",
])?
.stdout()?;

Expand Down
10 changes: 5 additions & 5 deletions mailcatcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ pub fn start(_args: String) -> FnResult<String> {
let smtp_port = dag().get_env("MAILCATCHER_SMTP_PORT")?;

let stdout = dag()
.flox()?
.devbox()?
.with_workdir(".fluentci/mailcatcher")?
.with_exec(vec!["overmind", "--version"])?
.with_exec(vec!["type", "overmind"])?
.with_exec(vec!["PATH=`flox activate -- gem environment gemhome`/bin:$PATH && flox activate -- type mailcatcher"])?
.with_exec(vec!["PATH=`flox activate -- gem environment gemhome`/bin:$PATH && flox activate -- mailcatcher --version"])?
.with_exec(vec!["type mailcatcher"])?
.with_exec(vec!["mailcatcher --version"])?
.with_exec(vec![
"echo -e \"MailCatcher starting on port $MAILCATCHER_HTTP_PORT\"",
])?
.with_exec(vec![
"overmind start -f Procfile --daemonize || flox activate -- overmind restart mailcatcher",
"overmind start -f Procfile --daemonize || devbox run overmind restart mailcatcher",
])?
.wait_on(http_port.parse()?, None)?
.wait_on(smtp_port.parse()?, None)?
Expand All @@ -41,7 +41,7 @@ pub fn stop(args: String) -> FnResult<String> {
};

let stdout = dag()
.flox()?
.devbox()?
.with_workdir(".fluentci/mailcatcher")?
.with_exec(vec!["overmind", "stop", &args])?
.stdout()?;
Expand Down

0 comments on commit 13e3a9f

Please sign in to comment.