Skip to content
Closed
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
59 changes: 59 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"enabledManagers": ["custom.regex"],
"timezone": "America/Sao_Paulo",
"customManagers": [
{
"customType": "regex",
"managerFilePatterns": ["/^Makefile$/"],
"matchStrings": ["SITE_REPO_REF \\?= (?<currentDigest>[0-9a-f]{40})"],
"datasourceTemplate": "git-refs",
"depNameTemplate": "site",
"packageNameTemplate": "https://github.com/LibreSign/site.git",
"currentValueTemplate": "main"
},
{
"customType": "regex",
"managerFilePatterns": ["/^Makefile$/"],
"matchStrings": ["ADMIN_GROUP_MANAGER_REF \\?= (?<currentDigest>[0-9a-f]{40})"],
"datasourceTemplate": "git-refs",
"depNameTemplate": "admin_group_manager",
"packageNameTemplate": "https://github.com/LibreSign/admin_group_manager.git",
"currentValueTemplate": "main"
},
{
"customType": "regex",
"managerFilePatterns": ["/^Makefile$/"],
"matchStrings": ["WORDPRESS_LOGIN_BACKEND_REF \\?= (?<currentDigest>[0-9a-f]{40})"],
"datasourceTemplate": "git-refs",
"depNameTemplate": "wordpress_login_backend",
"packageNameTemplate": "https://github.com/LibreSign/wordpress_login_backend.git",
"currentValueTemplate": "main"
},
{
"customType": "regex",
"managerFilePatterns": ["/^tests\\/E2E\\/support\\/nextcloud-setup\\.sh$/"],
"matchStrings": ["download_app (?<depName>[a-z_]+) (?<currentDigest>[0-9a-f]{40})"],
"datasourceTemplate": "git-refs",
"packageNameTemplate": "https://github.com/LibreSign/{{{depName}}}.git",
"currentValueTemplate": "main"
},
{
"customType": "regex",
"managerFilePatterns": ["/^docker-compose\\.saas\\.yml$/"],
"matchStrings": [
"- slug: (?<depName>\\S+)\\n\\s+source: (?<packageName>\\S+)\\n\\s+post_install_commands:\\n\\s+- git -C \"\\$\\$PLUGIN_DIR\" fetch -q origin (?<currentDigest>[0-9a-f]{40})",
"git clone -q (?<packageName>\\S+) wp-content/themes/(?<depName>[a-z-]+); fi\\n\\s+- git -C \"wp-content/themes/[a-z-]+\" fetch -q origin (?<currentDigest>[0-9a-f]{40})"
],
"datasourceTemplate": "git-refs",
"currentValueTemplate": "{{#if (containsString packageName 'gitlab.com/wordpress-premium/')}}master{{else}}main{{/if}}"
}
],
"packageRules": [
{
"matchDatasources": ["git-refs"],
"groupName": "pinned components",
"schedule": ["* * * * 1"]
}
]
}
22 changes: 12 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ SITE_DIR := $(ROOT_DIR)/site
SITE_NPM_CACHE_DIR ?= $(ROOT_DIR)/.cache/site-npm
SITE_COMPOSER_HOME_DIR ?= $(ROOT_DIR)/.cache/site-composer
SITE_REPO_URL ?= https://github.com/LibreSign/site.git
SITE_REPO_BRANCH ?= main
SITE_REPO_REF ?= c1b338ed9ef581c8166073d332b7a028dfdcd6fa
ADMIN_GROUP_MANAGER_REF ?= 826b04a5364a03495da8bdfed8416eca1284a21b
WORDPRESS_LOGIN_BACKEND_REF ?= eab143d586b2331329d406ef4460734499fb66c4
SITE_HTTP_PORT ?= 8081
SITE_BROWSERSYNC_PORT ?= 3000
SITE_SERVER_MODE ?= build
Expand Down Expand Up @@ -77,6 +79,9 @@ _help:
@echo " SITE_HTTP_PORT - Static site port (default: 8081)"
@echo " SITE_BROWSERSYNC_PORT - Static site HMR port (default: 3000)"
@echo " SITE_SERVER_MODE - Static site container mode for make up (default: build)"
@echo " SITE_REPO_REF - Commit of the static site checked out by make up"
@echo " ADMIN_GROUP_MANAGER_REF - Commit of admin_group_manager checked out by make up"
@echo " WORDPRESS_LOGIN_BACKEND_REF - Commit of wordpress_login_backend checked out by make up"
@echo " WORDPRESS_HTTP_PORT - WordPress port (default: 8080)"
@echo " NEXTCLOUD_HOST - Nextcloud hostname behind the shared proxy (default: nextcloud-development.localhost)"
@echo " NEXTCLOUD_PROTOCOL - Nextcloud protocol behind the shared proxy (default: https)"
Expand Down Expand Up @@ -153,9 +158,8 @@ _ensure-site-repo:
git clone "$(SITE_REPO_URL)" "$(SITE_DIR)"; \
fi
@git -C "$(SITE_DIR)" remote set-url origin "$(SITE_REPO_URL)"
@git -C "$(SITE_DIR)" fetch origin "$(SITE_REPO_BRANCH)"
@git -C "$(SITE_DIR)" checkout "$(SITE_REPO_BRANCH)"
@git -C "$(SITE_DIR)" pull --ff-only origin "$(SITE_REPO_BRANCH)"
@git -C "$(SITE_DIR)" fetch origin
@git -C "$(SITE_DIR)" checkout -q "$(SITE_REPO_REF)"

