generated from unai/python_boilerplate
Add CI/CD pipeline configuration for testing and container publishing
This commit is contained in:
54
.gitea/workflows/ci.yaml
Normal file
54
.gitea/workflows/ci.yaml
Normal file
@@ -0,0 +1,54 @@
|
||||
name: CI/CD Pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ['v*']
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test-and-lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.14'
|
||||
|
||||
- name: Install Poetry
|
||||
run: pip install poetry
|
||||
|
||||
- name: Install dependencies
|
||||
run: poetry install
|
||||
|
||||
- name: Lint with Ruff (PEP-8 & Docstrings)
|
||||
run: poetry run ruff check .
|
||||
|
||||
- name: Run Tests with Coverage
|
||||
run: poetry run pytest --cov=my_project --cov-report=term-missing --cov-fail-under=80
|
||||
|
||||
publish-container:
|
||||
needs: test-and-lint
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Login to Gitea Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ gitea.server_url }}
|
||||
# Nota: Quita 'https://' si server_url lo incluye y falla, suele ser solo dominio:puerto
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and Push Docker Image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
${{ gitea.server_url }}/${{ gitea.repository }}:latest
|
||||
${{ gitea.server_url }}/${{ gitea.repository }}:${{ gitea.ref_name }}
|
||||
Reference in New Issue
Block a user