Skip to content

Commit 3e54b46

Browse files
committed
Test non-fastapi project when fastapi is enabled
1 parent 37d0095 commit 3e54b46

File tree

3 files changed

+48
-7
lines changed

3 files changed

+48
-7
lines changed

.github/workflows/testing_fastapi.yml

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ env:
2626
PRODUCTION_MODE: false
2727
DATABASE_URL: postgresql://postgres:[email protected]:5432/test_db
2828
jobs:
29-
test-uv:
30-
name: test-fastapi-uv-setup
29+
test-uv-fastapi-project:
30+
name: test-fastapi-uv-setup-fastapi
3131
strategy:
3232
fail-fast: false
3333
runs-on: ubuntu-latest
@@ -48,7 +48,7 @@ jobs:
4848
- name: Build package
4949
run: cargo build --release -F fastapi
5050
- name: Run creation
51-
run: ./scripts/ci_run_fastapi.sh
51+
run: ./scripts/ci_run_fastapi.sh "fastapi" 1
5252
shell: bash
5353
- name: Install Dependencies
5454
working-directory: ${{ env.WORKING_DIR }}
@@ -70,3 +70,41 @@ jobs:
7070
- name: Test with pytest
7171
working-directory: ${{ env.WORKING_DIR }}
7272
run: uv run pytest -n auto
73+
test-uv-non-fastapi-project:
74+
name: test-fastapi-uv-setup-non-fastapi
75+
strategy:
76+
fail-fast: false
77+
matrix:
78+
project_type: ["application", "lib"]
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@v5
82+
- name: install Rust
83+
uses: dtolnay/rust-toolchain@stable
84+
- name: Cache dependencies
85+
uses: Swatinem/[email protected]
86+
- name: Install uv
87+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
88+
- name: Set up Python
89+
uses: actions/setup-python@v6
90+
with:
91+
python-version: ${{ env.MIN_PYTHON_VERSION }}
92+
- name: Build package
93+
run: cargo build --release -F fastapi
94+
- name: Run creation
95+
run: ./scripts/ci_run_fastapi.sh ${{ matrix.project_type }} 1
96+
shell: bash
97+
- name: Install Dependencies
98+
working-directory: ${{ env.WORKING_DIR }}
99+
run: |
100+
uv lock
101+
uv sync --frozen
102+
- name: Pre-commit check
103+
working-directory: ${{ env.WORKING_DIR }}
104+
run: |
105+
uv run pre-commit install
106+
git add .
107+
uv run pre-commit run --all-files
108+
- name: Test with pytest
109+
working-directory: ${{ env.WORKING_DIR }}
110+
run: uv run pytest

scripts/ci_run_fastapi.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,14 @@ fi
2828

2929
# Check for user provided application input
3030
if [ $# -gt 0 ]; then
31-
if [ $1 = "application" ]; then
31+
if [ $1 = "fastapi" ] ; then
32+
fastapi_project="1"
33+
application="1"
34+
elif [ $1 = "application" ]; then
35+
fastapi_project="2"
3236
application="1"
3337
elif [ $1 = "lib" ]; then
38+
fastapi_project="2"
3439
application="2"
3540
else
3641
echo "Invalid application value"

src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ fn create(project_info: &ProjectInfo) -> Result<()> {
4040
.output()
4141
.expect("Failed to initialize git");
4242

43-
#[cfg(feature = "fastapi")]
44-
install_fastapi_dependencies(project_info)?;
45-
4643
#[cfg(feature = "fastapi")]
4744
if project_info.is_fastapi_project {
45+
install_fastapi_dependencies(project_info)?;
4846
generate_fastapi(project_info)?;
4947
}
5048

0 commit comments

Comments
 (0)