_prepare-site-output-dir:
@echo "Preparing site output directory and caches..."
Expand Down Expand Up @@ -286,18 +290,16 @@ _ensure-wordpress-app:
@if [ ! -d "$(NEXTCLOUD_APPS_DIR)/wordpress_login_backend/.git" ]; then \
git clone https://github.com/LibreSign/wordpress_login_backend.git $(NEXTCLOUD_APPS_DIR)/wordpress_login_backend; \
fi
@git -C $(NEXTCLOUD_APPS_DIR)/wordpress_login_backend fetch origin main
@git -C $(NEXTCLOUD_APPS_DIR)/wordpress_login_backend checkout main
@git -C $(NEXTCLOUD_APPS_DIR)/wordpress_login_backend pull --ff-only origin main
@git -C $(NEXTCLOUD_APPS_DIR)/wordpress_login_backend fetch origin
@git -C $(NEXTCLOUD_APPS_DIR)/wordpress_login_backend checkout -q $(WORDPRESS_LOGIN_BACKEND_REF)

_ensure-nextcloud-app:
@echo "Setting up admin_group_manager app..."
@if [ ! -d "$(NEXTCLOUD_APPS_DIR)/admin_group_manager/.git" ]; then \
git clone https://github.com/LibreSign/admin_group_manager.git $(NEXTCLOUD_APPS_DIR)/admin_group_manager; \
fi
@git -C $(NEXTCLOUD_APPS_DIR)/admin_group_manager fetch origin main
@git -C $(NEXTCLOUD_APPS_DIR)/admin_group_manager checkout main
@git -C $(NEXTCLOUD_APPS_DIR)/admin_group_manager pull --ff-only origin main
@git -C $(NEXTCLOUD_APPS_DIR)/admin_group_manager fetch origin
@git -C $(NEXTCLOUD_APPS_DIR)/admin_group_manager checkout -q $(ADMIN_GROUP_MANAGER_REF)

_enable-apps:
@echo "Enabling apps..."
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ These caches are ignored by Git.

The static site (`site/`) is a regular cloned repository managed by
`make up`. On the first run, the Makefile clones `https://github.com/LibreSign/site.git`
automatically and checks out `main`.
automatically and checks out the commit set in `SITE_REPO_REF`.

Then start the stack:

Expand Down Expand Up @@ -112,8 +112,18 @@ URL by `make up`.
`make up` refreshes the remote Docker images used by the WordPress, static site,
and Nextcloud services and rebuilds local buildable services before starting the
stack. During `make up site`, the `site/` clone is also synced from
`https://github.com/LibreSign/site.git` (`main`) automatically, so no manual
site update step is required.
`https://github.com/LibreSign/site.git` and checked out at `SITE_REPO_REF`
automatically, so no manual site update step is required.

