Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(workflows): Arreglo en el lint, commits y render #41

Merged
merged 7 commits into from
Dec 14, 2024
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
38 changes: 28 additions & 10 deletions .github/workflows/commits.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
name: Commits Syntax Checker
name: Validar commits en develop

on:
pull_request:
branches: [main]
types: [opened, reopened, edited, review_requested, synchronize]
push:
branches:
- "main"
workflow_call:
- develop

jobs:
check:
name: Conventional Commits
validar-commits:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: webiny/[email protected]
- name: Checkout del código
uses: actions/checkout@v2

- name: Obtener commits del push
run: |
# Obtener los commits realizados en el push
commits=$(git log origin/develop..HEAD --oneline)
echo "Commits realizados en el push:"
echo "$commits"

# Validar cada commit
while IFS= read -r commit; do
mensaje=$(echo "$commit" | awk '{$1=""; print $0}' | xargs)

if ! echo "$mensaje" | grep -Eq '^(feat|fix|docs|style|refactor|test|chore|perf|build|ci)\([a-zA-Z0-9 _-]+\):\ .+'; then
echo "Error: El mensaje de commit no sigue el formato esperado."
echo "Formato esperado: <tipo>(<módulo>): <descripción>"
echo "Ejemplo válido: fix(workflows): Corrección en el pipeline de CI"
echo "Mensaje actual: '$mensaje'"
exit 1
fi
done <<< "$commits"

echo "Todos los mensajes de commit cumplen con el formato esperado."
28 changes: 0 additions & 28 deletions .github/workflows/lint.yml

This file was deleted.

85 changes: 85 additions & 0 deletions .github/workflows/release-with-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Release Workflow

on:
pull_request:
types:
- closed
branches:
- main

jobs:
release:
if: >
github.event.pull_request.merged == true &&
contains(github.event.pull_request.title, 'release')
runs-on: ubuntu-latest

steps:
- name: Check out the code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10' # Cambia según tus necesidades

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18' # Cambia según tus necesidades

- name: Install Node.js dependencies
run: npm install

- name: Run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Se usa para autenticar con GitHub
run: npx semantic-release

- name: Get version from PR title or increment it
run: |
# Obtener el título de la PR
PR_TITLE="${{ github.event.pull_request.title }}"
echo "PR title: $PR_TITLE"

# Buscar un patrón de versión X.Y.Z en el título
VERSION_PATTERN="([0-9]+)\.([0-9]+)\.([0-9]+)"
if [[ "$PR_TITLE" =~ $VERSION_PATTERN ]]; then
# Si se encuentra un patrón de versión, extraerlo
MAJOR="${BASH_REMATCH[1]}"
MINOR="${BASH_REMATCH[2]}"
PATCH="${BASH_REMATCH[3]}"
echo "Found version: $MAJOR.$MINOR.$PATCH"
else
# Si no se encuentra, obtener la versión desde package.json y sumarle 1 al PATCH
CURRENT_VERSION=$(jq -r .version package.json)
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
PATCH=$((PATCH + 1))
echo "No version found in PR title, incrementing patch to: $MAJOR.$MINOR.$PATCH"
fi

# Crear la nueva versión
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
echo "New version: $NEW_VERSION"

# Actualizar la versión en package.json (opcional)
jq ".version = \"$NEW_VERSION\"" package.json > package.json.tmp && mv package.json.tmp package.json

# Crear la etiqueta con la nueva versión
git tag -a "v$NEW_VERSION" -m "Release version $NEW_VERSION"

# Empujar la etiqueta al repositorio remoto
git push origin "v$NEW_VERSION"

- name: Commit updated version
run: |
git config user.name "GitHub Actions Bot"
git config user.email "[email protected]"
git add package.json CHANGELOG.md
git commit -m "chore(release): update version to $(jq -r .version package.json)"
git push
74 changes: 49 additions & 25 deletions .github/workflows/render.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ name: Deploy to Render

on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
- main

jobs:

testing:

name: Run Tests
runs-on: ubuntu-latest

Expand All @@ -28,40 +26,66 @@ jobs:
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- name: Check out the repository
uses: actions/checkout@v4

- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Tests
env:
FLASK_ENV: testing
MARIADB_HOSTNAME: 127.0.0.1
MARIADB_PORT: 3306
MARIADB_DATABASE: uvlhubdb_test
MARIADB_USER: uvlhub_user
MARIADB_PASSWORD: uvlhub_password
run: |
pytest app/modules/ --ignore-glob='*selenium*'

- name: Run Tests
env:
FLASK_ENV: testing
MARIADB_HOSTNAME: 127.0.0.1
MARIADB_PORT: 3306
MARIADB_TEST_DATABASE: uvlhubdb_test
MARIADB_USER: uvlhubdb_user

MARIADB_PASSWORD: uvlhub_password
run: |
pytest app/modules/ --ignore-glob='*selenium*'

deploy:
name: Deploy to Render
needs: testing
runs-on: ubuntu-latest

steps:
- name: Check out the repo
- name: Check out the repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Populate Database
env:
FLASK_ENV: production
MARIADB_HOSTNAME: ${{ secrets.MARIADB_HOSTNAME }}
MARIADB_PORT: ${{ secrets.MARIADB_PORT }}
MARIADB_DATABASE: ${{ secrets.MARIADB_DATABASE }}
MARIADB_USER: ${{ secrets.MARIADB_USER }}
MARIADB_PASSWORD: ${{ secrets.MARIADB_PASSWORD }}
run: |
flask db upgrade
flask db seed

- name: Deploy to Render
env:
deploy_url: ${{ secrets.RENDER_DEPLOY_HOOK_URL }}
run: |
curl "$deploy_url"
curl -X POST "$deploy_url"
Loading