Skip to content

fix(ui): nest special-use mailboxes below their ordinary parents #23885

fix(ui): nest special-use mailboxes below their ordinary parents

fix(ui): nest special-use mailboxes below their ordinary parents #23885

Workflow file for this run

# SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT
name: Test
on: pull_request
permissions:
contents: read
concurrency:
group: test-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
E2E_NODE_VERSION: "20"
STALWART_PWD: "secretpassword"
# Must satisfy Stalwart's default zxcvbn password policy and match JmapTestAccount
STALWART_USER_PWD: "violet-harbor-cactus-lantern"
jobs:
changes:
runs-on: ubuntu-latest-low
permissions:
contents: read
pull-requests: read
outputs:
backend: ${{ steps.changes.outputs.backend }}
frontend: ${{ steps.changes.outputs.frontend }}
steps:
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: changes
continue-on-error: true
with:
filters: |
backend:
- '.github/workflows/**'
- 'appinfo/**'
- 'lib/**'
- 'templates/**'
- 'tests/**'
- 'vendor/**'
- 'vendor-bin/**'
- 'composer/**'
- 'composer.json'
- 'composer.lock'
- '.patches/**'
- 'patches.json'
- 'patches.lock.json'
- 'resources/**'
- 'img/**'
frontend:
- '.github/workflows/**'
- 'src/**'
- 'package.json'
- 'package-lock.json'
- 'tsconfig.json'
- 'vitest.config.js'
- 'babel.config.js'
- 'webpack.*.js'
- 'playwright.config.js'
- 'css/**'
- 'img/**'
unit-tests:
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.backend != 'false'
strategy:
matrix:
php-versions: ['8.5']
nextcloud-versions: ['master']
include:
- php-versions: '8.4'
nextcloud-versions: 'master'
coverage: true
- php-versions: '8.2'
nextcloud-versions: 'stable33'
- php-versions: '8.3'
nextcloud-versions: 'stable34'
- php-versions: '8.4'
nextcloud-versions: 'stable35'
name: Nextcloud ${{ matrix.nextcloud-versions }} php${{ matrix.php-versions }} unit tests ${{ matrix.coverage && '(coverage)' || ''}}
steps:
- name: Set up Nextcloud env
uses: nextcloud/setup-server-action@34b73d5b0e3633f83a52227d00cc2a6c41d01d9a # v1.0.0
with:
nextcloud-version: ${{ matrix.nextcloud-versions }}
php-version: ${{ matrix.php-versions }}
php-coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
patch-php-version-check: ${{ matrix.php-versions == '8.6' }}
node-version: 'false'
install: true
- name: Checkout Mail
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: nextcloud/apps/mail
fetch-depth: 2
- name: Install dependencies
working-directory: nextcloud/apps/mail
run: composer install
- name: Run tests
working-directory: nextcloud/apps/mail
run: composer run test:unit
env:
XDEBUG_MODE: ${{ matrix.coverage && 'coverage' || 'off' }}
- name: Report coverage
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
if: ${{ !cancelled() && matrix.coverage }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
working-directory: nextcloud/apps/mail
files: tests/clover.unit.xml
flags: unittests
fail_ci_if_error: ${{ !github.event.pull_request.head.repo.fork }}
verbose: true
integration-tests:
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.backend != 'false'
strategy:
matrix:
php-versions: ['8.4']
nextcloud-versions: ['master']
db: ['sqlite', 'mysql', 'pgsql']
cache: ['nocache']
include:
- php-versions: 8.4
nextcloud-versions: 'master'
db: 'mysql'
cache: 'nocache'
coverage: true
- php-versions: 8.2
nextcloud-versions: 'stable33'
db: 'sqlite'
cache: 'redis'
- php-versions: 8.4
nextcloud-versions: 'stable33'
db: 'mysql'
cache: 'redis'
coverage: true
- php-versions: 8.4
nextcloud-versions: 'stable34'
db: 'mysql'
cache: 'redis'
- php-versions: 8.5
nextcloud-versions: 'stable35'
db: 'mysql'
cache: 'redis'
- php-versions: 8.5
nextcloud-versions: 'master'
db: 'mysql'
cache: 'redis'
name: ${{ matrix.nextcloud-versions }} w/ php${{ matrix.php-versions }}-${{ matrix.db }}-${{ matrix.cache }} integration tests ${{ matrix.coverage && '(coverage)' || ''}}
services:
mail-dovecot-service:
image: ghcr.io/christophwurst/docker-imap-devel:latest@sha256:b76a062268d7342ccec549f5323a0b6dc1b6ac55b03367f474934927653f5cb5
env:
MAILNAME: mail.domain.tld
MAIL_ADDRESS: user@domain.tld
MAIL_PASS: mypassword
ports:
- 25:25
- 143:143
- 993:993
- 4190:4190
mail-stalwart-service:
image: stalwartlabs/stalwart:v1.1.0
env:
STALWART_RECOVERY_ADMIN: admin:${{ env.STALWART_PWD }}
# Base URL of the published JMAP discovery URLs (apiUrl/downloadUrl/uploadUrl),
# otherwise https://<defaultHostname> on port 443
STALWART_PUBLIC_URL: http://stalwart:8080
# Pin a stable container hostname so the runner can map it to loopback
# via /etc/hosts and reach the advertised http://stalwart:8080/jmap/.
options: --hostname stalwart
ports:
- 8080:8080
- 10025:25
- 10143:143
- 10993:993
mariadb-service:
image: ghcr.io/nextcloud/continuous-integration-mariadb-11.8:latest@sha256:9232089007ddc49b42e5a7e4cc158ac373efebed6885ea0f76e3d4e5f8532bac
env:
MARIADB_ROOT_PASSWORD: my-secret-pw
MARIADB_DATABASE: nextcloud
MARIADB_USER: nextcloud
MARIADB_PASSWORD: nextcloud
ports:
- 3306:3306/tcp
options: >-
--health-cmd="mariadb-admin ping"
--health-interval=5s
--health-timeout=2s
--health-retries=5
postgres-service:
image: ghcr.io/nextcloud/continuous-integration-postgres-15:latest@sha256:1939108b31fd841cf01906c431c1802cd984fcfb0e57fb0d714b9e6895c340b0
env:
POSTGRES_USER: nextcloud
POSTGRES_DB: nextcloud
POSTGRES_PASSWORD: nextcloud
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: ghcr.io/nextcloud/continuous-integration-redis:latest@sha256:4ae220629fc544cd1396b35723137628a4cf7e5355b1d86649073f30249d7cbe
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Map Stalwart hostname to loopback
run: echo "127.0.0.1 stalwart" | sudo tee -a /etc/hosts
- name: Provision Stalwart
env:
STALWART_CONTAINER: ${{ job.services.mail-stalwart-service.id }}
run: |
set -euo pipefail
jmap() {
jq -nc --argjson call "$1" '{using: ["urn:ietf:params:jmap:core", "urn:stalwart:jmap"], methodCalls: [$call]}' \
| curl -sSf -u "admin:$STALWART_PWD" -H 'Content-Type: application/json' -d @- http://stalwart:8080/jmap/ \
| jq -e '.methodResponses[0] | if .[0] == "error" or ((.[1].notCreated // .[1].notUpdated // {}) | length > 0) then error(tojson) else .[1] end'
}
wait_for() {
timeout 120 sh -c "until curl -sf '$1' > /dev/null; do sleep 2; done"
}
# A fresh server starts in bootstrap mode and only accepts the Bootstrap object
wait_for http://stalwart:8080/healthz/live
jmap '["x:Bootstrap/set", {"update": {"singleton": {
"defaultHostname": "mail.example.com",
"defaultDomain": "example.com",
"requestTlsCertificate": false,
"generateDkimKeys": false,
"tracer": {"@type": "Stdout"}
}}}, "0"]'
# The configuration written by the bootstrap is only loaded on restart
docker restart "$STALWART_CONTAINER"
wait_for http://stalwart:8080/healthz/ready
domain_id=$(jmap '["x:Domain/query", {"filter": {"name": "example.com"}}, "0"]' | jq -er '.ids[0]')
jmap "$(jq -nc --arg domain "$domain_id" --arg pwd "$STALWART_USER_PWD" '["x:Account/set", {"create": {"u1": {
"@type": "User",
"name": "user",
"domainId": $domain,
"credentials": {"0": {"@type": "Password", "secret": $pwd}}
}}}, "0"]')"
- name: Set up Nextcloud env
uses: nextcloud/setup-server-action@34b73d5b0e3633f83a52227d00cc2a6c41d01d9a # v1.0.0
with:
nextcloud-version: ${{ matrix.nextcloud-versions }}
php-version: ${{ matrix.php-versions }}
php-coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
patch-php-version-check: ${{ matrix.php-versions == '8.5' }}
install: true
database: ${{ matrix.db }}
node-version: 'false'
- name: Configure caching
if: ${{ matrix.cache == 'redis' }}
run: |
php -f nextcloud/occ config:system:set memcache.local --value='\OC\Memcache\Redis'
php -f nextcloud/occ config:system:set memcache.distributed --value='\OC\Memcache\Redis'
- name: Checkout Mail
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: nextcloud/apps/mail
fetch-depth: 2
- name: Install dependencies
working-directory: nextcloud/apps/mail
run: composer install
- name: Patch version check for nightly PHP
if: ${{ matrix.php-versions == '8.6' }}
run: sed -i 's/max-version="8.5"/max-version="8.6"/' nextcloud/apps/mail/appinfo/info.xml
- name: Install Mail
run: php -f nextcloud/occ app:enable mail --force
- name: Configure Nextcloud for testing
run: |
php -f nextcloud/occ config:system:set app.mail.debug --type bool --value true
php -f nextcloud/occ config:system:set app.mail.verify-tls-peer --type bool --value false
php -f nextcloud/occ config:system:set allow_local_remote_servers --type bool --value true
- name: Enable slow mysql query logs
if: ${{ matrix.db == 'mysql' }}
run: |
echo "SET GLOBAL log_queries_not_using_indexes = 1;" | mysql -h 127.0.0.1 -u root -pmy-secret-pw
echo "SET GLOBAL slow_query_log=1;" | mysql -h 127.0.0.1 -u root -pmy-secret-pw
echo "SET GLOBAL log_output = 'table';" | mysql -h 127.0.0.1 -u root -pmy-secret-pw
- name: Run tests
working-directory: nextcloud/apps/mail
run: composer run test:integration
env:
XDEBUG_MODE: ${{ matrix.coverage && 'coverage' || 'off' }}
- name: Read slow queries
if: ${{ always() }}
run: echo "SELECT * FROM mysql.slow_log WHERE sql_text LIKE '%oc_mail%' AND sql_text NOT LIKE '%information_schema%'" | mysql -h 127.0.0.1 -u root -pmy-secret-pw
- name: Print debug logs
if: ${{ always() }}
run: cat nextcloud/data/mail-*-*-imap.log
- name: Print Stalwart logs
if: ${{ failure() }}
run: docker logs ${{ job.services.mail-stalwart-service.id }}
- name: Report coverage
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
if: ${{ !cancelled() && matrix.coverage }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
working-directory: nextcloud/apps/mail
files: tests/clover.integration.xml
flags: integrationtests
fail_ci_if_error: ${{ !github.event.pull_request.head.repo.fork }}
verbose: true
frontend-unit-test:
runs-on: ubuntu-24.04
needs: changes
if: needs.changes.outputs.frontend != 'false'
name: Front-end unit tests
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
id: versions
with:
fallbackNode: '^14'
fallbackNpm: '^7'
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
- name: npm install
run: npm install
- name: run tests
run: npm run test:unit
env:
CI: true
matrix:
runs-on: ubuntu-latest-low
needs: changes
if: needs.changes.outputs.backend != 'false' || needs.changes.outputs.frontend != 'false'
outputs:
php-min: ${{ steps.versions.outputs.php-min }}
branches-min: ${{ steps.versions.outputs.branches-min }}
steps:
- name: Checkout app
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Get version matrix
id: versions
uses: icewind1991/nextcloud-version-matrix@71959de73c244b11ecbf4503b87c41d65b0f64ae # v1.3.4
frontend-e2e-tests:
runs-on: ubuntu-latest
name: Front-end E2E tests
needs: [changes, matrix]
if: needs.changes.outputs.backend != 'false' || needs.changes.outputs.frontend != 'false'
steps:
- name: Set up Nextcloud env
uses: nextcloud/setup-server-action@34b73d5b0e3633f83a52227d00cc2a6c41d01d9a # v1.0.0
with:
nextcloud-version: ${{ needs.matrix.outputs.branches-min }}
php-version: ${{ needs.matrix.outputs.php-min }}
node-version: ${{ env.E2E_NODE_VERSION }}
install: true
- name: Configure Nextcloud for testing
run: |
php -f nextcloud/occ config:system:set debug --type=bool --value=true
php -f nextcloud/occ config:system:set overwriteprotocol --value=https
php -f nextcloud/occ config:system:set overwritehost --value=localhost
php -f nextcloud/occ config:system:set overwrite.cli.url --value=https://localhost
php -f nextcloud/occ config:system:set app.mail.debug --type=bool --value=true
php -f nextcloud/occ config:system:set app.mail.verify-tls-peer --type=bool --value=false
- name: Check out the app
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: nextcloud/apps/mail
- name: Install php dependencies
working-directory: nextcloud/apps/mail
run: composer install
- name: Install the app
run: php -f nextcloud/occ app:enable mail --force
- name: Set up node ${{ env.E2E_NODE_VERSION }}
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ env.E2E_NODE_VERSION }}
- name: Install npm dependencies
working-directory: nextcloud/apps/mail
run: npm ci
- name: Build frontend
working-directory: nextcloud/apps/mail
run: npm run build -- --fail-on-warnings
- name: Install stunnel (tiny https proxy)
run: sudo apt-get install -y stunnel
- name: Start php server and https proxy
working-directory: nextcloud
run: |
openssl req -new -x509 -days 365 -nodes -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=localhost" -out stunnel.pem -keyout stunnel.pem
php -S 127.0.0.1:8080 &
sudo stunnel3 -p stunnel.pem -d 443 -r 8080
- name: Test https access
run: curl --insecure -Li https://localhost
- name: Install Playwright browsers
working-directory: nextcloud/apps/mail
run: npx playwright install --with-deps chromium
- name: Run Playwright tests
working-directory: nextcloud/apps/mail
run: DEBUG=pw:api npx playwright test
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: always()
with:
name: playwright-report-${{ github.event.number }}-nc${{ needs.matrix.outputs.branches-min }}-php${{ needs.matrix.outputs.php-min }}-node${{ env.E2E_NODE_VERSION }}
path: nextcloud/apps/mail/playwright-report/
retention-days: 14
- name: Print server logs
if: always()
run: cat nextcloud/data/nextcloud.log*
env:
CI: true
codecov-empty:
runs-on: ubuntu-latest-low
needs: changes
if: needs.changes.outputs.backend == 'false'
name: codecov-empty-upload
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Send empty Codecov upload so required coverage checks pass
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
run_command: empty-upload
force: true
user-migration-smoke-test:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '8.5' ]
nextcloud-versions: [ 'master' ]
db: [ 'mysql' ]
env:
TEST_USER: user1
TEST_EMAIL: user1@localhost
EXPORT_DIRECTORY: /tmp
name: Nextcloud ${{ matrix.nextcloud-versions }} php${{ matrix.php-versions }} user migration test
steps:
- name: Set up Nextcloud env
uses: nextcloud/setup-server-action@34b73d5b0e3633f83a52227d00cc2a6c41d01d9a # v1.0.0
with:
nextcloud-version: ${{ matrix.nextcloud-versions }}
php-version: ${{ matrix.php-versions }}
patch-php-version-check: ${{ matrix.php-versions == '8.6' }}
node-version: 'false'
install: true
- name: Checkout mail
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: nextcloud/apps/mail
fetch-depth: 2
- name: Install dependencies
working-directory: nextcloud/apps/mail
run: composer install --no-dev
- name: Install mail
run: php -f nextcloud/occ app:enable mail
- name: Checkout user_migration
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: nextcloud/user_migration
ref: 3b4007d9ed2c80c53ca8bce6692e14aab5e482b0 # v10.5.0
path: nextcloud/apps/user_migration
- name: Install dependencies
working-directory: nextcloud/apps/user_migration
run: composer install --no-dev
- name: Patch version check for nightly Nextcloud
if: ${{ matrix.nextcloud-versions == 'master' }}
run: sed -i -E 's/max-version="([0-9]{2})"/max-version="99"/' nextcloud/apps/user_migration/appinfo/info.xml
- name: Install user_migration
run: php -f nextcloud/occ app:enable user_migration
- name: Create test user
run: php -f nextcloud/occ user:add --generate-password $TEST_USER
- name: Create mail account to migrate
run: |
php -f nextcloud/occ mail:account:create-imap \
$TEST_USER 'Test Account' $TEST_EMAIL \
imap.mail.test 993 ssl $TEST_EMAIL imap-password \
smtp.mail.test 465 ssl $TEST_EMAIL smtp-password
- name: Test basic mail export
run: php -f nextcloud/occ user:export -t mail_account $TEST_USER $EXPORT_DIRECTORY
- name: Assert the account was written to the export
run: |
EXPORTED_ZIP=$(find $EXPORT_DIRECTORY -name "$TEST_USER*.zip" | tail -1)
unzip -l "$EXPORTED_ZIP" | grep -q 'mail/accounts/.*\.json' \
|| { echo "::error::no account file in the export"; unzip -l "$EXPORTED_ZIP"; exit 1; }
- name: Delete exported user to avoid overwrite confirmation during import
run: php -f nextcloud/occ user:delete $TEST_USER
- name: Test basic mail import
run: |
EXPORTED_ZIP=$(find $EXPORT_DIRECTORY -name "$TEST_USER*.zip" | tail -1)
php -f nextcloud/occ user:import $EXPORTED_ZIP
- name: Assert the account was restored
run: |
php -f nextcloud/occ mail:account:export $TEST_USER | tee /tmp/imported-accounts.txt
grep -q "E-Mail: $TEST_EMAIL" /tmp/imported-accounts.txt \
|| { echo "::error::imported user has no mail account"; exit 1; }
grep -q "IMAP user: $TEST_EMAIL" /tmp/imported-accounts.txt \
|| { echo "::error::imported account lost its IMAP username"; exit 1; }
summary:
runs-on: ubuntu-latest-low
needs:
- unit-tests
- integration-tests
- frontend-unit-test
- frontend-e2e-tests
- user-migration-smoke-test
if: always()
name: test-summary
steps:
- name: Unit test status
run: if ${{ needs.unit-tests.result != 'success' && needs.unit-tests.result != 'skipped' }}; then exit 1; fi
- name: Integration test status
run: if ${{ needs.integration-tests.result != 'success' && needs.integration-tests.result != 'skipped' }}; then exit 1; fi
- name: Frontend unit test status
run: if ${{ needs.frontend-unit-test.result != 'success' && needs.frontend-unit-test.result != 'skipped' }}; then exit 1; fi
- name: Frontend E2E test status
run: if ${{ needs.frontend-e2e-tests.result != 'success' && needs.frontend-e2e-tests.result != 'skipped' }}; then exit 1; fi
- name: User migration smoke test status
run: if ${{ needs.user-migration-smoke-test.result != 'success' && needs.user-migration-smoke-test.result != 'skipped' }}; then exit 1; fi