Skip to content

Commit

Permalink
lock starters versions and create bump version script (#110)
Browse files Browse the repository at this point in the history
* lock starters to specific version and cerate a bump version script

* allows to bump starters by falg

* fix yaml
  • Loading branch information
kaplanelad authored Dec 10, 2023
1 parent 546ae40 commit 8582186
Show file tree
Hide file tree
Showing 24 changed files with 1,099 additions and 222 deletions.
118 changes: 61 additions & 57 deletions .github/workflows/ci-starter-saas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ on:
push:
branches:
- master
paths:
- starters/saas/**
pull_request:
paths:
- starters/saas/**

env:
RUST_TOOLCHAIN: stable
Expand Down Expand Up @@ -101,60 +105,60 @@ jobs:
APP_REDIS_URI: redis://localhost:${{job.services.redis.ports[6379]}}
APP_DATABASE_URI: postgres://postgress:postgress@localhost:5432/postgress_test

generate_template:
name: Generate Template
needs: [test]
runs-on: ubuntu-latest

permissions:
contents: read

services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- "6379:6379"
postgres:
image: postgres
env:
POSTGRES_DB: postgress_test
POSTGRES_USER: postgress
POSTGRES_PASSWORD: postgress
ports:
- "5432:5432"
# Set health checks to wait until postgres has started
options: --health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v3.x
- name: Generate template
run: |
cargo build --release --features github_ci
RUST_LOG=debug LOCO_CURRENT_REPOSITORY=${{ github.event.pull_request.head.repo.html_url }} LOCO_CI_MODE=true LOCO_APP_NAME=saas_starter LOCO_TEMPLATE=saas LOCO_BRANCH=${{ env.GITHUB_HEAD_REF_SLUG }} ./target/release/loco new
cd saas_starter
echo "Building generate template..."
cargo build --release
echo "Run cargo test on generated template..."
cargo test
working-directory: ./loco-cli
env:
APP_REDIS_URI: redis://localhost:${{job.services.redis.ports[6379]}}
APP_DATABASE_URI: postgres://postgress:postgress@localhost:5432/postgress_test
# generate_template:
# name: Generate Template
# needs: [test]
# runs-on: ubuntu-latest

# permissions:
# contents: read

# services:
# redis:
# image: redis
# options: >-
# --health-cmd "redis-cli ping"
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
# ports:
# - "6379:6379"
# postgres:
# image: postgres
# env:
# POSTGRES_DB: postgress_test
# POSTGRES_USER: postgress
# POSTGRES_PASSWORD: postgress
# ports:
# - "5432:5432"
# # Set health checks to wait until postgres has started
# options: --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
#
# steps:
# - name: Checkout the code
# uses: actions/checkout@v4
# - uses: actions-rs/toolchain@v1
# with:
# profile: ${{ env.TOOLCHAIN_PROFILE }}
# toolchain: ${{ env.RUST_TOOLCHAIN }}
# override: true
# - name: Setup Rust cache
# uses: Swatinem/rust-cache@v2
# - name: Inject slug/short variables
# uses: rlespinasse/github-slug-action@v3.x
# - name: Generate template
# run: |
# cargo build --release --features github_ci
# RUST_LOG=debug LOCO_CURRENT_REPOSITORY=${{ github.event.pull_request.head.repo.html_url }} LOCO_CI_MODE=true LOCO_APP_NAME=saas_starter LOCO_TEMPLATE=saas LOCO_BRANCH=${{ env.GITHUB_HEAD_REF_SLUG }} ./target/release/loco new
# cd saas_starter
# echo "Building generate template..."
# cargo build --release
# echo "Run cargo test on generated template..."
# cargo test
# working-directory: ./loco-cli
# env:
# APP_REDIS_URI: redis://localhost:${{job.services.redis.ports[6379]}}
# APP_DATABASE_URI: postgres://postgress:postgress@localhost:5432/postgress_test
60 changes: 32 additions & 28 deletions .github/workflows/ci-stateless-html.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ on:
push:
branches:
- master
paths:
- starters/stateless_html/**
pull_request:
paths:
- starters/stateless_html/**

env:
RUST_TOOLCHAIN: stable
Expand Down Expand Up @@ -73,33 +77,33 @@ jobs:
run: cargo test --all-features --all
working-directory: ./starters/stateless_html

generate_template:
name: Generate Template
needs: [test]
runs-on: ubuntu-latest
# generate_template:
# name: Generate Template
# needs: [test]
# runs-on: ubuntu-latest

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

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v3.x
- name: Generate template
run: |
cargo build --release --features github_ci
RUST_LOG=debug LOCO_CURRENT_REPOSITORY=${{ github.event.pull_request.head.repo.html_url }} LOCO_CI_MODE=true LOCO_APP_NAME=stateless_html_starter LOCO_TEMPLATE=stateless_html LOCO_BRANCH=${{ env.GITHUB_HEAD_REF_SLUG }} ./target/release/loco new
cd stateless_html_starter
echo "Building generate template..."
cargo build --release
echo "Run cargo test on generated template..."
cargo test
working-directory: ./loco-cli
# steps:
# - name: Checkout the code
# uses: actions/checkout@v4
# - uses: actions-rs/toolchain@v1
# with:
# profile: ${{ env.TOOLCHAIN_PROFILE }}
# toolchain: ${{ env.RUST_TOOLCHAIN }}
# override: true
# - name: Setup Rust cache
# uses: Swatinem/rust-cache@v2
# - name: Inject slug/short variables
# uses: rlespinasse/github-slug-action@v3.x
# - name: Generate template
# run: |
# cargo build --release --features github_ci
# RUST_LOG=debug LOCO_CURRENT_REPOSITORY=${{ github.event.pull_request.head.repo.html_url }} LOCO_CI_MODE=true LOCO_APP_NAME=stateless_html_starter LOCO_TEMPLATE=stateless_html LOCO_BRANCH=${{ env.GITHUB_HEAD_REF_SLUG }} ./target/release/loco new
# cd stateless_html_starter
# echo "Building generate template..."
# cargo build --release
# echo "Run cargo test on generated template..."
# cargo test
# working-directory: ./loco-cli
60 changes: 32 additions & 28 deletions .github/workflows/ci-stateless-saas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ on:
push:
branches:
- master
paths:
- starters/stateless/**
pull_request:
paths:
- starters/stateless/**

env:
RUST_TOOLCHAIN: stable
Expand Down Expand Up @@ -73,33 +77,33 @@ jobs:
run: cargo test --all-features --all
working-directory: ./starters/stateless

generate_template:
name: Generate Template
needs: [test]
runs-on: ubuntu-latest
# generate_template:
# name: Generate Template
# needs: [test]
# runs-on: ubuntu-latest

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

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v3.x
- name: Generate template
run: |
cargo build --release --features github_ci
RUST_LOG=debug LOCO_CURRENT_REPOSITORY=${{ github.event.pull_request.head.repo.html_url }} LOCO_CI_MODE=true LOCO_APP_NAME=stateless_starter LOCO_TEMPLATE=stateless LOCO_BRANCH=${{ env.GITHUB_HEAD_REF_SLUG }} ./target/release/loco new
cd stateless_starter
echo "Building generate template..."
cargo build --release
echo "Run cargo test on generated template..."
cargo test
working-directory: ./loco-cli
# steps:
# - name: Checkout the code
# uses: actions/checkout@v4
# - uses: actions-rs/toolchain@v1
# with:
# profile: ${{ env.TOOLCHAIN_PROFILE }}
# toolchain: ${{ env.RUST_TOOLCHAIN }}
# override: true
# - name: Setup Rust cache
# uses: Swatinem/rust-cache@v2
# - name: Inject slug/short variables
# uses: rlespinasse/github-slug-action@v3.x
# - name: Generate template
# run: |
# cargo build --release --features github_ci
# RUST_LOG=debug LOCO_CURRENT_REPOSITORY=${{ github.event.pull_request.head.repo.html_url }} LOCO_CI_MODE=true LOCO_APP_NAME=stateless_starter LOCO_TEMPLATE=stateless LOCO_BRANCH=${{ env.GITHUB_HEAD_REF_SLUG }} ./target/release/loco new
# cd stateless_starter
# echo "Building generate template..."
# cargo build --release
# echo "Run cargo test on generated template..."
# cargo test
# working-directory: ./loco-cli
23 changes: 23 additions & 0 deletions starters/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Starters Overview

Loco starters provide a straightforward way to initiate a Loco project, minimizing user effort and facilitating the seamless adoption of Loco.

## How It Works

The [loco-cli](../loco-cli/README.md) dynamically searches for all available starter projects in the starters root path during runtime. It then prompts the user to choose from the available starters.

Starters **must be work**, as users often start with these projects, and it's crucial to provide a positive first impression :).

When releasing a new version of the Loco library, we utilize xtask utilities, which automatically update the Loco version and the starters, locking them to the updated version.

## When to Update a Starter

Ideally, **avoid** making changes to the starters. Starters should have minimal implementations.

## When to Add a New Starter

We recommend not submitting a pull request (PR) with a new starter right away. Instead, feel free to open a [PR](https://github.com/loco-rs/loco/issues/new/choose) and as and consult with us before investing your time.

## Handling Breaking Changes

When making breaking changes, there is generally no need to update the starters. During version bumps, we thoroughly test the starter projects and make any necessary adjustments if needed.
4 changes: 2 additions & 2 deletions starters/saas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"

[dependencies]

loco-rs = { path = "../../" }
loco-rs = { version = "0.1.5" }
migration = { path = "migration" }

serde = { version = "1", features = ["derive"] }
Expand Down Expand Up @@ -40,6 +40,6 @@ required-features = []
[dev-dependencies]
serial_test = "2.0.0"
rstest = "0.18.2"
loco-rs = { path = "../../", features = ["testing"] }
loco-rs = { version = "0.1.5", features = ["testing"] }
trycmd = "0.14.19"
insta = { version = "1.34.0", features = ["redactions", "yaml", "filters"] }
5 changes: 0 additions & 5 deletions starters/saas/generator.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
---
description: Saas app (with DB and user auth)
rules:
- pattern: loco-rs = \{ path = +.(.*/)+.
skip_in_ci: true
kind: loco-rs = { version = "*"
file_patterns:
- toml
- pattern: loco_starter_template
kind: LibName
file_patterns:
Expand Down
2 changes: 1 addition & 1 deletion starters/saas/migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ path = "src/lib.rs"

[dependencies]
async-std = { version = "1", features = ["attributes", "tokio1"] }
loco-rs = { path = "../../../" }
loco-rs = { version = "0.1.5" }

[dependencies.sea-orm-migration]
version = "0.12.4"
Expand Down
4 changes: 2 additions & 2 deletions starters/stateless/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"

[dependencies]

loco-rs = { path = "../../", default-features = false, features = ["cli"] }
loco-rs = { version = "0.1.5", default-features = false, features = ["cli"] }
serde = "*"
serde_json = "*"
eyre = "*"
Expand All @@ -31,7 +31,7 @@ required-features = []
[dev-dependencies]
serial_test = "*"
rstest = "*"
loco-rs = { path = "../../", default-features = false, features = [
loco-rs = { version = "0.1.5", default-features = false, features = [
"testing",
"cli",
] }
Expand Down
5 changes: 0 additions & 5 deletions starters/stateless/generator.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
---
description: Stateless service (minimal, no db)
rules:
- pattern: loco-rs = \{ path = +.(../../)+.
skip_in_ci: true
kind: loco-rs = { version = "*"
file_patterns:
- Cargo.toml
- pattern: loco_starter_template
kind: LibName
file_patterns:
Expand Down
4 changes: 2 additions & 2 deletions starters/stateless_html/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"

[dependencies]

loco-rs = { path = "../../", default-features = false, features = ["cli"] }
loco-rs = { version = "0.1.5", default-features = false, features = ["cli"] }
serde = "*"
serde_json = "*"
eyre = "*"
Expand All @@ -32,7 +32,7 @@ required-features = []
[dev-dependencies]
serial_test = "*"
rstest = "*"
loco-rs = { path = "../../", default-features = false, features = [
loco-rs = { version = "0.1.5", default-features = false, features = [
"testing",
"cli",
] }
Expand Down
5 changes: 0 additions & 5 deletions starters/stateless_html/generator.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
---
description: Stateless HTML (minimal, no db)
rules:
- pattern: loco-rs = \{ path = +.(../../)+.
skip_in_ci: true
kind: loco-rs = { version = "*"
file_patterns:
- Cargo.toml
- pattern: loco_starter_template
kind: LibName
file_patterns:
Expand Down
Loading

0 comments on commit 8582186

Please sign in to comment.