Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ indent_style = space
# 4 space indentation
indent_size = 4

[*.{html,dtml,pt,zpt,xml,zcml,js,json,ts,less,css,sass,scss,yml,yaml}]
[*.{html,dtml,pt,zpt,xml,zcml,js,json,ts,less,scss,css,sass,yml,yaml}]
# 2 space indentation
indent_size = 2

Expand Down
159 changes: 82 additions & 77 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,86 +2,91 @@ name: Backend CI

on:
workflow_call:
workflow_dispatch:

env:
IMAGE_NAME_PREFIX: ghcr.io/collective/volto-form-block
IMAGE_NAME_SUFFIX: backend
PYTHON_VERSION: "3.11"

defaults:
run:
working-directory: ./backend
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:

config:
runs-on: ubuntu-latest
outputs:
BASE_TAG: ${{ steps.vars.outputs.BASE_TAG }}
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 version.txt)" >> $GITHUB_OUTPUT
echo 'BASE_TAG=sha-'$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT

- name: Test vars
run: |
echo 'BASE_TAG=${{ steps.vars.outputs.BASE_TAG }}'
echo 'PLONE_VERSION=${{ steps.vars.outputs.PLONE_VERSION }}'

code-quality:
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: Coverage"
uses: plone/meta/.github/workflows/backend-pytest-coverage.yml@2.x
with:
python-version: ${{ inputs.python-version }}
plone-version: ${{ inputs.plone-version }}
working-directory: ${{ inputs.working-directory }}

release:
name: "Backend: Build and publish Container Image"
uses: plone/meta/.github/workflows/container-image-build-push.yml@2.x
needs:
- lint
- test
- coverage
permissions:
contents: read
packages: write
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 }}

report:
name: "Final report"
if: ${{ always() }}
runs-on: ubuntu-latest
needs:
- config
- lint
- test
- coverage
- release
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Install hatch
run: pipx install hatch

- name: Generate Constraints file
run: pipx run mxdev -c mx.ini

- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'

- name: "Install Environment"
run: hatch env create

- name: "Run checks"
run: hatch run lint

# test:
# runs-on: ubuntu-latest
# needs:
# - config
# steps:
# - name: Checkout codebase
# uses: actions/checkout@v4

# - name: Install hatch
# run: pipx install hatch

# - name: Generate Constraints file
# run: pipx run mxdev -c mx.ini

# - uses: actions/setup-python@v5
# with:
# python-version: ${{ env.PYTHON_VERSION }}
# cache: 'pip'

# - name: "Install Environment"
# run: hatch env create

# - name: "Test Codebase"
# run: hatch run test

- name: Write report
run: |
echo '# Backend Workflow Report' >> $GITHUB_STEP_SUMMARY
echo '| Job ID | Conclusion |' >> $GITHUB_STEP_SUMMARY
echo '| --- | --- |' >> $GITHUB_STEP_SUMMARY
echo '| lint | ${{ needs.lint.result }} |' >> $GITHUB_STEP_SUMMARY
echo '| test | ${{ needs.test.result }} |' >> $GITHUB_STEP_SUMMARY
echo '| coverage | ${{ needs.coverage.result }} |' >> $GITHUB_STEP_SUMMARY
echo '| release | ${{ needs.release.result }} |' >> $GITHUB_STEP_SUMMARY
152 changes: 152 additions & 0 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: "Compute Config variables"

on:
workflow_call:
inputs:
node-version:
required: false
type: string
default: "22"
python-version:
required: false
type: string
default: "3.12"
stack-name:
required: false
type: string
default: "project-example-com"
environment:
required: false
type: string
default: "project.example.com"
outputs:
acceptance:
description: "Flag reporting if we should run the acceptance jobs"
value: ${{ jobs.config.outputs.acceptance }}
backend:
description: "Flag reporting if we should run the backend jobs"
value: ${{ jobs.config.outputs.backend }}
devops:
description: "Flag reporting if we should run the devops jobs"
value: ${{ jobs.config.outputs.devops }}
docs:
description: "Flag reporting if we should run the docs jobs"
value: ${{ jobs.config.outputs.docs }}
frontend:
description: "Flag reporting if we should run the frontend jobs"
value: ${{ jobs.config.outputs.frontend }}
varnish:
description: "Flag reporting if we should run the varnish jobs"
value: ${{ jobs.config.outputs.varnish }}
base-tag:
description: "Base tag to be used when creating container images"
value: ${{ jobs.config.outputs.base-tag }}
event-name:
description: "Event name triggering the workflow"
value: ${{ github.event_name }}
image-name-prefix:
description: "Image name prefix for container images"
value: ${{ jobs.config.outputs.image-name-prefix }}
stack-name:
description: "Stack name for the deployment"
value: ${{ inputs.stack-name }}
environment:
description: "Environment to be used for the deployment"
value: ${{ inputs.environment }}
node-version:
description: "Node version to be used"
value: ${{ inputs.node-version }}
python-version:
description: "Python version to be used"
value: ${{ inputs.python-version }}
plone-version:
description: "Plone version to be used"
value: ${{ jobs.config.outputs.plone-version }}
volto-version:
description: "Volto version to be used"
value: ${{ jobs.config.outputs.volto-version }}

