Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 18 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
name: CI-CD Pipeline
name: Multi-Job Container Pipeline

on:
push:
branches: [ "main", "feature/*" ]
branches: [ "dev-stable-build" ] # Only runs when we push to this branch
pull_request:
branches: [ "main" ]

jobs:
test-and-deploy:
# JOB 1: The "Inside GitHub" Test
container-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build the Testing Image
run: docker build -t internal-test-image .

# --- STEP 1: UNIT TESTING ---
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install dependencies
run: pip install pytest

- name: Run Pytest
run: pytest
- name: Run Pytest INSIDE the Container
# This is what the teacher wants: Pytest running in the cloud container
run: docker run --rm internal-test-image pytest

# --- STEP 2: DOCKER HUB DEPLOY (Only on Main Branch) ---
# JOB 2: The Deployment (Only if Job 1 passes)
docker-hub-push:
needs: container-test
runs-on: ubuntu-latest
# This prevents pushing to Docker Hub until we are ready for 'main'
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push
if: github.ref == 'refs/heads/main'
run: |
docker build -t skalgleb2devops/testing:latest .
docker push skalgleb2devops/testing:latest
21 changes: 10 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Use the tiny Alpine image
FROM alpine:3.18
FROM python:3.9-slim

# Install Python and Pytest
RUN apk add --no-cache python3 py3-pip curl && \
pip install pytest --break-system-packages

# Set the working directory inside the container
WORKDIR /app

# Copy your files from your ThinkPad into the container
COPY app.py test_app.py ./
# Copy the requirements file first
COPY requirements.txt .

# Install the "baked-in" tools
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of your code
COPY . .

# This command runs the tests when the container starts
CMD ["pytest"]
CMD ["python", "app.py"]
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flask
pytest
Loading