Skip to content

Commit 1f614d5

Browse files
committed
feat: Add CI profiles for dev and prod
1 parent 98283d6 commit 1f614d5

4 files changed

Lines changed: 133 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# python-demo test
22

3-
before running any stage you will need to set up a 'CS_TOKEN' env var containing an Codesphere API key.
3+
before running any stage you will need to set up a 'CS_TOKEN' env var containing an Codesphere API key
4+
5+
# open backend api docs
6+
7+
`/api/docs` or `/api/redoc`

ci.dev.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
schemaVersion: v0.2
2+
prepare:
3+
steps:
4+
- name: install Codesphere cli tool
5+
command: mkdir -p $HOME/.local/bin && wget -qO-
6+
'https://api.github.com/repos/codesphere-cloud/cs-go/releases/latest' |
7+
grep linux_amd64 | grep browser_download_url | sed s/.*https/https/ |
8+
sed s/\".*$// | xargs wget -O $HOME/.local/bin/cs && chmod +x
9+
$HOME/.local/bin/cs
10+
- name: install uv standalone version
11+
command: curl -LsSf https://astral.sh/uv/install.sh | env
12+
UV_INSTALL_DIR="$HOME/app" sh && chmod +x $HOME/app/uv
13+
- name: copy template .env file
14+
command: cp -n .env.sample .env
15+
- name: "set ev vars "
16+
command: . .env && cs set-env -w $WORKSPACE_ID -t $TEAM_ID --env-var
17+
UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install
18+
--env-var UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin
19+
--env-var UV_CACHE_DIR=$PWD/.codesphere-internal/.uv --env-var
20+
UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python
21+
- name: install frontend environment
22+
command: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync; }
23+
- name: install backend environment
24+
command: . ./env && cd backend && { [ ! -d ".venv" ] && uv venv; uv sync; }
25+
test:
26+
steps:
27+
- name: test frontend
28+
command: . ./env && cd frontend && uv run pytest
29+
- name: test backend
30+
command: ". ./env && cd backend && uv run pytest "
31+
- name: security check frontend
32+
command: '. ./env && cd frontend && uv run bandit -r . -c pyproject.toml
33+
--format=custom --msg-template "{abspath}:{line}: {test_id}[{severity}]:
34+
{msg}" -o bandit-results.txt'
35+
- name: security check backend
36+
command: '. ./env && cd backend && uv run bandit -r . -c pyproject.toml
37+
--format=custom --msg-template "{abspath}:{line}: {test_id}[{severity}]:
38+
{msg}" -o bandit-results.txt'
39+
run:
40+
frontend:
41+
steps:
42+
- name: start frontend application
43+
command: . ./env && cd frontend && uv run streamlit run --server.address 0.0.0.0
44+
--server.port 3000 main.py
45+
plan: 8
46+
replicas: 1
47+
isPublic: true
48+
network:
49+
path: /
50+
stripPath: false
51+
backend:
52+
steps:
53+
- name: start backend application
54+
command: . ./env && cd backend && uv run uvicorn app:app --reload --port 3000
55+
--host 0.0.0.0
56+
plan: 8
57+
replicas: 1
58+
isPublic: false
59+
api-docs:
60+
steps:
61+
- name: deploy docs
62+
command: . ./env && cd backend && uv run uvicorn doc:app_docs --host 0.0.0.0
63+
--port 3000
64+
plan: 8
65+
replicas: 1
66+
isPublic: true
67+
network:
68+
path: /api
69+
stripPath: false

ci.prod.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
schemaVersion: v0.2
2+
prepare:
3+
steps:
4+
- name: install Codesphere cli tool
5+
command: mkdir -p $HOME/.local/bin && wget -qO-
6+
'https://api.github.com/repos/codesphere-cloud/cs-go/releases/latest' |
7+
grep linux_amd64 | grep browser_download_url | sed s/.*https/https/ |
8+
sed s/\".*$// | xargs wget -O $HOME/.local/bin/cs && chmod +x
9+
$HOME/.local/bin/cs
10+
- name: install uv standalone version
11+
command: curl -LsSf https://astral.sh/uv/install.sh | env
12+
UV_INSTALL_DIR="$HOME/app" sh && chmod +x $HOME/app/uv
13+
- name: "set ev vars "
14+
command: . .env && cs set-env -w $WORKSPACE_ID -t $TEAM_ID --env-var
15+
UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install
16+
--env-var UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin
17+
--env-var UV_CACHE_DIR=$PWD/.codesphere-internal/.uv --env-var
18+
UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python
19+
- name: install frontend environment
20+
command: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync
21+
--no-dev; }
22+
- name: install backend environment
23+
command: . ./env && cd backend && { [ ! -d ".venv" ] && uv venv; uv sync
24+
--no-dev; }
25+
test:
26+
steps: []
27+
run:
28+
frontend:
29+
steps:
30+
- name: start frontend application
31+
command: ". ./env && cd frontend && uv run streamlit run main.py
32+
--server.headless true --server.address 0.0.0.0 --server.port 3000
33+
--browser.gatherUsageStats false --logger.level info "
34+
plan: 8
35+
replicas: 1
36+
isPublic: true
37+
network:
38+
path: /
39+
stripPath: false
40+
backend:
41+
steps:
42+
- name: start backend application
43+
command: . ./env && cd backend && uv run uvicorn app:app --port 3000 --host
44+
0.0.0.0 --workers 2
45+
plan: 8
46+
replicas: 1
47+
isPublic: false
48+
api-docs:
49+
steps:
50+
- name: deploy docs
51+
command: . ./env && cd backend && uv run uvicorn doc:app_docs --host 0.0.0.0
52+
--port 3000 --workers 2
53+
plan: 8
54+
replicas: 1
55+
isPublic: true
56+
network:
57+
path: /api
58+
stripPath: false

ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ run:
4141
steps:
4242
- name: start frontend application
4343
command: . ./env && cd frontend && uv run streamlit run --server.address 0.0.0.0
44-
--server.port 3000 main.py
44+
--server.port 3000 main.p
4545
plan: 8
4646
replicas: 1
4747
isPublic: true

0 commit comments

Comments
 (0)