Compare commits

..

8 Commits

Author SHA1 Message Date
ksan 0574d08d57 one more
CI/CD / build (push) Successful in 11s
CI/CD / deploy (push) Successful in 9s
2026-06-01 13:22:49 +02:00
ksan 7ce949852f asd
CI/CD / build (push) Successful in 10s
CI/CD / deploy (push) Successful in 10s
2026-06-01 13:21:11 +02:00
ksan bb98b8272f fixed formating
CI/CD / build (push) Successful in 12s
CI/CD / deploy (push) Successful in 13s
2026-05-31 14:47:41 +02:00
ksan ee6889d705 testing change
CI/CD / build (push) Successful in 18s
CI/CD / deploy (push) Successful in 13s
2026-05-31 14:39:03 +02:00
ksan 71ff35c7a1 used github config and i guess it doesn't work with gitea?
CI/CD / build (push) Successful in 12s
CI/CD / deploy (push) Successful in 19s
2026-05-31 14:34:13 +02:00
ksan 049eeed9d6 testing deploy
CI/CD / build (push) Successful in 9s
CI/CD / deploy (push) Has been skipped
2026-05-31 14:29:47 +02:00
ksan 528c31e7fc forgot to add this...
CI/CD / build (push) Successful in 15s
CI/CD / deploy (push) Has been skipped
2026-05-31 14:27:51 +02:00
ksan f1d11085a1 testing build and deploy
CI/CD / build (push) Failing after 6s
CI/CD / deploy (push) Has been skipped
2026-05-31 14:25:07 +02:00
12 changed files with 1858 additions and 53 deletions
+35 -13
View File
@@ -1,27 +1,49 @@
name: CI name: CI/CD
on: on:
push: push:
branches: [main] branches: [main, dev]
pull_request: pull_request:
branches: [main] branches: [main, dev]
jobs: jobs:
test: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - uses: actions/checkout@v4
uses: actions/checkout@v4
- name: Set up Python - uses: actions/setup-node@v4
uses: actions/setup-python@v5
with: with:
python-version: "3.12" node-version: 20
- name: Install dependencies - name: Install dependencies
run: pip install -r requirements.txt run: npm ci
- name: Run tests - name: Build
run: pytest -v run: npm run build
deploy:
runs-on: ubuntu-latest
needs: build
if: gitea.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Build & push Docker image
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | \
docker login git.${{ secrets.DOMAIN }} \
-u ${{ secrets.REGISTRY_USER }} --password-stdin
docker build -t git.${{ secrets.DOMAIN }}/${{ secrets.REGISTRY_USER }}/testapp:latest .
docker push git.${{ secrets.DOMAIN }}/${{ secrets.REGISTRY_USER }}/testapp:latest
- name: Deploy to VPS
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/key
chmod 600 ~/.ssh/key
ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts
ssh -i ~/.ssh/key \
${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} \
"cd ~/programs/testapp && docker compose pull && docker compose up -d"
+12
View File
@@ -0,0 +1,12 @@
# Stage 1 - build the React app
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Stage 2 - serve with nginx
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80
-14
View File
@@ -1,14 +0,0 @@
def add(a, b):
return a + b
def subtract(a, b):
return a - b
def multiply(a, b):
return a * b
def divide(a, b):
if b == 0:
raise ValueError("Cannot divide by zero")
return a / b
+22
View File
@@ -0,0 +1,22 @@
services:
nginx:
build:
context: .
dockerfile: Dockerfile
image: git.ksan.dev/ksan/testapp:latest
container_name: testapp_nginx
networks:
- frontend
labels:
- traefik.enable=true
- traefik.http.routers.testapp-https.rule=Host(`${DOMAIN}`)
- traefik.http.routers.testapp-https.entrypoints=websecure
- traefik.http.routers.testapp-https.tls=true
- traefik.http.routers.testapp-https.tls.certresolver=cloudflare
- traefik.http.services.testapp.loadbalancer.server.port=80
restart: unless-stopped
networks:
frontend:
external: true
+15
View File
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Testapp</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
+1719
View File
File diff suppressed because it is too large Load Diff
+18
View File
@@ -0,0 +1,18 @@
{
"name": "testapp",
"version": "1.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.3.1",
"vite": "^5.4.1"
}
}
-1
View File
@@ -1 +0,0 @@
pytest==8.3.5
+20
View File
@@ -0,0 +1,20 @@
function App() {
return (
<div
style={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
height: '100vh',
}}
>
<h1>Build works when pushing to dev.</h1>
<h1>Now time to try pushing to main and deploy.</h1>
<h2>Okay, everything works just fine.</h2>
<h3> one more</h3>
</div>
);
}
export default App;
+10
View File
@@ -0,0 +1,10 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.jsx'
createRoot(document.getElementById('root')).render(
<StrictMode>
<App />
</StrictMode>
)
-25
View File
@@ -1,25 +0,0 @@
import pytest
from calculator import add, subtract, multiply, divide
def test_add():
assert add(2, 3) == 5
assert add(-1, 1) == 0
assert add(0, 0) == 0
def test_subtract():
assert subtract(10, 4) == 6
assert subtract(0, 5) == -5
def test_multiply():
assert multiply(3, 4) == 12
assert multiply(-2, 5) == -10
assert multiply(0, 100) == 0
def test_divide():
assert divide(10, 2) == 5
assert divide(7, 2) == 3.5
def test_divide_by_zero():
with pytest.raises(ValueError, match="Cannot divide by zero"):
divide(5, 0)
+7
View File
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
})