CI for Backend and Frontend #2854
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
name: CI for Backend and Frontend | |
on: | |
workflow_dispatch: | |
push: | |
paths: | |
- "backend/**" | |
- "frontend/**" | |
- ".github/workflows/ci.yml" | |
pull_request: | |
paths: | |
- "backend/**" | |
- "frontend/**" | |
- ".github/workflows/ci.yml" | |
schedule: | |
- cron: '0 */2 * * *' | |
env: | |
node-version: 16.x | |
python: "3.11" | |
plone: "6.0.6" | |
jobs: | |
backend-black: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Run check | |
uses: plone/code-analysis-action@v2 | |
with: | |
base_dir: 'backend' | |
check: 'black' | |
backend-flake8: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Run check | |
uses: plone/code-analysis-action@v2 | |
with: | |
base_dir: 'backend' | |
check: 'flake8' | |
backend-isort: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Run check | |
uses: plone/code-analysis-action@v2 | |
with: | |
base_dir: 'backend' | |
check: 'isort' | |
backend-zpretty: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Run check | |
uses: plone/code-analysis-action@v2 | |
with: | |
base_dir: 'backend' | |
check: 'zpretty' | |
backend-tests: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./backend | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Plone ${{ env.plone }} with Python ${{ env.python }} | |
uses: plone/[email protected] | |
with: | |
python-version: ${{ env.python }} | |
plone-version: ${{ env.plone }} | |
- name: Install package | |
run: | | |
pip install mxdev | |
mxdev -c mx.ini | |
pip install -r requirements-mxdev.txt | |
- name: Run tests | |
run: | | |
PYTHONWARNINGS=ignore zope-testrunner --auto-color --auto-progress --test-path src/plone_6_demo_site/src/ | |
classic-black: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Run check | |
uses: plone/code-analysis-action@v2 | |
with: | |
base_dir: 'classic' | |
check: 'black' | |
classic-flake8: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Run check | |
uses: plone/code-analysis-action@v2 | |
with: | |
base_dir: 'classic' | |
check: 'flake8' | |
classic-isort: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Run check | |
uses: plone/code-analysis-action@v2 | |
with: | |
base_dir: 'classic' | |
check: 'isort' | |
classic-zpretty: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Run check | |
uses: plone/code-analysis-action@v2 | |
with: | |
base_dir: 'classic' | |
check: 'zpretty' | |
frontend-eslint: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./frontend | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Use Node.js ${{ env.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.node-version }} | |
cache: 'yarn' | |
cache-dependency-path: 'frontend/yarn.lock' | |
- name: Install packages | |
run: make install | |
- name: Lint | |
run: yarn run lint:ci | |
frontend-prettier: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./frontend | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Run Prettier | |
run: npx [email protected] --single-quote --check 'src/**/*.{js,jsx,ts,tsx,css,scss}' --config=package.json | |
frontend-i18n: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | |
name: i18n sync | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: frontend | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Use Node.js ${{ env.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.node-version }} | |
cache: 'yarn' | |
cache-dependency-path: 'frontend/yarn.lock' | |
- name: Install packages | |
run: make install | |
- name: Test i18n sync | |
run: make i18n-ci | |
frontend-tests: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./frontend | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Use Node.js ${{ env.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.node-version }} | |
cache: 'yarn' | |
cache-dependency-path: 'frontend/yarn.lock' | |
- name: Install packages | |
run: make install | |
- name: Test | |
run: make test | |
release: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | |
runs-on: ubuntu-latest | |
needs: | |
- backend-black | |
- backend-flake8 | |
- backend-isort | |
- backend-zpretty | |
- backend-tests | |
- classic-black | |
- classic-flake8 | |
- classic-isort | |
- classic-zpretty | |
- frontend-eslint | |
- frontend-prettier | |
- frontend-i18n | |
- frontend-tests | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- image: backend | |
context: backend | |
file: Dockerfile | |
- image: frontend | |
context: frontend | |
file: Dockerfile | |
- image: classic | |
context: classic | |
file: Dockerfile | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/plone/demo-${{ matrix.image }} | |
tags: | | |
type=sha | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to ghcr | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/amd64 | |
context: ${{ matrix.context }} | |
file: ${{ matrix.context }}/${{ matrix.file }} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: SEED=$GITHUB_RUN_ID |