Skip to content

Commit

Permalink
Merge branch 'main' into bobtemplates
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTango authored May 7, 2024
2 parents ebf1724 + 0f6bfdd commit 117a05a
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 16 deletions.
1 change: 1 addition & 0 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Post generation hook."""

import json
import os
import subprocess
Expand Down
1 change: 1 addition & 0 deletions hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pre generation hook."""

import re
import sys
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions hooks/pre_prompt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pre Prompt hook."""

import re
import subprocess
import sys
Expand Down
12 changes: 4 additions & 8 deletions local_extensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@

from .semver import VersionInfo

REGISTRIES = {
"Docker Hub": "",
"GitHub": "ghcr.io/",
"GitLab": "registry.gitlab.com/"
}
REGISTRIES = {"Docker Hub": "", "GitHub": "ghcr.io/", "GitLab": "registry.gitlab.com/"}


VOLTO_MIN_VERSION = 16
Expand All @@ -24,12 +20,12 @@
}


DEFAULT_NODE = 18
DEFAULT_NODE = 20

VOLTO_NODE = {
16: 16,
17: DEFAULT_NODE,
18: 20,
17: 18,
18: DEFAULT_NODE,
}


Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pytest configuration."""

from copy import deepcopy

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/test_cutter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test cookiecutter generation."""

import re
from pathlib import Path
from typing import List
Expand Down
1 change: 1 addition & 0 deletions tests/test_hooks_pre_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test cookiecutter generation."""

import pytest

from hooks import pre_gen_project
Expand Down
1 change: 1 addition & 0 deletions tests/test_hooks_pre_prompt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test cookiecutter generation."""

import pytest

from hooks import pre_prompt
Expand Down
1 change: 1 addition & 0 deletions tests/test_project_backend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test Generator: /backend."""

import pytest

BACKEND_FILES = [
Expand Down
1 change: 1 addition & 0 deletions tests/test_project_cache.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test Generator: /varnish (And Cache support)."""

import pytest

CACHE_FILES = [
Expand Down
1 change: 1 addition & 0 deletions tests/test_project_devops.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test Generator: /devops."""

import pytest
import yaml

Expand Down
1 change: 1 addition & 0 deletions tests/test_project_frontend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test Generator: /frontend."""

import pytest

RENAMED_FILES = [
Expand Down
1 change: 1 addition & 0 deletions tests/test_project_generation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test Generator: /."""

import json

import pytest
Expand Down
28 changes: 26 additions & 2 deletions {{ cookiecutter.project_slug }}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ MAKEFLAGS+=--no-builtin-rules

CURRENT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

PLONE_VERSION=$$(cat backend/version.txt)
VOLTO_VERSION = $(shell cat ./frontend/package.json | python -c "import sys, json; print(json.load(sys.stdin)['dependencies']['@plone/volto'])")

PROJECT_NAME={{ cookiecutter.project_slug }}
STACK_NAME={{ cookiecutter.__devops_stack_name }}

Expand Down Expand Up @@ -149,9 +152,9 @@ stack-rm: ## Local Stack: Remove Services and Volumes
.PHONY: build-acceptance-servers
build-acceptance-servers: ## Build Acceptance Servers
@echo "Build acceptance backend"
@docker build backend -t {{ cookiecutter.github_organization }}/{{ cookiecutter.project_slug }}-backend:acceptance -f backend/Dockerfile.acceptance
@docker build backend --build-arg PLONE_VERSION=${PLONE_VERSION} -t {{ cookiecutter.github_organization }}/{{ cookiecutter.project_slug }}-backend:acceptance -f backend/Dockerfile.acceptance
@echo "Build acceptance frontend"
@docker build frontend -t {{ cookiecutter.github_organization }}/{{ cookiecutter.project_slug }}-frontend:acceptance -f frontend/Dockerfile
@docker build frontend --build-arg VOLTO_VERSION=${VOLTO_VERSION} -t {{ cookiecutter.github_organization }}/{{ cookiecutter.project_slug }}-frontend:acceptance -f frontend/Dockerfile

.PHONY: start-acceptance-servers
start-acceptance-servers: build-acceptance-servers ## Start Acceptance Servers
Expand All @@ -172,3 +175,24 @@ run-acceptance-tests: ## Run Acceptance tests
npx wait-on --httpTimeout 20000 http-get://localhost:55001/plone http://localhost:3000
$(MAKE) -C "./frontend/" test-acceptance-headless
$(MAKE) stop-acceptance-servers

## Acceptance Frontend tests in development mode
.PHONY: start-test-acceptance-frontend-dev
start-test-acceptance-frontend-dev: ## Start the Acceptance Frontend Fixture in development mode
(cd frontend && RAZZLE_API_PATH=http://127.0.0.1:55001/plone yarn start)

.PHONY: start-test-acceptance-server
start-test-acceptance-server: build-acceptance-servers ## Start Backend Acceptance Servers in development mode
@echo "Starting test acceptance server"
@docker run --rm -p 55001:55001 --name {{ cookiecutter.project_slug }}-backend-acceptance -d {{ cookiecutter.github_organization }}/{{ cookiecutter.project_slug }}-backend:acceptance
@echo "Started test acceptance server"

.PHONY: test-acceptance
test-acceptance: ## Start Cypress (for use it while developing)
(cd frontend && ./node_modules/.bin/cypress open')

.PHONY: stop-acceptance-server
stop-acceptance-server: ## Stop Backend Acceptance Server in development mode
@echo "Stopping acceptance server"
@docker stop {{ cookiecutter.project_slug }}-backend-acceptance
@echo "Stopped acceptance server"
6 changes: 3 additions & 3 deletions {{ cookiecutter.project_slug }}/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
ARG PLONE_VERSION={{ cookiecutter.plone_version }}
FROM plone/server-builder:${PLONE_VERSION} as builder
ARG PLONE_VERSION
FROM plone/server-builder:${PLONE_VERSION:-{{ cookiecutter.plone_version }}} as builder

WORKDIR /app

Expand All @@ -19,7 +19,7 @@ RUN <<EOT
rm -Rf src/
EOT

FROM plone/server-prod-config:${PLONE_VERSION}
FROM plone/server-prod-config:${PLONE_VERSION:-{{ cookiecutter.plone_version }}}

LABEL maintainer="{{ cookiecutter.author }} <{{ cookiecutter.email }}>" \
org.label-schema.name="{{ cookiecutter.project_slug }}-backend" \
Expand Down
6 changes: 3 additions & 3 deletions {{ cookiecutter.project_slug }}/backend/Dockerfile.acceptance
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
ARG PLONE_VERSION={{ cookiecutter.plone_version }}
FROM plone/server-builder:${PLONE_VERSION} as builder
ARG PLONE_VERSION
FROM plone/server-builder:${PLONE_VERSION:-{{ cookiecutter.plone_version }}} as builder

WORKDIR /app

Expand All @@ -20,7 +20,7 @@ RUN <<EOT
rm -Rf src/
EOT

FROM plone/server-acceptance:${PLONE_VERSION}
FROM plone/server-acceptance:${PLONE_VERSION:-{{ cookiecutter.plone_version }}}

LABEL maintainer="{{ cookiecutter.author }} <{{ cookiecutter.email }}>" \
org.label-schema.name="{{ cookiecutter.project_slug }}-acceptance" \
Expand Down

0 comments on commit 117a05a

Please sign in to comment.