Skip to content

Commit

Permalink
Back to the old gha
Browse files Browse the repository at this point in the history
  • Loading branch information
sneridagh committed Jul 9, 2024
1 parent 71063a3 commit b1d82b5
Showing 1 changed file with 150 additions and 71 deletions.
221 changes: 150 additions & 71 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,158 @@
# Generated from:
# https://github.com/plone/meta/tree/main/config/default
# See the inline comments on how to expand/tweak this configuration file
name: Backend CI

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

defaults:
run:
working-directory: ./backend

##
# To set environment variables for all jobs, add in .meta.toml:
# [github]
# env = """
# debug: 1
# image-name: 'org/image'
# image-tag: 'latest'
# """
##
env:
IMAGE_NAME_PREFIX: ghcr.io/collective/volto-form-block
IMAGE_NAME_SUFFIX: backend
PYTHON_VERSION: "3.11"

jobs:
qa:
uses: plone/meta/.github/workflows/qa.yml@main
test:
uses: plone/meta/.github/workflows/test.yml@main
with:

py-versions: '["3.12", "3.11", "3.10"]'
coverage:
uses: plone/meta/.github/workflows/coverage.yml@main
dependencies:
uses: plone/meta/.github/workflows/dependencies.yml@main
release_ready:
uses: plone/meta/.github/workflows/release_ready.yml@main

##
# To modify the list of default jobs being created add in .meta.toml:
# [github]
# jobs = [
# "qa",
# "test",
# "coverage",
# "dependencies",
# "release_ready",
# "circular",
# ]
##

##
# To request that some OS level dependencies get installed
# when running tests/coverage jobs, add in .meta.toml:
# [github]
# os_dependencies = "git libxml2 libxslt"
##

##
# To test against a specific matrix of python versions
# when running tests jobs, add in .meta.toml:
# [github]
# py_versions = "['3.12', '3.11']"
##


##
# Specify additional jobs in .meta.toml:
# [github]
# extra_lines = """
# another:
# uses: org/repo/.github/workflows/file.yml@main
# """
##

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
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/[email protected]
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 src/collective.voltoformblock/tests
release:
runs-on: ubuntu-latest
needs:
- black
- flake8
- isort
- zpretty
- tests
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 }}

0 comments on commit b1d82b5

Please sign in to comment.