Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
07c890a
fix readme
Datata1 Jun 11, 2025
b3a3906
fix readme
Datata1 Jun 11, 2025
4228588
Update preview-deployment.yml
Datata1 Jun 11, 2025
41f5b16
Update backend-app.yml
Datata1 Jun 11, 2025
136cc24
Update frontend-app.yml
Datata1 Jun 11, 2025
318a225
Update preview-deployment.yml
Datata1 Jun 11, 2025
8524637
Update backend-app.yml
Datata1 Jun 12, 2025
689709d
Update frontend-app.yml
Datata1 Jun 12, 2025
a68cdbf
Merge pull request #2 from codesphere-cloud/main
Datata1 Jun 12, 2025
2bf476e
Update backend-app.yml
Datata1 Jun 12, 2025
bd9666d
Update frontend-app.yml
Datata1 Jun 12, 2025
181085b
Update backend-app.yml
Datata1 Jun 12, 2025
b7782fb
Update frontend-app.yml
Datata1 Jun 12, 2025
a5229c3
change uv installation method
Datata1 Jun 12, 2025
6780ca2
ci.yml
Datata1 Jun 12, 2025
38e2a45
Update preview-deployment.yml
Datata1 Jun 12, 2025
7b4d337
changes to ci.yml
Datata1 Jun 12, 2025
c151615
debug ci
Datata1 Jun 12, 2025
5ebff04
change .env sample
Datata1 Jun 12, 2025
8f088e0
Update backend-app.yml
Datata1 Jun 12, 2025
2de5e9e
Merge branch 'main' into fix/readme
Datata1 Jun 12, 2025
14e3a2f
Update backend-app.yml
Datata1 Jun 12, 2025
08b86fe
Update frontend-app.yml
Datata1 Jun 12, 2025
7eef90d
Update backend-app.yml
Datata1 Jun 12, 2025
b26e00a
Update backend-app.yml
Datata1 Jun 12, 2025
e95995f
Update frontend-app.yml
Datata1 Jun 12, 2025
d785667
Update backend-app.yml
Datata1 Jun 12, 2025
f95ef4e
Update frontend-app.yml
Datata1 Jun 12, 2025
f19c94c
Update backend-app.yml
Datata1 Jun 12, 2025
555babd
Update frontend-app.yml
Datata1 Jun 12, 2025
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
4 changes: 1 addition & 3 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# set API TOKEN so that the cli is authorized to use the public api
CS_TOKEN=
TEAM_ID=
export TEAM_ID=$(cs list workspaces | grep $WORKSPACE_ID | awk '{print $2}')
23 changes: 9 additions & 14 deletions .github/workflows/backend-app.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Python server tests
name: Python backend server tests

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, draft]
paths:
- 'server/**'
- 'backend/**'
- '.github/workflows/backend-app.yml'

permissions:
Expand All @@ -15,9 +15,6 @@ jobs:
pytest:
runs-on: ubuntu-latest

env:
UV_CACHE_DIR: ${{ github.workspace }}/backend/.uv_cache

permissions:
contents: read
pull-requests: write
Expand All @@ -29,18 +26,15 @@ jobs:
- name: Install uv package manager
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-dependency-glob: backend/uv.lock
activate-environment: true
working-directory: backend
cache-local-path: ${{ github.workspace }}/backend/.uv_cache

- name: Install dependencies using uv
run: |
cd server && uv sync
cd backend && uv sync
shell: bash

- name: Run Bandit security check on server code
- name: Run Bandit security check on backend code
id: bandit_check
run: |
echo "Running Bandit security check..."
Expand All @@ -61,7 +55,7 @@ jobs:
COMMENT_BODY_FILE="bandit-comment-body.md"
echo "COMMENT_BODY_FILE=${COMMENT_BODY_FILE}" >> $GITHUB_ENV

echo "### 🛡️ Bandit Security Scan Results" > $COMMENT_BODY_FILE
echo "### 🛡️ Bandit Backend Security Scan Results" > $COMMENT_BODY_FILE
echo "" >> $COMMENT_BODY_FILE
echo "" >> $COMMENT_BODY_FILE
echo "" >> $COMMENT_BODY_FILE
Expand All @@ -81,7 +75,7 @@ jobs:
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Bandit Security Scan Results
body-includes: Bandit Backend Security Scan Results

