diff --git a/.github/renovate.json5 b/.github/renovate.json5 new file mode 100644 index 0000000..d9a8bcb --- /dev/null +++ b/.github/renovate.json5 @@ -0,0 +1,23 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "enabledManagers": ["custom.regex"], + "timezone": "America/Sao_Paulo", + "customManagers": [ + { + "customType": "regex", + "managerFilePatterns": ["/^docker-compose\\.saas\\.yml$/"], + "matchStrings": [ + "version=(?v\\d+\\.\\d+\\.\\d+) pin=(?[0-9a-f]{40});.*? fetch -q (?https:\\/\\/\\S+?\\.git) " + ], + "datasourceTemplate": "git-tags", + "depNameTemplate": "{{{replace '^.*/(.+)\\.git$' '$1' packageName}}}", + "versioningTemplate": "semver-coerced" + } + ], + "packageRules": [ + { + "matchManagers": ["custom.regex"], + "schedule": ["* * * * 1"] + } + ] +} diff --git a/README.md b/README.md index 2ec285a..d17863d 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,13 @@ 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. +The site, the Nextcloud apps and the LibreSign WordPress plugins and theme follow +the `main` branch of their repositories. Polylang Pro and WooCommerce +Subscriptions come from third-party mirrors, so `docker-compose.saas.yml` pins +them to the commit of a release tag (`version=` and `pin=`). Renovate +(`.github/renovate.json5`) checks the mirrors on Mondays and opens a pull request +when a new release is tagged. + On a fresh WordPress database, `make up` also performs the initial WordPress installation via WP-CLI and restarts the WordPress container once so the `wordpress-docker` entrypoint can install the configured plugins and themes. diff --git a/docker-compose.saas.yml b/docker-compose.saas.yml index 49db4e8..fdfe496 100644 --- a/docker-compose.saas.yml +++ b/docker-compose.saas.yml @@ -29,6 +29,7 @@ services: - slug: polylang-pro source: https://gitlab.com/wordpress-premium/polylang-pro post_install_commands: + - version=v3.7.6 pin=851df56e647a4c19450d69ddff9c77aa67963a0d; [ "$$(git -C "$$PLUGIN_DIR" rev-parse HEAD)" = "$$pin" ] || { git -C "$$PLUGIN_DIR" fetch -q https://gitlab.com/wordpress-premium/polylang-pro.git "$$pin" && git -C "$$PLUGIN_DIR" checkout -q FETCH_HEAD; } || echo "Could not check out $$PLUGIN_DIR at $$version ($$pin), keeping the current commit" >&2 - 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 @@ -54,6 +55,9 @@ services: source: https://github.com/LibreSign/woocommerce-restrict-switch.git - slug: woocommerce-subscriptions source: https://github.com/pronamic/woocommerce-subscriptions.git + post_install_commands: + - version=v9.4.1 pin=2459d9c8662884d62b9a92221eb21c7c6c051a62; [ "$$(git -C "$$PLUGIN_DIR" rev-parse HEAD)" = "$$pin" ] || { git -C "$$PLUGIN_DIR" fetch -q https://github.com/pronamic/woocommerce-subscriptions.git "$$pin" && git -C "$$PLUGIN_DIR" checkout -q FETCH_HEAD; } || echo "Could not check out $$PLUGIN_DIR at $$version ($$pin), keeping the current commit" >&2 + - wp option update woocommerce_subscriptions_apportion_recurring_price yes-upgrade wordpress_custom_themes: - slug: libresign source: https://github.com/LibreSign/wordpress-theme.git diff --git a/tests/E2E/PlanChange.spec.ts b/tests/E2E/PlanChange.spec.ts index 8e40bb8..2cae28a 100644 --- a/tests/E2E/PlanChange.spec.ts +++ b/tests/E2E/PlanChange.spec.ts @@ -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; @@ -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 ); @@ -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 ); diff --git a/tests/E2E/support/seed.php b/tests/E2E/support/seed.php index 9098382..304fa94 100644 --- a/tests/E2E/support/seed.php +++ b/tests/E2E/support/seed.php @@ -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', diff --git a/tests/E2E/support/wordpress.ts b/tests/E2E/support/wordpress.ts index aeb54fa..6528081 100644 --- a/tests/E2E/support/wordpress.ts +++ b/tests/E2E/support/wordpress.ts @@ -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' ) ) {