Correction Workflow

Understanding how automated correction works

Menu

Theme

Toggle between light and dark mode

Language

Choose your preferred language

Font Size

Adjust text size for better readability

Content Width

Choose optimal width for your screen

Table of Contents

Show or hide the table of contents

Actions

More options coming soon...

Automated Correction Workflow

This guide explains in detail the automated correction process for your Docker projects.

๐Ÿ“Š Overview

The automated correction system uses Gitea Actions to evaluate your projects as soon as you do a git push.

graph LR
    A[Git Push] --> B[Gitea Actions]
    B --> C[Clone Repo]
    C --> D[Build Docker]
    D --> E[Run Tests]
    E --> F[Calculate Grade]
    F --> G[Send Email]
โšก 1. Automatic Triggering

The workflow is automatically triggered on:

  • โœ… Push to the main or master branch
  • โœ… Pull Request to main

File .gitea/workflows/correction.yml:

name: Automated Correction

on:
  push:
    branches:
      - main
      - master
  pull_request:
    branches:
      - main

jobs:
  correction:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Build Docker images
        run: docker compose build

      - name: Run tests
        run: docker compose up -d && sleep 5

      - name: Evaluate
        run: ./scripts/evaluate.sh
๐Ÿ“ฅ 2. Repository Cloning

The runner clones your repository:

git clone https://git.zohrabi.cloud/Groupe-A/jean.dupont-tds.git
cd jean.dupont-tds
๐Ÿ—๏ธ 3. Docker Build

The system attempts to build your images:

docker compose build --no-cache

Evaluated criteria:

  • โœ… Successful build without errors (20 points)
  • โœ… Build time < 5 minutes (5 points)
  • โœ… Image size < 500MB (5 points)
  • โœ… Multi-stage build used (bonus +5 points)
๐Ÿš€ 4. Service Startup

Services are launched:

docker compose up -d
sleep 10  # Wait for services to start

Evaluated criteria:

  • โœ… All services start (15 points)
  • โœ… Services in "healthy" state (10 points)
  • โœ… No crash on startup (5 points)
โœ… 5. Functional Tests

The system executes a series of tests:

Connectivity Test

# HTTP Test
curl -f http://localhost:80 || exit 1

# Healthcheck test
curl -f http://localhost:80/health || exit 1

Logs Test

# Check for no critical errors
docker compose logs | grep -i "error" && exit 1

Persistence Test (if applicable)

# Restart and verify data persists
docker compose restart
sleep 5
curl -f http://localhost:80 || exit 1

Evaluated criteria:

  • โœ… HTTP 200 response (10 points)
  • โœ… Functional healthcheck (5 points)
  • โœ… Clean logs (5 points)
  • โœ… Data persistence (10 points)
๐Ÿ” 6. Quality Analysis

Verification of best practices:

Dockerfile

  • โœ… Official base image (5 points)
  • โœ… Version specified (not latest) (5 points)
  • โœ… Multi-stage build (5 points)
  • โœ… Non-root USER (3 points)
  • โœ… Informative labels (2 points)

docker-compose.yml

  • โœ… Version specified (2 points)
  • โœ… Networks defined (3 points)
  • โœ… Restart policy (2 points)
  • โœ… Healthchecks (3 points)

Documentation

  • โœ… README.md present (5 points)
  • โœ… Complete README (5 points)
  • โœ… Comments in code (3 points)
๐Ÿงฎ 7. Grade Calculation
Final Grade = Build (30) + Startup (30) + Tests (30) + Quality (20) + Bonus
Maximum: 100 points + Bonus
๐Ÿ“„ 8. Report Generation

The system generates a detailed HTML report:

<!DOCTYPE html>
<html>
<head>
    <title>Correction Report</title>
</head>
<body>
    <h1>Correction Result</h1>

    <div class="score">
        <h2>Grade: 85/100</h2>
    </div>

    <div class="details">
        <h3>Docker Build (30/30)</h3>
        <ul>
            <li>โœ… Build successful: 20/20</li>
            <li>โœ… Optimal time: 5/5</li>
            <li>โœ… Correct size: 5/5</li>
        </ul>

        <h3>Startup (25/30)</h3>
        <ul>
            <li>โœ… Services started: 15/15</li>
            <li>โš ๏ธ Partial healthcheck: 5/10</li>
            <li>โœ… No crash: 5/5</li>
        </ul>

        <!-- ... -->
    </div>
