-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
3,290 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
name: Backend CI | ||
|
||
on: | ||
push: | ||
paths: | ||
- "backend/**" | ||
- ".github/workflows/backend.yml" | ||
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 | ||
|
||
jobs: | ||
|
||
meta: | ||
config: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
BASE_TAG: ${{ steps.vars.outputs.BASE_TAG }} | ||
PLONE_VERSION: ${{ steps.vars.outputs.PLONE_VERSION }} | ||
steps: | ||
- name: Checkout | ||
|
@@ -25,91 +27,70 @@ jobs: | |
- name: Set Env Vars | ||
id: vars | ||
run: | | ||
echo "PLONE_VERSION=$(cat backend/version.txt)" >> $GITHUB_OUTPUT | ||
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 }}' | ||
black: | ||
code-quality: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- config | ||
steps: | ||
- name: Checkout codebase | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run check | ||
uses: plone/code-analysis-action@v2 | ||
with: | ||
base_dir: 'backend' | ||
check: 'black' | ||
- name: Install hatch | ||
run: pipx install hatch | ||
|
||
flake8: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout codebase | ||
uses: actions/checkout@v4 | ||
- name: Generate Constraints file | ||
run: pipx run mxdev -c mx.ini | ||
|
||
- name: Run check | ||
uses: plone/code-analysis-action@v2 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
base_dir: 'backend' | ||
check: 'flake8' | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
cache: 'pip' | ||
|
||
isort: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout codebase | ||
uses: actions/checkout@v4 | ||
- name: "Install Environment" | ||
run: hatch env create | ||
|
||
- name: Run check | ||
uses: plone/code-analysis-action@v2 | ||
with: | ||
base_dir: 'backend' | ||
check: 'isort' | ||
- name: "Run checks" | ||
run: hatch run lint | ||
|
||
zpretty: | ||
test: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- config | ||
steps: | ||
- name: Checkout codebase | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run check | ||
uses: plone/code-analysis-action@v2 | ||
with: | ||
base_dir: 'backend' | ||
check: 'zpretty' | ||
- name: Install hatch | ||
run: pipx install hatch | ||
|
||
tests: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- meta | ||
defaults: | ||
run: | ||
working-directory: ./backend | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Generate Constraints file | ||
run: pipx run mxdev -c mx.ini | ||
|
||
- name: Setup Plone ${{ needs.meta.outputs.PLONE_VERSION }} with Python ${{ env.PYTHON_VERSION }} | ||
uses: plone/[email protected] | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
plone-version: ${{ needs.meta.outputs.PLONE_VERSION }} | ||
cache: 'pip' | ||
|
||
- name: Install package | ||
run: | | ||
pip install mxdev | ||
mxdev -c mx.ini | ||
pip install -r requirements-mxdev.txt | ||
- name: "Install Environment" | ||
run: hatch env create | ||
|
||
- name: Run tests | ||
run: | | ||
pytest --disable-warnings src/collective.voltoformblock/tests | ||
- name: "Test Codebase" | ||
run: hatch run test | ||
|
||
release: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- black | ||
- flake8 | ||
- isort | ||
- zpretty | ||
- tests | ||
- config | ||
- code-quality | ||
- test | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
@@ -156,3 +137,34 @@ jobs: | |
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
PLONE_VERSION=${{ needs.config.outputs.PLONE_VERSION }} | ||
- name: Docker meta | ||
id: meta-demo | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
${{ env.IMAGE_NAME_PREFIX }}-demo | ||
labels: | | ||
org.label-schema.docker.cmd=docker run -d -p 8080:8080 ${{ env.IMAGE_NAME_PREFIX }}-demo:latest | ||
flavor: | ||
latest=false | ||
tags: | | ||
type=ref,event=branch | ||
type=sha | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
- name: Build and push demo | ||
uses: docker/build-push-action@v5 | ||
with: | ||
platforms: linux/amd64 | ||
context: backend | ||
file: backend/Dockerfile.demo | ||
load: true | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta-demo.outputs.tags }} | ||
labels: ${{ steps.meta-demo.outputs.labels }} | ||
build-args: | | ||
SEED=${{ github.run_id }} | ||
IMAGE_TAG=${{ needs.config.outputs.BASE_TAG }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: 'volto-form-block' | ||
|
||
on: | ||
push: | ||
paths: | ||
- "backend/**" | ||
- "frontend/**" | ||
- ".github/workflows/backend.yml" | ||
- ".github/workflows/frontend.yml" | ||
- ".github/workflows/main.yml" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
config: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
backend: ${{ steps.filter.outputs.backend }} | ||
frontend: ${{ steps.filter.outputs.frontend }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- uses: dorny/paths-filter@v3 | ||
id: filter | ||
with: | ||
filters: | | ||
backend: | ||
- 'backend/**' | ||
- '.github/workflows/backend.yml' | ||
frontend: | ||
- 'frontend/**' | ||
- '.github/workflows/frontend.yml' | ||
backend: | ||
uses: ./.github/workflows/backend.yml | ||
needs: config | ||
if: ${{ needs.config.outputs.backend == 'true' }} | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
frontend: | ||
uses: ./.github/workflows/frontend.yml | ||
needs: config | ||
if: ${{ needs.config.outputs.frontend == 'true' }} | ||
permissions: | ||
contents: read | ||
packages: write |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.