Creating Pre-commit file & Adding workflow Testing
هذا الالتزام موجود في:
71
.github/workflows/cicd.yaml
مباع
71
.github/workflows/cicd.yaml
مباع
@@ -1,36 +1,85 @@
|
||||
name: CI/CD Pipeline - Weather App 🌤️
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
|
||||
|
||||
jobs:
|
||||
build_and_push_image:
|
||||
# -----------------------------
|
||||
# 🧪 1. Test job
|
||||
# -----------------------------
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout code
|
||||
- name: 🧾 Checkout Code
|
||||
uses: actions/checkout@v5.0.0
|
||||
|
||||
- name: login to dockerhub
|
||||
- name: 🐍 Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.10"
|
||||
|
||||
- name: 📦 Install Dependencies
|
||||
run: |
|
||||
python -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
pip install pytest pytest-cov flake8
|
||||
|
||||
- name: 🔍 Run Code Linting
|
||||
run: |
|
||||
source venv/bin/activate
|
||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
|
||||
- name: 🧪 Run Unit Tests
|
||||
run: |
|
||||
source venv/bin/activate
|
||||
pytest --maxfail=1 --disable-warnings -q
|
||||
|
||||
- name: 📊 Generate Test Coverage Report
|
||||
run: |
|
||||
source venv/bin/activate
|
||||
pytest --cov=app --cov-report=term-missing
|
||||
|
||||
# -----------------------------
|
||||
# 🐳 2. Build and Push Docker Image
|
||||
# -----------------------------
|
||||
build_and_push_image:
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
steps:
|
||||
- name: 📦 Checkout Code
|
||||
uses: actions/checkout@v5.0.0
|
||||
|
||||
- name: 🔐 Login to DockerHub
|
||||
uses: docker/login-action@v3.6.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
- name: 🐳 Build and Push Docker Image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ahmedgamalyousef/firstcicd:latest
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# ☁️ 3. Deploy to Ghaymah Cloud
|
||||
# -----------------------------
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build_and_push_image
|
||||
steps:
|
||||
- name: checkout code
|
||||
- name: 📦 Checkout Code
|
||||
uses: actions/checkout@v5.0.0
|
||||
- name: install ghaymah cli
|
||||
|
||||
- name: 🌩️ Install Ghaymah CLI
|
||||
run: curl -sSl https://cli.ghaymah.systems/install.sh | bash
|
||||
|
||||
- name: login to ghaymah
|
||||
run: $HOME/ghaymah/bin/gy auth login --email "${{secrets.GHAYMAH_EMAIL}}" --password "${{secrets.GHAYMAH_PW}}"
|
||||
- name: 🔐 Login to Ghaymah Cloud
|
||||
run: $HOME/ghaymah/bin/gy auth login --email "${{ secrets.GHAYMAH_EMAIL }}" --password "${{ secrets.GHAYMAH_PW }}"
|
||||
|
||||
- name: deploy
|
||||
- name: 🚀 Deploy Application
|
||||
run: $HOME/ghaymah/bin/gy resource app launch
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم