1
0
mirror of https://github.com/flarum/core.git synced 2025-08-10 10:24:46 +02:00

chore: improve test suite (#3814)

Allows running tests without constantly running `composer install` on each extension.
This commit is contained in:
Sami Mazouz
2023-06-15 13:26:39 +01:00
committed by GitHub
parent 6bc19e2e52
commit 64b25b26c3
70 changed files with 213 additions and 309 deletions

View File

@@ -21,6 +21,12 @@ on:
required: false
default: '.'
# Only relevant in mono-repos.
monorepo_tests:
description: "The list of directories to test in a monorepo. This should be a space-separated list of directories relative to the backend directory."
type: string
required: false
php_versions:
description: Versions of PHP to test with. Should be array of strings encoded as JSON array
type: string
@@ -47,6 +53,7 @@ on:
env:
COMPOSER_ROOT_VERSION: dev-main
# `inputs.composer_directory` defaults to `inputs.backend_directory`
FLARUM_TEST_TMP_DIR_LOCAL: tests/integration/tmp
jobs:
@@ -143,18 +150,27 @@ jobs:
run: composer install
working-directory: ${{ inputs.backend_directory }}
- name: Setup Composer tests
run: composer test:setup
# If we have a `inputs.monorepo_tests`, we will run tests for each item of the provided array in a ::group::item
# If we don't have a `inputs.monorepo_tests`, we will run tests for the current repository
# We also have to run the `composer test:setup` script first before running each test
- name: Run tests
run: |
if [ -z "${{ inputs.monorepo_tests }}" ]; then
composer test:setup
composer test
else
for test in ${{ inputs.monorepo_tests }}; do
echo "::group::Running tests for $test"
composer test:setup --working-dir=$test
composer test --working-dir=$test
echo "::endgroup::"
done
fi
working-directory: ${{ inputs.backend_directory }}
env:
DB_PORT: 13306
DB_PASSWORD: root
DB_PREFIX: ${{ matrix.prefix }}
- name: Run Composer tests
run: composer test
working-directory: ${{ inputs.backend_directory }}
env:
COMPOSER_PROCESS_TIMEOUT: 600
phpstan:

11
.github/workflows/backend.yml vendored Normal file
View File

@@ -0,0 +1,11 @@
name: Backend Tests
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true
backend_directory: .
monorepo_tests: "framework/core extensions/akismet extensions/approval extensions/flags extensions/likes extensions/mentions extensions/nicknames extensions/statistics extensions/sticky extensions/subscriptions extensions/suspend extensions/tags"

View File

@@ -1,11 +0,0 @@
name: Akismet PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true
backend_directory: ./extensions/akismet

View File

@@ -1,11 +0,0 @@
name: Approval PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true
backend_directory: ./extensions/approval

View File

@@ -1,11 +0,0 @@
name: Core PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true
backend_directory: ./framework/core

View File

@@ -1,11 +0,0 @@
name: Embed PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false
backend_directory: ./extensions/embed

View File

@@ -1,11 +0,0 @@
name: Emoji PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false
backend_directory: ./extensions/emoji

View File

@@ -1,11 +0,0 @@
name: Flags PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true
backend_directory: ./extensions/flags

View File

@@ -1,11 +0,0 @@
name: Likes PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true
backend_directory: ./extensions/likes

View File

@@ -1,11 +0,0 @@
name: Lock PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false
backend_directory: ./extensions/lock

View File

@@ -1,11 +0,0 @@
name: Markdown PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false
backend_directory: ./extensions/markdown

View File

@@ -1,11 +0,0 @@
name: Mentions PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true
backend_directory: ./extensions/mentions

View File

@@ -1,11 +0,0 @@
name: Nicknames PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true
backend_directory: ./extensions/nicknames

View File

@@ -1,11 +0,0 @@
name: Package Manager PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false
backend_directory: ./extensions/package-manager

View File

@@ -1,11 +0,0 @@
name: Pusher PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false
backend_directory: ./extensions/pusher

View File

@@ -1,11 +0,0 @@
name: Statistics PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true
backend_directory: ./extensions/statistics

View File

@@ -1,11 +0,0 @@
name: Sticky PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true
backend_directory: ./extensions/sticky

View File

@@ -1,11 +0,0 @@
name: Subscriptions PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true
backend_directory: ./extensions/subscriptions

View File

@@ -1,11 +0,0 @@
name: Suspend PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true
backend_directory: ./extensions/suspend

View File

@@ -1,11 +0,0 @@
name: Tags PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true
backend_directory: ./extensions/tags

View File

@@ -1,4 +1,4 @@
name: Framework JS
name: Frontend Workflow
on: [workflow_dispatch, push, pull_request]

View File

@@ -1,4 +1,4 @@
name: Framework PHP
name: Static Code Analysis
on: [workflow_dispatch, push, pull_request]
@@ -8,5 +8,4 @@ jobs:
with:
enable_backend_testing: false
enable_phpstan: true
backend_directory: .