Skip to content

Commit d6f0a55

Browse files
authored
feat: Add CI profiles for dev and prod (#7)
* feat: Add CI profiles for dev and prod * add Qa ci-profile * set ci.yml == ci.Qa.yml * Update preview-deployment.yml
1 parent 98283d6 commit d6f0a55

6 files changed

Lines changed: 202 additions & 23 deletions

File tree

.github/workflows/preview-deployment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
password: ${{ secrets.CODESPHERE_PASSWORD }}
3030
team: ${{ secrets.CODESPHERE_TEAM }}
3131
plan: Micro
32+
onDemand: true
3233
env: |
3334
CS_TOKEN=${{ secrets.CODESPHERE_TOKEN }}
3435
apiUrl: https://codesphere.com/

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.Qa.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: 20
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: 20
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: 20
54+
replicas: 1
55+
isPublic: true
56+
network:
57+
path: /api
58+
stripPath: false

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: 20
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: 20
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: 20
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: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,27 @@ prepare:
1010
- name: install uv standalone version
1111
command: curl -LsSf https://astral.sh/uv/install.sh | env
1212
UV_INSTALL_DIR="$HOME/app" sh && chmod +x $HOME/app/uv
13-
- name: copy template .env file
14-
command: cp -n .env.sample .env
1513
- name: "set ev vars "
1614
command: . .env && cs set-env -w $WORKSPACE_ID -t $TEAM_ID --env-var
1715
UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install
1816
--env-var UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin
1917
--env-var UV_CACHE_DIR=$PWD/.codesphere-internal/.uv --env-var
2018
UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python
2119
- name: install frontend environment
22-
command: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync; }
20+
command: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync
21+
--no-dev; }
2322
- name: install backend environment
24-
command: . ./env && cd backend && { [ ! -d ".venv" ] && uv venv; uv sync; }
23+
command: . ./env && cd backend && { [ ! -d ".venv" ] && uv venv; uv sync
24+
--no-dev; }
2525
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'
26+
steps: []
3927
run:
4028
frontend:
4129
steps:
4230
- 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
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 "
4534
plan: 8
4635
replicas: 1
4736
isPublic: true
@@ -51,16 +40,16 @@ run:
5140
backend:
5241
steps:
5342
- name: start backend application
54-
command: . ./env && cd backend && uv run uvicorn app:app --reload --port 3000
55-
--host 0.0.0.0
43+
command: . ./env && cd backend && uv run uvicorn app:app --port 3000 --host
44+
0.0.0.0 --workers 2
5645
plan: 8
5746
replicas: 1
5847
isPublic: false
5948
api-docs:
6049
steps:
6150
- name: deploy docs
6251
command: . ./env && cd backend && uv run uvicorn doc:app_docs --host 0.0.0.0
63-
--port 3000
52+
--port 3000 --workers 2
6453
plan: 8
6554
replicas: 1
6655
isPublic: true

0 commit comments

Comments
 (0)