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

fix: introduce secondary binary for compile-and-run on Windows #727

Merged
merged 5 commits into from
Sep 2, 2024
Merged
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
76 changes: 38 additions & 38 deletions .github/workflows/e2e-cli-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,44 @@ on:

jobs:
# TODO: re-enable after 0.8 to check cmd spawning fix
# saas-template-win32:
# name: Create saas starter template (win32)
# runs-on: windows-latest
saas-template-win32:
name: Create saas (win32)
runs-on: windows-latest

# permissions:
# contents: read
permissions:
contents: read

# steps:
# - name: Checkout the code
# uses: actions/checkout@v4
# - uses: dtolnay/rust-toolchain@stable
# with:
# toolchain: nightly
# - run: |
# cargo install --path .
# working-directory: ./loco-cli
# - run: |
# loco new -n saas -t saas --db sqlite --bg async --assets none
# env:
# ALLOW_IN_GIT_REPO: true
# - run: |
# cargo build
# working-directory: ./saas
# - run: |
# cargo loco routes
# working-directory: ./saas
# - run: |
# cargo loco db migrate
# working-directory: ./saas
# - run: |
# cargo loco generate scaffold movie title:string
# working-directory: ./saas
# - run: |
# cargo loco db migrate
# working-directory: ./saas
steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
- run: |
cargo install --path .
working-directory: ./loco-cli
- run: |
loco new -n saas -t saas --db sqlite --bg async --assets none
env:
ALLOW_IN_GIT_REPO: true
- run: |
cargo build
working-directory: ./saas
- run: |
cargo loco routes
working-directory: ./saas
- run: |
cargo loco db migrate
working-directory: ./saas
- run: |
cargo loco generate scaffold movie title:string
working-directory: ./saas
- run: |
cargo loco db migrate
working-directory: ./saas

saas-template:
name: Create saas starter template
name: Create saas
runs-on: ubuntu-latest

permissions:
Expand All @@ -59,13 +59,13 @@ jobs:
toolchain: nightly
- run: |
cargo install loco-cli
ALLOW_IN_GIT_REPO=true LOCO_APP_NAME=saas LOCO_TEMPLATE=saas loco new
ALLOW_IN_GIT_REPO=true LOCO_APP_NAME=saas LOCO_TEMPLATE=saas loco new --db postgres --bg queue --assets serverside
- run: |
cargo build
working-directory: ./saas

rest-api:
name: Create stateless starter template
name: Create rest-api
runs-on: ubuntu-latest

permissions:
Expand All @@ -79,13 +79,13 @@ jobs:
toolchain: nightly
- run: |
cargo install loco-cli
ALLOW_IN_GIT_REPO=true LOCO_APP_NAME=restapi LOCO_TEMPLATE=rest-api loco new
ALLOW_IN_GIT_REPO=true LOCO_APP_NAME=restapi LOCO_TEMPLATE=rest-api loco new --db postgres --bg queue
- run: |
cargo build
working-directory: ./restapi

lightweight-service:
name: Create stateless starter template
name: Create lightweight-service
runs-on: ubuntu-latest

permissions:
Expand Down
1 change: 1 addition & 0 deletions examples/demo/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[alias]
loco = "run --"
loco-tool = "run --bin tool --"
playground = "run --example playground"
6 changes: 6 additions & 0 deletions examples/demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
name = "blo"
version = "0.1.0"
edition = "2021"
default-run = "blo-cli"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down Expand Up @@ -47,6 +48,11 @@ name = "blo-cli"
path = "src/bin/main.rs"
required-features = []

[[bin]]
name = "tool"
path = "src/bin/tool.rs"
required-features = []

[dev-dependencies]
serial_test = "3.1.1"
rstest = "0.21.0"
Expand Down
8 changes: 8 additions & 0 deletions examples/demo/src/bin/tool.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use blo::app::App;
use loco_rs::cli;
use migration::Migrator;

#[tokio::main]
async fn main() -> loco_rs::Result<()> {
cli::main::<App, Migrator>().await
}
4 changes: 2 additions & 2 deletions src/gen/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn generate<H: Hooks>(
let cwd = current_dir()?;
let env_map: HashMap<_, _> = std::env::vars().collect();

let _ = cmd!("cargo", "loco", "db", "migrate",)
let _ = cmd!("cargo", "loco-tool", "db", "migrate",)
.stderr_to_stdout()
.dir(cwd.as_path())
.full_env(&env_map)
Expand All @@ -72,7 +72,7 @@ pub fn generate<H: Hooks>(
"failed to run loco db migration. error details: `{err}`",
))
})?;
let _ = cmd!("cargo", "loco", "db", "entities",)
let _ = cmd!("cargo", "loco-tool", "db", "entities",)
.stderr_to_stdout()
.dir(cwd.as_path())
.full_env(&env_map)
Expand Down
1 change: 1 addition & 0 deletions starters/lightweight-service/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[alias]
loco = "run --"
loco-tool = "run --bin tool --"
6 changes: 6 additions & 0 deletions starters/lightweight-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name = "loco_starter_template"
version = "0.1.0"
edition = "2021"
publish = false
default-run = "loco_starter_template-cli"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -24,6 +25,11 @@ name = "loco_starter_template-cli"
path = "src/bin/main.rs"
required-features = []

[[bin]]
name = "tool"
path = "src/bin/tool.rs"
required-features = []

[dev-dependencies]
serial_test = "3.1.1"
rstest = "0.21.0"
Expand Down
7 changes: 7 additions & 0 deletions starters/lightweight-service/src/bin/tool.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use loco_rs::cli;
use loco_starter_template::app::App;

#[tokio::main]
async fn main() -> loco_rs::Result<()> {
cli::main::<App>().await
}
1 change: 1 addition & 0 deletions starters/rest-api/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[alias]
loco = "run --"
loco-tool = "run --bin tool --"
playground = "run --example playground"
6 changes: 6 additions & 0 deletions starters/rest-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name = "loco_starter_template"
version = "0.1.0"
edition = "2021"
publish = false
default-run = "loco_starter_template-cli"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down Expand Up @@ -37,6 +38,11 @@ name = "loco_starter_template-cli"
path = "src/bin/main.rs"
required-features = []

[[bin]]
name = "tool"
path = "src/bin/tool.rs"
required-features = []

[dev-dependencies]
serial_test = "3.1.1"
rstest = "0.21.0"
Expand Down
8 changes: 8 additions & 0 deletions starters/rest-api/src/bin/tool.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use loco_rs::cli;
use loco_starter_template::app::App;
use migration::Migrator;

#[tokio::main]
async fn main() -> loco_rs::Result<()> {
cli::main::<App, Migrator>().await
}
1 change: 1 addition & 0 deletions starters/saas/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[alias]
loco = "run --"
loco-tool = "run --bin tool --"
playground = "run --example playground"
6 changes: 6 additions & 0 deletions starters/saas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name = "loco_starter_template"
version = "0.1.0"
edition = "2021"
publish = false
default-run = "loco_starter_template-cli"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down Expand Up @@ -42,6 +43,11 @@ name = "loco_starter_template-cli"
path = "src/bin/main.rs"
required-features = []

[[bin]]
name = "tool"
path = "src/bin/tool.rs"
required-features = []

[dev-dependencies]
serial_test = "3.1.1"
rstest = "0.21.0"
Expand Down
8 changes: 8 additions & 0 deletions starters/saas/src/bin/tool.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use loco_rs::cli;
use loco_starter_template::app::App;
use migration::Migrator;

#[tokio::main]
async fn main() -> loco_rs::Result<()> {
cli::main::<App, Migrator>().await
}
Loading