mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Refactor matrix job to use GitHub API and clean up test config
Replace shell-based database change detection with github-script using the GitHub API, eliminating the need for a full checkout. Restructure matrix generation with guard clauses and no mutation. Remove ciIgnore exclude group from test command. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
09317f290a
commit
edd948557e
+38
-27
@@ -20,31 +20,42 @@ on:
|
||||
default: ''
|
||||
|
||||
jobs:
|
||||
check_database_changes:
|
||||
name: Check if utopia-php/database changed
|
||||
matrix:
|
||||
name: Generate test matrix
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
database_changed: ${{ steps.check.outputs.database_changed }}
|
||||
databases: ${{ steps.generate.outputs.databases }}
|
||||
modes: ${{ steps.generate.outputs.modes }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
- name: Generate matrix
|
||||
id: generate
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
script: |
|
||||
const allDatabases = ['MariaDB', 'PostgreSQL', 'MongoDB'];
|
||||
const allModes = ['dedicated', 'shared_v1', 'shared_v2'];
|
||||
|
||||
- name: Check for utopia-php/database changes
|
||||
id: check
|
||||
run: |
|
||||
BASE_REF="${{ github.event.pull_request.base.ref }}"
|
||||
if [ -z "$BASE_REF" ]; then
|
||||
echo "database_changed=true" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
const defaultDatabases = ['MongoDB'];
|
||||
const defaultModes = ['dedicated'];
|
||||
|
||||
if git diff "origin/${BASE_REF}" HEAD -- composer.lock | grep -q '"name": "utopia-php/database"'; then
|
||||
echo "database_changed=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "database_changed=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
const pr = context.payload.pull_request;
|
||||
if (!pr) {
|
||||
core.setOutput('databases', JSON.stringify(allDatabases));
|
||||
core.setOutput('modes', JSON.stringify(allModes));
|
||||
return;
|
||||
}
|
||||
|
||||
const files = await github.paginate(github.rest.pulls.listFiles, {
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: pr.number,
|
||||
});
|
||||
|
||||
const lockFile = files.find(f => f.filename === 'composer.lock');
|
||||
const databaseChanged = lockFile?.patch?.includes('"name": "utopia-php/database"') ?? false;
|
||||
|
||||
core.setOutput('databases', JSON.stringify(databaseChanged ? allDatabases : defaultDatabases));
|
||||
core.setOutput('modes', JSON.stringify(databaseChanged ? allModes : defaultModes));
|
||||
|
||||
setup:
|
||||
name: Setup & Build Appwrite Image
|
||||
@@ -197,15 +208,15 @@ jobs:
|
||||
e2e_service_test:
|
||||
name: E2E / ${{ matrix.database }} (${{ matrix.mode }}) / ${{ matrix.service }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [setup, check_database_changes]
|
||||
needs: [setup, matrix]
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
database: ${{ fromJSON(needs.check_database_changes.outputs.database_changed == 'true' && '["MariaDB","PostgreSQL","MongoDB"]' || '["MongoDB"]') }}
|
||||
mode: ${{ fromJSON(needs.check_database_changes.outputs.database_changed == 'true' && '["dedicated","shared_v1","shared_v2"]' || '["dedicated"]') }}
|
||||
database: ${{ fromJSON(needs.matrix.outputs.databases) }}
|
||||
mode: ${{ fromJSON(needs.matrix.outputs.modes) }}
|
||||
service: [
|
||||
Account,
|
||||
Avatars,
|
||||
@@ -304,7 +315,7 @@ jobs:
|
||||
|
||||
docker compose exec -T \
|
||||
-e _APP_E2E_RESPONSE_FORMAT="${{ github.event.inputs.response_format }}" \
|
||||
appwrite vendor/bin/paratest --processes $(nproc) $FUNCTIONAL_FLAG "$SERVICE_PATH" --exclude-group abuseEnabled --exclude-group screenshots --exclude-group ciIgnore --log-junit tests/e2e/Services/${{ matrix.service }}/junit.xml
|
||||
appwrite vendor/bin/paratest --processes $(nproc) $FUNCTIONAL_FLAG "$SERVICE_PATH" --exclude-group abuseEnabled --exclude-group screenshots --log-junit tests/e2e/Services/${{ matrix.service }}/junit.xml
|
||||
|
||||
- name: Failure Logs
|
||||
if: failure()
|
||||
@@ -315,14 +326,14 @@ jobs:
|
||||
e2e_abuse_enabled:
|
||||
name: E2E / Abuse (${{ matrix.mode }})
|
||||
runs-on: ubuntu-latest
|
||||
needs: [setup, check_database_changes]
|
||||
needs: [setup, matrix]
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
mode: ${{ fromJSON(needs.check_database_changes.outputs.database_changed == 'true' && '["dedicated","shared_v1","shared_v2"]' || '["dedicated"]') }}
|
||||
mode: ${{ fromJSON(needs.matrix.outputs.modes) }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
@@ -374,14 +385,14 @@ jobs:
|
||||
e2e_screenshots:
|
||||
name: E2E / Screenshots (${{ matrix.mode }})
|
||||
runs-on: ubuntu-latest
|
||||
needs: [setup, check_database_changes]
|
||||
needs: [setup, matrix]
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
mode: ${{ fromJSON(needs.check_database_changes.outputs.database_changed == 'true' && '["dedicated","shared_v1","shared_v2"]' || '["dedicated"]') }}
|
||||
mode: ${{ fromJSON(needs.matrix.outputs.modes) }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
|
||||
Reference in New Issue
Block a user