- name: Post Bandit results as PR comment
if: github.event_name == 'pull_request' && always()
Expand All @@ -104,11 +98,12 @@ jobs:
if: github.event_name == 'pull_request' && always()
uses: MishaKav/pytest-coverage-comment@main
with:
unique-id-for-comment: backend-coverage-report
pytest-xml-coverage-path: backend/coverage.xml
pytest-coverage-path: backend/pytest-coverage.txt
junitxml-path: backend/junit/test-results.xml
title: Pytest Coverage Report
junitxml-title: Test Execution Summary
title: Pytest Coverage Report - Backend
junitxml-title: Test Execution Summary - Backend

- name: Minimize uv cache
run: uv cache prune --ci
29 changes: 12 additions & 17 deletions .github/workflows/frontend-app.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Python server tests
name: Python frontend server tests

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, draft]
paths:
- 'server/**'
- '.github/workflows/python-app.yml'
- 'frontend/**'
- '.github/workflows/frontend-app.yml'

permissions:
contents: write
Expand All @@ -15,9 +15,6 @@ jobs:
pytest:
runs-on: ubuntu-latest

env:
UV_CACHE_DIR: ${{ github.workspace }}/frontend/.uv_cache

permissions:
contents: read
pull-requests: write
Expand All @@ -29,15 +26,12 @@ jobs:
- name: Install uv package manager
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-dependency-glob: frontend/uv.lock
activate-environment: true
working-directory: frontend
cache-local-path: ${{ github.workspace }}/frontend/.uv_cache

- name: Install dependencies using uv
run: |
cd server && uv sync
cd frontend && uv sync
shell: bash

- name: Run Bandit security check on server code
Expand All @@ -61,7 +55,7 @@ jobs:
COMMENT_BODY_FILE="bandit-comment-body.md"
echo "COMMENT_BODY_FILE=${COMMENT_BODY_FILE}" >> $GITHUB_ENV

echo "### 🛡️ Bandit Security Scan Results" > $COMMENT_BODY_FILE
echo "### 🛡️ Bandit Frontend Security Scan Results" > $COMMENT_BODY_FILE
echo "" >> $COMMENT_BODY_FILE
echo "" >> $COMMENT_BODY_FILE
echo "" >> $COMMENT_BODY_FILE
Expand All @@ -81,7 +75,7 @@ jobs:
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Bandit Security Scan Results
body-includes: Bandit Frontend Security Scan Results

- name: Post Bandit results as PR comment
if: github.event_name == 'pull_request' && always()
Expand All @@ -104,11 +98,12 @@ jobs:
if: github.event_name == 'pull_request' && always()
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-xml-coverage-path: server/coverage.xml
pytest-coverage-path: server/pytest-coverage.txt
junitxml-path: server/junit/test-results.xml
title: Pytest Coverage Report
junitxml-title: Test Execution Summary
unique-id-for-comment: frontend-coverage-report
pytest-xml-coverage-path: frontend/coverage.xml
pytest-coverage-path: frontend/pytest-coverage.txt
junitxml-path: frontend/junit/test-results.xml
title: Pytest Coverage Report - Frontend
junitxml-title: Test Execution Summary - Frontend

- name: Minimize uv cache
run: uv cache prune --ci
11 changes: 5 additions & 6 deletions .github/workflows/preview-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ permissions:
pull-requests: read
deployments: write

env:
ON_DEMAND='true'
WORKSPACE_PLAN='Boost'

