Skip to content

fix(settings): hide server actions on auth failure #22811

fix(settings): hide server actions on auth failure

fix(settings): hide server actions on auth failure #22811

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"
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.1'
nextcloud-versions: 'stable32'
- 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@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
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.1
nextcloud-versions: 'stable32'
db: 'sqlite'
cache: 'redis'
- php-versions: 8.2
nextcloud-versions: 'stable32'
db: 'pgsql'
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:v0.15.5
env:
STALWART_ADMIN_PASSWORD: ${{ env.STALWART_PWD }}
ports:
- 10080: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: Create domain and account in Stalwart
run: |
curl -sf -X POST http://localhost:10080/api/principal \
-u "admin:${{ env.STALWART_PWD }}" \
-H 'Content-Type: application/json' \
-d '{"type":"domain","name":"example.com"}'
curl -sf -X POST http://localhost:10080/api/principal \
-u "admin:${{ env.STALWART_PWD }}" \
-H 'Content-Type: application/json' \
-d '{"type":"individual","name":"user@example.com","secrets":["mypassword"],"emails":["user@example.com"],"roles":["user"]}'
- 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: Report coverage
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
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@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.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@8a7bac6300b2f0f3100088b297995a229558ddba # v1.3.2
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@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
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@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
run_command: empty-upload
summary:
runs-on: ubuntu-latest-low
needs:
- unit-tests
- integration-tests
- frontend-unit-test
- frontend-e2e-tests
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