jobs:
config:
runs-on: ubuntu-latest
outputs:
acceptance: ${{ steps.filter.outputs.acceptance }}
backend: ${{ steps.filter.outputs.backend }}
devops: ${{ steps.filter.outputs.devops }}
docs: ${{ steps.filter.outputs.docs }}
frontend: ${{ steps.filter.outputs.frontend }}
varnish: ${{ steps.filter.outputs.varnish }}
base-tag: ${{ steps.vars.outputs.base-tag }}
plone-version: ${{ steps.vars.outputs.plone-version }}
volto-version: ${{ steps.vars.outputs.volto-version }}
image-name-prefix: ${{ steps.vars.outputs.image-name-prefix }}

steps:

- name: Checkout
uses: actions/checkout@v5

- name: Setup uv
uses: plone/meta/.github/actions/setup_uv@2.x
with:
python-version: ${{ inputs.python-version }}
working-directory: '.'

- name: Compute several vars needed for the CI
id: vars
shell: bash
run: |
REPOSITORY_SETTINGS="$(uvx repoplone settings dump)"
echo "image-name-prefix=$(jq -r '.container_images_prefix' <<< "$REPOSITORY_SETTINGS")" >> "$GITHUB_OUTPUT"
echo "plone-version=$(jq -r '.backend.base_package_version' <<< "$REPOSITORY_SETTINGS")" >> "$GITHUB_OUTPUT"
echo "volto-version=$(jq -r '.frontend.volto_version' <<< "$REPOSITORY_SETTINGS")" >> "$GITHUB_OUTPUT"
echo "base-tag=sha-$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"

- name: Filter paths
uses: dorny/paths-filter@v3.0.2
id: filter
with:
filters: |
acceptance:
- '.github/workflows/backend*'
- '.github/workflows/frontend*'
- '.github/workflows/config*'
- 'backend/**'
- 'frontend/**'
backend:
- 'backend/**'
- '.github/workflows/backend*'
- '.github/workflows/config*'
devops:
- 'devops/**'
- '.github/workflows/config*'
docs:
- '.readthedocs.yaml'
- 'docs/**'
- '.github/workflows/docs.yaml'
- '.github/workflows/config*'
frontend:
- 'frontend/**'
- '.github/workflows/frontend*'
- '.github/workflows/config*'
varnish:
- 'devops/varnish/**'
- '.github/workflows/varnish*'
- '.github/workflows/config*'

- name: Test vars
run: |
echo '# Config Settings' >> $GITHUB_STEP_SUMMARY
echo '| Variable | Value |' >> $GITHUB_STEP_SUMMARY
echo '| --- | --- |' >> $GITHUB_STEP_SUMMARY
echo "| base-tag | ${{ steps.vars.outputs.base-tag }} |" >> $GITHUB_STEP_SUMMARY
echo "| plone-version | ${{ steps.vars.outputs.plone-version }} |" >> $GITHUB_STEP_SUMMARY
echo "| volto-version | ${{ steps.vars.outputs.volto-version }} |" >> $GITHUB_STEP_SUMMARY
echo "| image-name-prefix | ${{ steps.vars.outputs.image-name-prefix }} |" >> $GITHUB_STEP_SUMMARY
echo "| event-name | ${{ github.event_name }} |" >> $GITHUB_STEP_SUMMARY
echo "| acceptance | ${{ steps.filter.outputs.acceptance }} |" >> $GITHUB_STEP_SUMMARY
echo "| backend | ${{ steps.filter.outputs.backend }} |" >> $GITHUB_STEP_SUMMARY
echo "| devops | ${{ steps.filter.outputs.devops }} |" >> $GITHUB_STEP_SUMMARY
echo "| docs | ${{ steps.filter.outputs.docs }} |" >> $GITHUB_STEP_SUMMARY
echo "| frontend | ${{ steps.filter.outputs.frontend }} |" >> $GITHUB_STEP_SUMMARY
echo "| varnish | ${{ steps.filter.outputs.varnish }} |" >> $GITHUB_STEP_SUMMARY
Loading
Loading