Skip to content
Merged
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
53 changes: 31 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ MAKEFLAGS+=--no-builtin-rules
CURRENT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
GIT_FOLDER=$(CURRENT_DIR)/.git

PROJECT_NAME=pybr25-site
STACK_NAME=2025-pythonbrasil-org-br
STACK_FILE=docker-compose-dev.yml
REPOSITORY_SETTINGS := $(shell uvx repoplone settings dump)

PROJECT_NAME := $(shell echo '$(REPOSITORY_SETTINGS)' | jq -r '.name')
STACK_NAME=pythonbrasil-pybr25-site

VOLTO_VERSION=$(shell cat frontend/mrs.developer.json | python -c "import sys, json; print(json.load(sys.stdin)['core']['tag'])")
PLONE_VERSION=$(shell cat backend/version.txt)
VOLTO_VERSION := $(shell echo '$(REPOSITORY_SETTINGS)' | jq -r '.frontend.volto_version')
PLONE_VERSION := $(shell echo '$(REPOSITORY_SETTINGS)' | jq -r '.backend.base_package_version')
IMAGE_PREFIX := $(shell echo '$(REPOSITORY_SETTINGS)' | jq -r '.container_images_prefix')

# We like colors
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
Expand All @@ -35,6 +36,13 @@ all: install
help: ## This help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: debug-settings
debug-settings: ## Debug settings
@echo "Debug settings"
@echo "PROJECT_NAME: $(PROJECT_NAME)"
@echo "VOLTO_VERSION: $(VOLTO_VERSION)"
@echo "PLONE_VERSION: $(PLONE_VERSION)"

###########################################
# Frontend
###########################################
Expand Down Expand Up @@ -110,7 +118,7 @@ format: ## Format codebase

.PHONY: lint
lint: ## Format codebase
@echo "Lint the codebasecodebase"
@echo "Lint the codebase"
$(MAKE) -C "./backend/" lint
$(MAKE) -C "./frontend/" lint

Expand Down Expand Up @@ -144,31 +152,32 @@ build-images: ## Build container images
###########################################
# Local Stack
###########################################
.PHONY: stack-start
stack-start: ## Local Stack: Start Services
@echo "Start local Docker stack"
VOLTO_VERSION=$(VOLTO_VERSION) PLONE_VERSION=$(PLONE_VERSION) docker compose -f $(STACK_FILE) up -d --build
@echo "Now visit: http://pybr25-site.localhost"

.PHONY: stack-create-site
stack-create-site: ## Local Stack: Create a new site
@echo "Create a new site in the local Docker stack"
VOLTO_VERSION=$(VOLTO_VERSION) PLONE_VERSION=$(PLONE_VERSION) docker compose -f $(STACK_FILE) exec backend ./docker-entrypoint.sh create-site
@echo "(Stack must not be running already.)"
VOLTO_VERSION=$(VOLTO_VERSION) PLONE_VERSION=$(PLONE_VERSION) docker compose -f docker-compose.yml run --build backend ./docker-entrypoint.sh create-site

.PHONY: stack-start
stack-start: ## Local Stack: Start Services
@echo "Start local Docker stack"
VOLTO_VERSION=$(VOLTO_VERSION) PLONE_VERSION=$(PLONE_VERSION) docker compose -f docker-compose.yml up -d --build
@echo "Now visit: http://pybr25.localhost"

.PHONY: stack-status
stack-status: ## Local Stack: Check Status
@echo "Check the status of the local Docker stack"
@docker compose -f $(STACK_FILE) ps
@docker compose -f docker-compose.yml ps

.PHONY: stack-stop
stack-stop: ## Local Stack: Stop Services
@echo "Stop local Docker stack"
@docker compose -f $(STACK_FILE) stop
@docker compose -f docker-compose.yml stop

.PHONY: stack-rm
stack-rm: ## Local Stack: Remove Services and Volumes
@echo "Remove local Docker stack"
@docker compose -f $(STACK_FILE) down
@docker compose -f docker-compose.yml down
@echo "Remove local volume data"
@docker volume rm $(PROJECT_NAME)_vol-site-data

Expand All @@ -194,12 +203,12 @@ acceptance-test:
.PHONY: acceptance-frontend-image-build
acceptance-frontend-image-build:
@echo "Build acceptance frontend image"
@docker build frontend -t pythonbrasil/pybr25-site-frontend:acceptance -f frontend/Dockerfile --build-arg VOLTO_VERSION=$(VOLTO_VERSION)
@docker build frontend -t $(IMAGE_PREFIX)-frontend:acceptance -f frontend/Dockerfile --build-arg VOLTO_VERSION=$(VOLTO_VERSION)

