This commit is contained in:
75
.drone.yml
75
.drone.yml
@@ -1,71 +1,18 @@
|
|||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
name: hello-world-pipeline
|
||||||
name: default
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Step 1: Install dependencies and run server tests
|
# Step 1: Run Hello World
|
||||||
- name: server_test
|
- name: hello-world
|
||||||
image: node:18-alpine
|
|
||||||
commands:
|
|
||||||
- echo "Running server tests..."
|
|
||||||
- cd services/server || echo "services/server directory not found!"
|
|
||||||
- if [ -f package.json ]; then
|
|
||||||
yarn install --frozen-lockfile;
|
|
||||||
yarn test;
|
|
||||||
else
|
|
||||||
echo "package.json not found! Skipping server tests.";
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Step 2: Install dependencies and run client tests
|
|
||||||
- name: client_test
|
|
||||||
image: node:18-alpine
|
|
||||||
commands:
|
|
||||||
- echo "Running tests for React client..."
|
|
||||||
- cd services/client || echo "services/client directory not found!"
|
|
||||||
- if [ -f package.json ]; then
|
|
||||||
yarn install --frozen-lockfile;
|
|
||||||
yarn add --dev @babel/plugin-proposal-private-property-in-object @testing-library/jest-dom;
|
|
||||||
yarn test --coverage --detectOpenHandles;
|
|
||||||
else
|
|
||||||
echo "package.json not found! Skipping client tests.";
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Step 3: Lint and static analysis (optional)
|
|
||||||
- name: lint
|
|
||||||
image: node:18-alpine
|
|
||||||
commands:
|
|
||||||
- echo "Running linter..."
|
|
||||||
- cd services/client || echo "services/client directory not found!"
|
|
||||||
- yarn lint || echo "Linting failed! Please fix lint errors."
|
|
||||||
|
|
||||||
# Step 4: Build the React client
|
|
||||||
- name: client_build
|
|
||||||
image: node:18-alpine
|
|
||||||
commands:
|
|
||||||
- echo "Building React client..."
|
|
||||||
- cd services/client || echo "services/client directory not found!"
|
|
||||||
- if [ -f package.json ]; then
|
|
||||||
yarn install --frozen-lockfile;
|
|
||||||
yarn build;
|
|
||||||
else
|
|
||||||
echo "package.json not found! Skipping build.";
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Step 5: Deploy (example step)
|
|
||||||
- name: deploy
|
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
environment:
|
|
||||||
DEPLOY_KEY:
|
|
||||||
from_secret: deploy_key
|
|
||||||
commands:
|
commands:
|
||||||
- echo "Deploying application..."
|
- echo "Hello, World! Everything is running fine!"
|
||||||
- # Add deployment commands here (e.g., SSH, Rsync, Kubernetes, etc.)
|
|
||||||
|
|
||||||
# Specify trigger conditions
|
# Step 2: Cleanup
|
||||||
trigger:
|
- name: cleanup
|
||||||
branch:
|
image: alpine:latest
|
||||||
- main
|
commands:
|
||||||
event:
|
- echo "Cleaning up any created data..."
|
||||||
- push
|
- rm -rf /tmp/* # Example cleanup, adjust based on what needs cleanup
|
||||||
- pull_request
|
- echo "Cleanup complete!"
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "client",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
|
||||||
"start": "react-scripts start",
|
|
||||||
"build": "react-scripts build",
|
|
||||||
"test": "react-scripts test --watchAll=false",
|
|
||||||
"eject": "react-scripts eject"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"react": "^18.0.0",
|
|
||||||
"react-dom": "^18.0.0",
|
|
||||||
"react-scripts": "5.0.1"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@testing-library/react": "^13.0.0",
|
|
||||||
"jest": "^29.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
|
|
||||||
function App() {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<h1>Hello, World!</h1>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default App;
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import { render, screen } from '@testing-library/react';
|
|
||||||
import App from './App';
|
|
||||||
|
|
||||||
test('renders Hello, World!', () => {
|
|
||||||
render(<App />);
|
|
||||||
const headingElement = screen.getByText(/Hello, World!/i);
|
|
||||||
expect(headingElement).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
from flask import Flask
|
|
||||||
|
|
||||||
def create_app():
|
|
||||||
app = Flask(__name__)
|
|
||||||
|
|
||||||
@app.route("/")
|
|
||||||
def hello_world():
|
|
||||||
return "Hello, World!"
|
|
||||||
|
|
||||||
return app
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
class Config:
|
|
||||||
SECRET_KEY = os.environ.get("SECRET_KEY", "default_secret_key")
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
from . import create_app
|
|
||||||
|
|
||||||
app = create_app()
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
from app import create_app
|
|
||||||
|
|
||||||
app = create_app()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
app.run()
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
Flask==2.2.2
|
|
||||||
pytest==7.2.0
|
|
||||||
gunicorn==20.1.0
|
|
||||||
psycopg2-binary==2.9.6
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import pytest
|
|
||||||
from app import create_app
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def app():
|
|
||||||
app = create_app()
|
|
||||||
app.config.update({
|
|
||||||
"TESTING": True,
|
|
||||||
})
|
|
||||||
return app
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def client(app):
|
|
||||||
return app.test_client()
|
|
||||||
|
|
||||||
def test_hello_world(client):
|
|
||||||
response = client.get("/")
|
|
||||||
assert response.status_code == 200
|
|
||||||
assert response.data == b"Hello, World!"
|
|
||||||
Reference in New Issue
Block a user