diff --git a/.github/workflows/preview-deployment.yml b/.github/workflows/preview-deployment.yml index 3a7a8b0..bb1de4a 100644 --- a/.github/workflows/preview-deployment.yml +++ b/.github/workflows/preview-deployment.yml @@ -29,6 +29,7 @@ jobs: password: ${{ secrets.CODESPHERE_PASSWORD }} team: ${{ secrets.CODESPHERE_TEAM }} plan: Micro + onDemand: true env: | CS_TOKEN=${{ secrets.CODESPHERE_TOKEN }} apiUrl: https://codesphere.com/ diff --git a/README.md b/README.md index cc13b35..64ccac7 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ # python-demo test -before running any stage you will need to set up a 'CS_TOKEN' env var containing an Codesphere API key. +before running any stage you will need to set up a 'CS_TOKEN' env var containing an Codesphere API key + +# open backend api docs + +`/api/docs` or `/api/redoc` diff --git a/ci.Qa.yml b/ci.Qa.yml new file mode 100644 index 0000000..32367e1 --- /dev/null +++ b/ci.Qa.yml @@ -0,0 +1,58 @@ +schemaVersion: v0.2 +prepare: + steps: + - 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: "set ev vars " + 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: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync + --no-dev; } + - name: install backend environment + command: . ./env && cd backend && { [ ! -d ".venv" ] && uv venv; uv sync + --no-dev; } +test: + steps: [] +run: + frontend: + steps: + - name: start frontend application + command: ". ./env && cd frontend && uv run streamlit run main.py + --server.headless true --server.address 0.0.0.0 --server.port 3000 + --browser.gatherUsageStats false --logger.level info " + plan: 20 + replicas: 1 + isPublic: true + network: + path: / + stripPath: false + backend: + steps: + - name: start backend application + command: . ./env && cd backend && uv run uvicorn app:app --port 3000 --host + 0.0.0.0 --workers 2 + plan: 20 + replicas: 1 + isPublic: false + api-docs: + steps: + - name: deploy docs + command: . ./env && cd backend && uv run uvicorn doc:app_docs --host 0.0.0.0 + --port 3000 --workers 2 + plan: 20 + replicas: 1 + isPublic: true + network: + path: /api + stripPath: false diff --git a/ci.dev.yml b/ci.dev.yml new file mode 100644 index 0000000..b82cf69 --- /dev/null +++ b/ci.dev.yml @@ -0,0 +1,69 @@ +schemaVersion: v0.2 +prepare: + steps: + - 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 && 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: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync; } + - name: install backend environment + command: . ./env && cd backend && { [ ! -d ".venv" ] && uv venv; uv sync; } +test: + steps: + - name: test frontend + command: . ./env && cd frontend && uv run pytest + - name: test backend + command: ". ./env && cd backend && uv run pytest " + - name: security check frontend + 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: '. ./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: . ./env && cd frontend && uv run streamlit run --server.address 0.0.0.0 + --server.port 3000 main.py + plan: 20 + replicas: 1 + isPublic: true + network: + path: / + stripPath: false + backend: + steps: + - name: start backend application + command: . ./env && cd backend && uv run uvicorn app:app --reload --port 3000 + --host 0.0.0.0 + plan: 20 + replicas: 1 + isPublic: false + api-docs: + steps: + - name: deploy docs + command: . ./env && cd backend && uv run uvicorn doc:app_docs --host 0.0.0.0 + --port 3000 + plan: 20 + replicas: 1 + isPublic: true + network: + path: /api + stripPath: false diff --git a/ci.prod.yml b/ci.prod.yml new file mode 100644 index 0000000..01109f7 --- /dev/null +++ b/ci.prod.yml @@ -0,0 +1,58 @@ +schemaVersion: v0.2 +prepare: + steps: + - 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: "set ev vars " + 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: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync + --no-dev; } + - name: install backend environment + command: . ./env && cd backend && { [ ! -d ".venv" ] && uv venv; uv sync + --no-dev; } +test: + steps: [] +run: + frontend: + steps: + - name: start frontend application + command: ". ./env && cd frontend && uv run streamlit run main.py + --server.headless true --server.address 0.0.0.0 --server.port 3000 + --browser.gatherUsageStats false --logger.level info " + plan: 8 + replicas: 1 + isPublic: true + network: + path: / + stripPath: false + backend: + steps: + - name: start backend application + command: . ./env && cd backend && uv run uvicorn app:app --port 3000 --host + 0.0.0.0 --workers 2 + plan: 8 + replicas: 1 + isPublic: false + api-docs: + steps: + - name: deploy docs + command: . ./env && cd backend && uv run uvicorn doc:app_docs --host 0.0.0.0 + --port 3000 --workers 2 + plan: 8 + replicas: 1 + isPublic: true + network: + path: /api + stripPath: false diff --git a/ci.yml b/ci.yml index 5b96d5e..01109f7 100644 --- a/ci.yml +++ b/ci.yml @@ -10,8 +10,6 @@ prepare: - 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 && cs set-env -w $WORKSPACE_ID -t $TEAM_ID --env-var UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install @@ -19,29 +17,20 @@ prepare: --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: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync; } + command: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync + --no-dev; } - name: install backend environment - command: . ./env && cd backend && { [ ! -d ".venv" ] && uv venv; uv sync; } + command: . ./env && cd backend && { [ ! -d ".venv" ] && uv venv; uv sync + --no-dev; } test: - steps: - - name: test frontend - command: . ./env && cd frontend && uv run pytest - - name: test backend - command: ". ./env && cd backend && uv run pytest " - - name: security check frontend - 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: '. ./env && cd backend && uv run bandit -r . -c pyproject.toml - --format=custom --msg-template "{abspath}:{line}: {test_id}[{severity}]: - {msg}" -o bandit-results.txt' + steps: [] run: frontend: steps: - name: start frontend application - command: . ./env && cd frontend && uv run streamlit run --server.address 0.0.0.0 - --server.port 3000 main.py + command: ". ./env && cd frontend && uv run streamlit run main.py + --server.headless true --server.address 0.0.0.0 --server.port 3000 + --browser.gatherUsageStats false --logger.level info " plan: 8 replicas: 1 isPublic: true @@ -51,8 +40,8 @@ run: backend: steps: - name: start backend application - command: . ./env && cd backend && uv run uvicorn app:app --reload --port 3000 - --host 0.0.0.0 + command: . ./env && cd backend && uv run uvicorn app:app --port 3000 --host + 0.0.0.0 --workers 2 plan: 8 replicas: 1 isPublic: false @@ -60,7 +49,7 @@ run: steps: - name: deploy docs command: . ./env && cd backend && uv run uvicorn doc:app_docs --host 0.0.0.0 - --port 3000 + --port 3000 --workers 2 plan: 8 replicas: 1 isPublic: true