.PHONY: acceptance-backend-image-build
acceptance-backend-image-build:
@echo "Build acceptance backend image"
@docker build backend -t pythonbrasil/pybr25-site-backend:acceptance -f backend/Dockerfile.acceptance --build-arg PLONE_VERSION=$(PLONE_VERSION)
@docker build backend -t $(IMAGE_PREFIX)-backend:acceptance -f backend/Dockerfile.acceptance --build-arg PLONE_VERSION=$(PLONE_VERSION)

.PHONY: acceptance-images-build
acceptance-images-build: ## Build Acceptance frontend/backend images
Expand All @@ -209,12 +218,12 @@ acceptance-images-build: ## Build Acceptance frontend/backend images
.PHONY: acceptance-frontend-container-start
acceptance-frontend-container-start:
@echo "Start acceptance frontend"
@docker run --rm -p 3000:3000 --name pybr25-site-frontend-acceptance --link pybr25-site-backend-acceptance:backend -e RAZZLE_API_PATH=http://localhost:55001/plone -e RAZZLE_INTERNAL_API_PATH=http://backend:55001/plone -d pythonbrasil/pybr25-site-frontend:acceptance
@docker run --rm -p 3000:3000 --name pybr25-frontend-acceptance --link pybr25-backend-acceptance:backend -e RAZZLE_API_PATH=http://localhost:55001/plone -e RAZZLE_INTERNAL_API_PATH=http://backend:55001/plone -d $(IMAGE_PREFIX)-frontend:acceptance

.PHONY: acceptance-backend-container-start
acceptance-backend-container-start:
@echo "Start acceptance backend"
@docker run --rm -p 55001:55001 --name pybr25-site-backend-acceptance -d pythonbrasil/pybr25-site-backend:acceptance
@docker run --rm -p 55001:55001 --name pybr25-backend-acceptance -d $(IMAGE_PREFIX)-backend:acceptance

.PHONY: acceptance-containers-start
acceptance-containers-start: ## Start Acceptance containers
Expand All @@ -224,8 +233,8 @@ acceptance-containers-start: ## Start Acceptance containers
.PHONY: acceptance-containers-stop
acceptance-containers-stop: ## Stop Acceptance containers
@echo "Stop acceptance containers"
@docker stop pybr25-site-frontend-acceptance
@docker stop pybr25-site-backend-acceptance
@docker stop pybr25-frontend-acceptance
@docker stop pybr25-backend-acceptance

.PHONY: ci-acceptance-test
ci-acceptance-test:
Expand Down
44 changes: 27 additions & 17 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
YELLOW=`tput setaf 3`

IMAGE_NAME_PREFIX=ghcr.io/pythonbrasil/pybr25-site
IMAGE_TAG=latest

# Python checks
UV?=uv

Expand All @@ -26,12 +22,19 @@ ifeq (, $(shell which $(UV) ))
$(error "UV=$(UV) not found in $(PATH)")
endif

REPOSITORY_SETTINGS := $(shell uvx repoplone settings dump)
IMAGE_NAME_PREFIX := $(shell echo '$(REPOSITORY_SETTINGS)' | jq -r '.container_images_prefix')

IMAGE_TAG=latest
IMAGE_NAME=$(IMAGE_NAME_PREFIX)-backend:$(IMAGE_TAG)
PLONE_SITE_ID=Plone
BACKEND_FOLDER=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
PLONE_VERSION=$(shell cat $(BACKEND_FOLDER)/version.txt)
EXAMPLE_CONTENT_FOLDER=${BACKEND_FOLDER}/src/pythonbrasil/site/setuphandlers/examplecontent
PLONE_VERSION := $(shell echo '$(REPOSITORY_SETTINGS)' | jq -r '.backend.base_package_version')
EXAMPLE_CONTENT_FOLDER := $(shell echo '$(REPOSITORY_SETTINGS)' | jq -r '.backend.code_path')/setuphandlers/examplecontent
PACKAGE_NAME := $(shell echo '$(REPOSITORY_SETTINGS)' | jq -r '.backend.name')

VENV_FOLDER=$(BACKEND_FOLDER)/.venv
export VIRTUAL_ENV=$(VENV_FOLDER)
BIN_FOLDER=$(VENV_FOLDER)/bin