jobs:
deploy:
concurrency: codesphere
Expand All @@ -32,5 +28,8 @@ jobs:
email: ${{ secrets.CODESPHERE_EMAIL }}
password: ${{ secrets.CODESPHERE_PASSWORD }}
team: ${{ secrets.CODESPHERE_TEAM }}
plan: $WORKSPACE_PLAN
onDemand: $ON_DEMAND
plan: 'Boost'
onDemand: 'true'
env: |
TEAM_ID=${{ secrets.CODESPHERE_TEAM_ID }}
CS_TOKEN=${{ secrets.CODESPHERE_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.env
env
env.fish

.github/*

uv
uvx
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# python-demo
# python-demo
# python-demo test
5 changes: 4 additions & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ coverage.xml
pytest-coverage.txt
.coverage

__pycache__/*
__pycache__/*
tests/__pycache__/*

bandit-results.txt
1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies = [
"numpy>=2.3.0",
"pandas>=2.3.0",
"pytest-cov>=6.1.1",
"pytest-profiling>=1.8.1",
]

[dependency-groups]
Expand Down
Binary file not shown.
Empty file removed backend/tests/conftest.py
Empty file.
25 changes: 25 additions & 0 deletions backend/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 22 additions & 18 deletions ci.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
schemaVersion: v0.2
prepare:
steps:
- name: install nix dependencies
command: nix-env -iA nixpkgs.uv
- name: install Codesphere cli tool
command: mkdir -p $HOME/.local/bin && wget -qO-
'https://api.github.com/repos/codesphere-cloud/cs-go/releases/latest' |
grep linux_amd64 | grep browser_download_url | sed s/.*https/https/ |
sed s/\".*$// | xargs wget -O $HOME/.local/bin/cs && chmod +x
$HOME/.local/bin/cs
- name: install uv standalone version
command: curl -LsSf https://astral.sh/uv/install.sh | env
UV_INSTALL_DIR="$HOME/app" sh && chmod +x $HOME/app/uv
- name: copy template .env file
command: cp -n .env.sample .env
- name: "set ev vars "
command: . .env && export $CS_TOKEN && cs set-env -w $CODESPHERE_APP_ID -t
$TEAM_ID --env-var UV_CACHE_DIR=$PWD/.codesphere-internal/.uv --env-var
command: . .env && cs set-env -w $WORKSPACE_ID -t $TEAM_ID --env-var
UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install
--env-var UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin
--env-var UV_CACHE_DIR=$PWD/.codesphere-internal/.uv --env-var
UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python
- name: install frontend environment
command: cd frontend && uv sync
command: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync; }
- name: install backend environment
command: "cd backend && uv sync "
command: . ./env && cd backend && { [ ! -d ".venv" ] && uv venv; uv sync; }
test:
steps:
- name: test frontend
command: cd frontend && uv run pytest --junitxml=junit/test-results.xml
--cov-report=xml --cov-report=html --cov=. | tee pytest-coverage.txt
command: . ./env && cd frontend && uv run pytest
- name: test backend
command: cd backend && uv run pytest --junitxml=junit/test-results.xml
--cov-report=xml --cov-report=html --cov=. | tee pytest-coverage.txt
command: ". ./env && cd backend && uv run pytest "
- name: security check frontend
command: 'bandit -r . -c pyproject.toml --format=custom --msg-template
"{abspath}:{line}: {test_id}[{severity}]: {msg}" -o bandit-results.txt'
command: '. ./env && cd frontend && uv run bandit -r . -c pyproject.toml
--format=custom --msg-template "{abspath}:{line}: {test_id}[{severity}]:
{msg}" -o bandit-results.txt'
- name: security check backend
command: 'bandit -r . -c pyproject.toml --format=custom --msg-template
"{abspath}:{line}: {test_id}[{severity}]: {msg}" -o bandit-results.txt'
command: '. ./env && cd backend && uv run bandit -r . -c pyproject.toml
--format=custom --msg-template "{abspath}:{line}: {test_id}[{severity}]:
{msg}" -o bandit-results.txt'
run:
frontend:
steps:
- name: start frontend application
command: cd frontend && uv run streamlit run --server.address 0.0.0.0
command: . ./env && cd frontend && uv run streamlit run --server.address 0.0.0.0
--server.port 3000 main.py
plan: 8
replicas: 1
Expand All @@ -48,15 +51,16 @@ run:
backend:
steps:
- name: start backend application
command: cd backend && uv run uvicorn app:app --reload --port 3000 --host
0.0.0.0
command: . ./env && cd backend && uv run uvicorn app:app --reload --port 3000
--host 0.0.0.0
plan: 8
replicas: 1
isPublic: false
api-docs:
steps:
- name: deploy docs
command: cd backend && uv run uvicorn doc:app_docs --host 0.0.0.0 --port 3000
command: . ./env && cd backend && uv run uvicorn doc:app_docs --host 0.0.0.0
--port 3000
plan: 8
replicas: 1
isPublic: true
Expand Down
5 changes: 4 additions & 1 deletion frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ coverage.xml
pytest-coverage.txt
.coverage

__pycache__/*
__pycache__/*
tests/__pycache__/*

bandit-results.txt
2 changes: 1 addition & 1 deletion frontend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@st.cache_data
def fetch_data(url: str, points: int):
try:
response = requests.get(url, params={"points": points})
response = requests.get(url, params={"points": points}, timeout=3)
response.raise_for_status()

data = response.json()
Expand Down
1 change: 1 addition & 0 deletions frontend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies = [
"pandas>=2.3.0",
"plotly>=6.1.2",
"pytest-cov>=6.1.1",
"pytest-profiling>=1.8.1",
"requests>=2.32.4",
"streamlit>=1.45.1",
]
Expand Down
Binary file not shown.
Binary file not shown.
Empty file removed frontend/tests/conftest.py
Empty file.
Loading