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
205 changes: 60 additions & 145 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -1,158 +1,73 @@
name: Backend CI

on:
push:
paths:
- "backend/**"
- ".github/workflows/backend.yml"
workflow_dispatch:

env:
IMAGE_NAME_PREFIX: ghcr.io/pythonbrasil/pybr25-site
IMAGE_NAME_SUFFIX: backend
PYTHON_VERSION: "3.11"
workflow_call:
inputs:
base-tag:
required: true
type: string
image-name-prefix:
required: true
type: string
image-name-suffix:
required: true
type: string
python-version:
required: true
type: string
plone-version:
required: true
type: string
working-directory:
required: false
type: string
default: backend

jobs:

meta:
runs-on: ubuntu-latest
outputs:
PLONE_VERSION: ${{ steps.vars.outputs.PLONE_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set Env Vars
id: vars
run: |
echo "PLONE_VERSION=$(cat backend/version.txt)" >> $GITHUB_OUTPUT

black:
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'backend'
check: 'black'

flake8:
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'backend'
check: 'flake8'

isort:
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'backend'
check: 'isort'

zpretty:
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'backend'
check: 'zpretty'

tests:
runs-on: ubuntu-latest
lint:
name: "Backend: Lint"
uses: plone/meta/.github/workflows/backend-lint.yml@2.x
with:
python-version: ${{ inputs.python-version }}
plone-version: ${{ inputs.plone-version }}
working-directory: ${{ inputs.working-directory }}

test:
name: "Backend: Test"
uses: plone/meta/.github/workflows/backend-pytest.yml@2.x
with:
python-version: ${{ inputs.python-version }}
plone-version: ${{ inputs.plone-version }}
working-directory: ${{ inputs.working-directory }}

coverage:
name: "Backend: Test"
uses: plone/meta/.github/workflows/backend-pytest-coverage.yml@2.x
needs:
- meta
defaults:
run:
working-directory: ./backend

steps:
- uses: actions/checkout@v4

- name: Setup Plone ${{ needs.meta.outputs.PLONE_VERSION }} with Python ${{ env.PYTHON_VERSION }}
uses: plone/setup-plone@v3.0.0
with:
python-version: ${{ env.PYTHON_VERSION }}
plone-version: ${{ needs.meta.outputs.PLONE_VERSION }}

- name: Install package
run: |
pip install mxdev
mxdev -c mx.ini
pip install -r requirements-mxdev.txt

- name: Run tests
run: |
pytest --disable-warnings tests
- test
with:
python-version: ${{ inputs.python-version }}
plone-version: ${{ inputs.plone-version }}
working-directory: ${{ inputs.working-directory }}

release:
runs-on: ubuntu-latest
name: "Backend: Build and publish Container Image"
uses: plone/meta/.github/workflows/container-image-build-push.yml@2.x
needs:
- black
- flake8
- isort
- zpretty
- tests
- lint
- coverage
permissions:
contents: read
packages: write

steps:

- name: Checkout
uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMAGE_NAME_PREFIX }}-${{ env.IMAGE_NAME_SUFFIX }}
labels: |
org.label-schema.docker.cmd=docker run -d -p 8080:8080 ${{ env.IMAGE_NAME_PREFIX }}-${{ env.IMAGE_NAME_SUFFIX }}:latest
flavor:
latest=false
tags: |
type=ref,event=branch
type=sha
type=raw,value=latest,enable={{is_default_branch}}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
platforms: linux/amd64
context: backend
file: backend/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
with:
base-tag: ${{ inputs.base-tag }}
image-name-prefix: ${{ inputs.image-name-prefix }}
image-name-suffix: ${{ inputs.image-name-suffix }}
working-directory: ${{ inputs.working-directory }}
build-args: |
PLONE_VERSION=${{ inputs.plone-version }}
push: ${{ github.event_name != 'pull_request' }}
secrets:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
135 changes: 135 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Changelog
on:
pull_request:
types: [assigned, opened, synchronize, reopened, labeled, unlabeled]
branches:
- main

env:
NODE_VERSION: 22.x
ADDON_NAME: volto-pythonbrasil-site
BASE_BRANCH: main

jobs:
config:
runs-on: ubuntu-latest
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
repository: ${{ steps.filter.outputs.repository }}
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: dorny/paths-filter@v3.0.2
id: filter
with:
filters: |
backend:
- 'backend/**'
repository:
- '.github/**'
- '.vscode/**'
- 'devops/**'
- 'docs/**'
- 'docker-compose.yml'
- 'README.md'
frontend:
- 'frontend/**'

backend:
if: ${{ needs.config.outputs.backend == 'true' }}
runs-on: ubuntu-latest
needs:
- config
steps:
- uses: actions/checkout@v4
with:
# Fetch all history
fetch-depth: '0'

- name: Install pipx
run: pip install towncrier

- name: Check for presence of a Change Log fragment (only pull requests)
if: github.event_name == 'pull_request'
run: |
# Fetch the pull request' base branch so towncrier will be able to
# compare the current branch with the base branch.
# Source: https://github.com/actions/checkout/#fetch-all-branches.
git fetch --no-tags origin ${BASE_BRANCH}
towncrier check --compare-with origin/${{ env.BASE_BRANCH }} --config backend/pyproject.toml --dir backend/

frontend:
if: ${{ needs.config.outputs.frontend == 'true' }}
runs-on: ubuntu-latest
needs:
- config
defaults:
run:
working-directory: ./frontend
steps:
- uses: actions/checkout@v4
with:
# Fetch all history
fetch-depth: '0'

- name: Install pipx
run: pip install towncrier

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Enable corepack
run: npm i -g corepack@latest && corepack enable

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: make install

- name: Check for presence of a Change Log fragment (only pull requests)
if: github.event_name == 'pull_request'
run: |
# Fetch the pull request' base branch so towncrier will be able to
# compare the current branch with the base branch.
# Source: https://github.com/actions/checkout/#fetch-all-branches.
git fetch --no-tags origin ${BASE_BRANCH}
cd ..
towncrier check --compare-with origin/${{ env.BASE_BRANCH }} --config frontend/packages/${{ env.ADDON_NAME }}/towncrier.toml --dir frontend/packages/${{ env.ADDON_NAME }}

repository:
if: ${{ needs.config.outputs.repository == 'true' }}
runs-on: ubuntu-latest
needs:
- config
steps:
- uses: actions/checkout@v4
with:
# Fetch all history
fetch-depth: '0'

- name: Install pipx
run: pip install towncrier

- name: Check for presence of a Change Log fragment (only pull requests)
if: github.event_name == 'pull_request'
run: |
# Fetch the pull request' base branch so towncrier will be able to
# compare the current branch with the base branch.
# Source: https://github.com/actions/checkout/#fetch-all-branches.
git fetch --no-tags origin ${BASE_BRANCH}
towncrier check --compare-with origin/${{ env.BASE_BRANCH }} --config towncrier.toml --dir .
Loading