# Environment variables to be exported
Expand All @@ -46,25 +49,31 @@ all: build
help: ## This help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

$(VENV_FOLDER): ## Install dependencies
@echo "$(GREEN)==> Install environment$(RESET)"
@uv sync
.PHONY: debug-settings
debug-settings: ## Debug settings
@echo "PLONE_VERSION: $(PLONE_VERSION)"
@echo "EXAMPLE_CONTENT_FOLDER: $(EXAMPLE_CONTENT_FOLDER)"

.PHONY: update-constraints
update-constraints: ## Update backend constraints
@echo "$(GREEN)==> Update backend constraints$(RESET)"
@uvx repoplone deps constraints

.PHONY: sync
sync: $(VENV_FOLDER) ## Sync project dependencies
sync: update-constraints ## Sync project dependencies
@echo "$(GREEN)==> Sync project dependencies$(RESET)"
@uv sync

.PHONY: install
install: sync config ## Install Plone and dependencies

instance/etc/zope.ini instance/etc/zope.conf: instance.yaml ## Create instance configuration
@echo "$(GREEN)==> Create instance configuration$(RESET)"
@uvx cookiecutter -f --no-input -c 2.1.1 --config-file instance.yaml gh:plone/cookiecutter-zope-instance

.PHONY: config
config: instance/etc/zope.ini

.PHONY: install
install: $(VENV_FOLDER) config ## Install Plone and dependencies

.PHONY: clean
clean: ## Clean installation and instance
@echo "$(RED)==> Cleaning environment and build$(RESET)"
Expand Down Expand Up @@ -114,7 +123,7 @@ format: ## Check and fix code base according to Plone standards
.PHONY: i18n
i18n: $(VENV_FOLDER) ## Update locales
@echo "$(GREEN)==> Updating locales$(RESET)"
@uv run python -m pythonbrasil.site.locales
@uv run python -m $(PACKAGE_NAME).locales

# Tests
.PHONY: test
Expand All @@ -123,17 +132,18 @@ test: $(VENV_FOLDER) ## run tests

.PHONY: test-coverage
test-coverage: $(VENV_FOLDER) ## run tests with coverage
@uv run pytest --cov=pythonbrasil.site --cov-report term-missing
@uv run pytest --cov=$(PACKAGE_NAME) --cov-report term-missing

# Build Docker images
.PHONY: build-image
build-image: ## Build Docker Images
@docker build . -t $(IMAGE_NAME_PREFIX)-backend:$(IMAGE_TAG) -f Dockerfile --build-arg PLONE_VERSION=$(PLONE_VERSION)
@echo "$(GREEN)==> Building image $(IMAGE_NAME) $(RESET)"
@docker build . -t $(IMAGE_NAME) --progress plain -f Dockerfile

# Acceptance tests
.PHONY: acceptance-backend-start
acceptance-backend-start: ## Start backend acceptance server
ZSERVER_HOST=0.0.0.0 ZSERVER_PORT=55001 LISTEN_PORT=55001 APPLY_PROFILES="pythonbrasil.site:default" CONFIGURE_PACKAGES="plone.restapi,plone.volto,plone.volto.cors,pythonbrasil.site" $(BIN_FOLDER)/robot-server plone.app.robotframework.testing.VOLTO_ROBOT_TESTING
ZSERVER_HOST=0.0.0.0 ZSERVER_PORT=55001 LISTEN_PORT=55001 APPLY_PROFILES="pybr25.core:default" CONFIGURE_PACKAGES="plone.restapi,plone.volto,plone.volto.cors,pybr25.core" $(BIN_FOLDER)/robot-server plone.app.robotframework.testing.VOLTO_ROBOT_TESTING

.PHONY: acceptance-image-build
acceptance-image-build: ## Build Docker Images
Expand Down
1 change: 1 addition & 0 deletions backend/news/+make.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Atualiza Makefile para uso do repoplone. @ericof
1 change: 1 addition & 0 deletions backend/news/+plone.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Atualiza Plone para versão 6.1.3. @ericof
1 change: 1 addition & 0 deletions backend/news/+socialmedia.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Atualiza plonegovbr.socialmedia para 2.0.0a10. @ericof
1 change: 1 addition & 0 deletions backend/news/+techevent.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Atualiza collective.techevent para versão 1.0.0b1. @ericof
Loading
Loading