</body>
</html>
๐Ÿ“ง 9. Email Sending

An email is sent to your Gitea address:

Subject: โœ… Correction TD1 - Grade: 85/100

Content:

  • ๐Ÿ“Š Your grade
  • ๐Ÿ“‹ Complete HTML report
  • ๐Ÿ’ก Improvement suggestions
  • ๐Ÿ”— Link to logs
๐Ÿ“ˆ Detailed Grading Scale

Docker Build (30 points)

Criterion Points
Successful build 20
Time < 5min 5
Size < 500MB 5

Startup (30 points)

Criterion Points
Services start 15
Healthchecks OK 10
No crash 5

Functional Tests (30 points)

Criterion Points
HTTP 200 10
Healthcheck endpoint 5
Clean logs 5
Persistence 10

Code Quality (20 points)

Criterion Points
Dockerfile best practices 10
docker-compose.yml quality 5
Documentation README 5

Bonus (up to +10)

Bonus Points
Multi-stage build +5
Security scan passed +3
Unit tests +2
๐Ÿ” Understanding Logs

Accessing Workflow Logs

  1. Go to Gitea
  2. Open your repository
  3. Click on "Actions"
  4. Select the running or completed workflow

Log Types

Build Logs

Step 1/5 : FROM nginx:alpine
 ---> abc123def456
Step 2/5 : COPY app/ /usr/share/nginx/html/
 ---> Using cache
 ---> def456ghi789
...
Successfully built def456ghi789

Test Logs

[TEST] HTTP Connectivity...
โœ… PASS: HTTP 200 received
[TEST] Healthcheck...
โœ… PASS: /health endpoint responds
[TEST] Logs check...
โœ… PASS: No critical errors found

Error Logs

โŒ ERROR: Build failed
Error response from daemon: dockerfile parse error line 3:
Unknown instruction: EXPOSE80 (should be EXPOSE 80)
๐Ÿ› ๏ธ Debugging Problems

Build Fails

Problem: docker compose build fails

Solutions: 1. Test locally: bash docker compose build 2. Check Dockerfile syntax 3. Verify all dependencies exist

Services Don't Start

Problem: Containers crash on startup

Solutions: 1. Check logs locally: bash docker compose up docker compose logs 2. Verify ports (no conflicts) 3. Check environment variables

Tests Fail

Problem: Low grade despite successful build

Solutions: 1. Test endpoints manually: bash curl http://localhost:80 curl http://localhost:80/health 2. Check application logs 3. Ensure services are ready before tests

๐Ÿ’ก Tips to Improve Your Grade

โœ… Before Push

  1. Test locally: bash docker compose build docker compose up -d docker compose ps docker compose logs curl http://localhost docker compose down

  2. Check Dockerfile:

  3. Official image with version
  4. Multi-stage build if possible
  5. Non-root USER
  6. Labels added

  7. Check docker-compose.yml:

  8. Networks defined
  9. Restart policy
  10. Healthchecks
  11. No unnecessary ports exposed

  12. Document:

  13. Complete README.md
  14. Comments in complex files

โœ… After Push

  1. Follow the Workflow:
  2. Actions tab on Gitea
  3. Verify everything is green

  4. Read the Report:

  5. Email with detailed report
  6. Identify lost points
  7. Apply suggestions

  8. Iterate:

  9. Fix errors
  10. Push again
  11. Improve gradually
๐Ÿ“ง Correction Email Format
From: correction@zohrabi.cloud
To: jean.dupont@example.com
Subject: โœ… Correction TD1 - Grade: 85/100

Hello Jean Dupont,

Your TD1 project has been automatically corrected.

๐Ÿ“Š Final Grade: 85/100

๐ŸŽฏ Details:

- Docker Build: 30/30 โœ…
- Startup: 25/30 โš ๏ธ
- Functional Tests: 25/30 โš ๏ธ
- Code Quality: 15/20 โš ๏ธ

๐Ÿ’ก Improvement Suggestions:

- Add a healthcheck in docker-compose.yml
- Better document the README.md
- Use multi-stage build to reduce size

๐Ÿ“‹ Full report attached (HTML)

๐Ÿ”— Logs: https://git.zohrabi.cloud/Groupe-A/jean.dupont-tds/actions

Good luck!
๐Ÿ†˜ Support
  • ๐Ÿ“– Check the FAQ
  • ๐Ÿ“ง Contact: Reza@zohrabi.fr

Good luck with your projects! ๐Ÿš€

Other pages