Every component cloned at runtime is pinned to a commit: the Nextcloud apps and
the static site through the `*_REF` variables of the `Makefile`, and the
WordPress plugins and theme through the `post_install_commands` in
`docker-compose.saas.yml`. The end-to-end suite downloads the same Nextcloud app
commits in `tests/E2E/support/nextcloud-setup.sh`.

Renovate (`.github/renovate.json5`) follows the branch each component is
released from and, on Mondays, opens a single pull request that bumps every
commit that moved, so the CI runs the new versions before they reach the stack.

On a fresh WordPress database, `make up` also performs the initial WordPress
installation via WP-CLI and restarts the WordPress container once so the
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.saas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ services:
- slug: polylang-pro
source: https://gitlab.com/wordpress-premium/polylang-pro
post_install_commands:
- git -C "$$PLUGIN_DIR" fetch -q origin 851df56e647a4c19450d69ddff9c77aa67963a0d && git -C "$$PLUGIN_DIR" checkout -q FETCH_HEAD
- if [ ! -L "$$PLUGIN_DIR/integrations/ACF" ]; then rm -rf "$$PLUGIN_DIR/integrations/ACF" && ln -s acf "$$PLUGIN_DIR/integrations/ACF"; fi || true
- slug: libresign-wp-customizations
source: https://github.com/LibreSign/libresign-wp-customizations.git
post_install_commands:
- git -C "$$PLUGIN_DIR" fetch -q origin f2bf08e53013e46ca586ab53d90fc7eec9267600 && git -C "$$PLUGIN_DIR" checkout -q FETCH_HEAD
- if [ ! -d wp-content/themes/libresign ]; then git clone -q https://github.com/LibreSign/wordpress-theme.git wp-content/themes/libresign; fi
- git -C "wp-content/themes/libresign" fetch -q origin 387d02d5622fa6fc90a3c2713ef0d6cd7d0ed846 && git -C "wp-content/themes/libresign" checkout -q FETCH_HEAD
- slug: wp-simple-smtp
source: https://github.com/LibreCodeCoop/wp-simple-smtp.git
post_install_commands:
- git -C "$$PLUGIN_DIR" fetch -q origin 24729b5a34d8c67584b2c2608285d499866b2b25 && git -C "$$PLUGIN_DIR" checkout -q FETCH_HEAD
- wp option update smtp_xmailer LibreSign
- wp option update smtp_hostname localhost
- wp option update smtp_host mailpit
Expand All @@ -48,12 +54,18 @@ services:
- slug: woocommerce-nextcloud-admin-group-manager
source: https://github.com/LibreSign/woocommerce-nextcloud-admin-group-manager.git
post_install_commands:
- git -C "$$PLUGIN_DIR" fetch -q origin 4f4eb83b61bb423a2b730a552a604a33ab3c344d && git -C "$$PLUGIN_DIR" checkout -q FETCH_HEAD
- wp option update nextcloud_api_login ${NEXTCLOUD_ADMIN_USER:-admin}
- wp option update nextcloud_api_password ${NEXTCLOUD_ADMIN_PASSWORD:-admin}
- slug: woocommerce-restrict-switch
source: https://github.com/LibreSign/woocommerce-restrict-switch.git
post_install_commands:
- git -C "$$PLUGIN_DIR" fetch -q origin c524fbf18447b61abdd93d9f5ffd379169242bb1 && git -C "$$PLUGIN_DIR" checkout -q FETCH_HEAD
- slug: woocommerce-subscriptions
source: https://github.com/pronamic/woocommerce-subscriptions.git
post_install_commands:
- git -C "$$PLUGIN_DIR" fetch -q origin 2459d9c8662884d62b9a92221eb21c7c6c051a62 && git -C "$$PLUGIN_DIR" checkout -q FETCH_HEAD
- wp option update woocommerce_subscriptions_apportion_recurring_price yes-upgrade
wordpress_custom_themes:
- slug: libresign
source: https://github.com/LibreSign/wordpress-theme.git
Expand Down
6 changes: 4 additions & 2 deletions tests/E2E/PlanChange.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test';

import { nextcloud } from './support/nextcloud';
import { agreeToTheTerms, aSubscriber, logInToTheStore, placeTheOrder, plansInTheStore, STORE_URL } from './support/store';
import { subscriptionStatus } from './support/wordpress';
import { orderTotal, subscriptionStatus } from './support/wordpress';

const GIGABYTE = 1024 ** 3;

Expand All @@ -23,7 +23,7 @@ test.describe( 'Changing plan', () => {
await expect( page.getByRole( 'link', { name: 'Professional', exact: true } ) ).toHaveCount( 0 );
} );

test( 'upgrading from Basic to Enterprise raises the workspace storage to 800 GB', async ( { browser, page } ) => {
test( 'upgrading from Basic to Enterprise charges the prorated difference and raises the workspace storage to 800 GB', async ( { browser, page } ) => {
const { customer, subscriptionId } = await aSubscriber( page, 'Nilo' );
await logInToTheStore( page, customer.email, customer.password );

Expand All @@ -37,6 +37,8 @@ test.describe( 'Changing plan', () => {
await page.getByRole( 'button', { name: 'Switch subscription' } ).click();
await expect( page ).toHaveURL( /\/checkout\/order-received\/\d+\//, { timeout: 90_000 } );

const switchOrderId = Number( page.url().match( /order-received\/(\d+)\// )![ 1 ] );
expect( orderTotal( switchOrderId ) ).toBeGreaterThan( 0 );
expect( subscriptionStatus( subscriptionId ) ).toBe( 'active' );
expect( await nextcloud.account( customer.email ) ).toMatchObject( { enabled: true, quota: { quota: 800 * GIGABYTE } } );
await nextcloud.expectToLogIn( browser, customer.email, customer.password );
Expand Down
11 changes: 7 additions & 4 deletions tests/E2E/support/nextcloud-setup.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/sh
set -e

for app in admin_group_manager wordpress_login_backend; do
mkdir -p "custom_apps/$app"
curl -fsSL "https://github.com/LibreSign/$app/archive/refs/heads/main.tar.gz" | tar -xz --strip-components=1 -C "custom_apps/$app"
done
download_app() {
mkdir -p "custom_apps/$1"
curl -fsSL "https://github.com/LibreSign/$1/archive/$2.tar.gz" | tar -xz --strip-components=1 -C "custom_apps/$1"
}

download_app admin_group_manager 826b04a5364a03495da8bdfed8416eca1284a21b
download_app wordpress_login_backend eab143d586b2331329d406ef4460734499fb66c4

php occ app:install groupquota --force --keep-disabled
php occ app:enable wordpress_login_backend
Expand Down
1 change: 0 additions & 1 deletion tests/E2E/support/seed.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
'woocommerce_email_from_name' => 'LibreSign',
'woocommerce_email_from_address' => 'noreply@example.com',
'woocommerce_subscriptions_allow_switching' => 'grouped',
'woocommerce_subscriptions_apportion_recurring_price' => 'no',
'woocommerce_subscriptions_enable_early_renewal' => 'yes',
'woocommerce_subscriptions_enable_retry' => 'no',
'woocommerce_subscriptions_multiple_purchase' => 'yes',
Expand Down
4 changes: 4 additions & 0 deletions tests/E2E/support/wordpress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export function orderStatus( orderId: number ): string {
return wpEval( `echo wc_get_order( ${ orderId } )->get_status();` );
}

export function orderTotal( orderId: number ): number {
return Number( wpEval( `echo wc_get_order( ${ orderId } )->get_total();` ) );
}

export function runTheScheduledNextcloudSyncRetry( orderId: number ): void {
wpEval( `
if ( ! as_next_scheduled_action( 'agm_retry_nextcloud_sync', array( 'order_id' => ${ orderId } ), 'nextcloud-admin-group-manager' ) ) {
Expand Down
Loading