dfc99b321d
Test Action / Test Node (pull_request) Has been cancelled
Test Action / Test PHP (pull_request) Has been cancelled
Test Action / Test Database Configuration (pull_request) Has been cancelled
Test Action / Test Base Modules Installation (pull_request) Has been cancelled
Test Action / Test Base Modules Requires PHP (pull_request) Has been cancelled
Test Action / Test nginx (pull_request) Has been cancelled
Test Action / Test All Components (pull_request) Has been cancelled
Test Action / Test Custom Server Path (pull_request) Has been cancelled
Test Action / Test Build Command (pull_request) Has been cancelled
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
311 lines
11 KiB
YAML
311 lines
11 KiB
YAML
name: Test Action
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
# Keep the fixture source in one place. Override these with repository variables
|
|
# when testing another server repository; no workflow edits are required.
|
|
env:
|
|
TEST_SERVER_REPOSITORY: ${{ vars.TEST_SERVER_REPOSITORY || 'Nodarx/server' }}
|
|
TEST_SERVER_REF: ${{ vars.TEST_SERVER_REF || 'main' }}
|
|
TEST_GIT_SERVER_URL: ${{ vars.TEST_GIT_SERVER_URL || 'https://git.ktrix.dev' }}
|
|
|
|
jobs:
|
|
test-node:
|
|
name: Test Node
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6.0.2
|
|
|
|
- name: Test action with Node.js (npm)
|
|
uses: ./
|
|
with:
|
|
install-node: 'true'
|
|
node-version: '24'
|
|
server-path: './test-server'
|
|
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
|
server-ref: ${{ env.TEST_SERVER_REF }}
|
|
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
|
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
|
|
|
- name: Verify installation
|
|
run: |
|
|
test -d ./test-server || exit 1
|
|
test -d ./test-server/node_modules || exit 1
|
|
chmod +x ./scripts/health-check.sh
|
|
./scripts/health-check.sh ./test-server true false false
|
|
echo "✓ Node.js (npm) installation successful"
|
|
|
|
- name: Run server tests
|
|
run: |
|
|
cd ./test-server
|
|
npm run test:unit
|
|
|
|
test-php:
|
|
name: Test PHP
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6.0.2
|
|
|
|
- name: Test action with PHP
|
|
uses: ./
|
|
with:
|
|
install-php: 'true'
|
|
php-version: '8.5'
|
|
server-path: './test-server'
|
|
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
|
server-ref: ${{ env.TEST_SERVER_REF }}
|
|
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
|
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
|
|
|
- name: Verify installation
|
|
run: |
|
|
test -d ./test-server || exit 1
|
|
php --version
|
|
composer --version
|
|
chmod +x ./scripts/health-check.sh
|
|
./scripts/health-check.sh ./test-server false true false
|
|
echo "✓ PHP installation successful"
|
|
|
|
- name: Run server tests
|
|
run: |
|
|
cd ./test-server
|
|
composer test:unit
|
|
|
|
test-database-config:
|
|
name: Test Database Configuration
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
mongo:
|
|
image: mongo:7
|
|
ports:
|
|
- 27017:27017
|
|
steps:
|
|
- uses: actions/checkout@v6.0.2
|
|
|
|
- name: Test action with database configuration
|
|
uses: ./
|
|
with:
|
|
install-php: 'true'
|
|
php-version: '8.5'
|
|
server-path: './test-server'
|
|
database-uri: 'mongodb://127.0.0.1:27017/?tls=false'
|
|
database-name: 'ktrix_ci'
|
|
app-environment: 'test'
|
|
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
|
server-ref: ${{ env.TEST_SERVER_REF }}
|
|
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
|
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
|
|
|
- name: Verify configuration was written
|
|
run: |
|
|
cd ./test-server
|
|
php -r '
|
|
$config = include "config/system.php";
|
|
$uri = $config["database"]["uri"] ?? null;
|
|
$name = $config["database"]["database"] ?? null;
|
|
$env = $config["environment"] ?? null;
|
|
if ($uri !== "mongodb://127.0.0.1:27017/?tls=false") { fwrite(STDERR, "database.uri not overridden, got: $uri\n"); exit(1); }
|
|
if ($name !== "ktrix_ci") { fwrite(STDERR, "database.database not overridden, got: $name\n"); exit(1); }
|
|
if ($env !== "test") { fwrite(STDERR, "environment not overridden, got: $env\n"); exit(1); }
|
|
'
|
|
echo "✓ Database configuration verified"
|
|
|
|
- name: Verify database is reachable with configured settings
|
|
run: |
|
|
cd ./test-server
|
|
php bin/console tenant:list
|
|
|
|
test-base-modules:
|
|
name: Test Base Modules Installation
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
mongo:
|
|
image: mongo:7
|
|
ports:
|
|
- 27017:27017
|
|
steps:
|
|
- uses: actions/checkout@v6.0.2
|
|
|
|
- name: Test action with base modules
|
|
uses: ./
|
|
with:
|
|
install-php: 'true'
|
|
php-version: '8.5'
|
|
server-path: './test-server'
|
|
database-uri: 'mongodb://127.0.0.1:27017/?tls=false'
|
|
database-name: 'ktrix_ci'
|
|
install-base-modules: 'true'
|
|
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
|
server-ref: ${{ env.TEST_SERVER_REF }}
|
|
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
|
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
|
|
|
- name: Verify password authentication provider is installed and enabled
|
|
run: |
|
|
cd ./test-server
|
|
OUTPUT=$(php bin/console module:list)
|
|
echo "$OUTPUT"
|
|
echo "$OUTPUT" | grep -q "authentication_provider_password" || { echo "::error::authentication_provider_password not found in module list"; exit 1; }
|
|
echo "$OUTPUT" | grep "authentication_provider_password" | grep -q "Enabled" || { echo "::error::authentication_provider_password is not enabled"; exit 1; }
|
|
echo "✓ authentication_provider_password is installed and enabled"
|
|
|
|
- name: Verify a tenant and user can be provisioned end-to-end
|
|
run: |
|
|
cd ./test-server
|
|
php bin/console tenant:create ci.test --identifier ci_smoke
|
|
php bin/console user:create ci_smoke tester@ci.test
|
|
php bin/console user:password ci_smoke tester@ci.test 'Sup3r-Secret!'
|
|
php bin/console user:list ci_smoke | grep -q "tester@ci.test" || { echo "::error::provisioned user not found"; exit 1; }
|
|
echo "✓ tenant and user provisioning verified"
|
|
|
|
test-base-modules-requires-php:
|
|
name: Test Base Modules Requires PHP
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6.0.2
|
|
|
|
- name: Expect failure when install-base-modules is set without install-php
|
|
id: expect-failure
|
|
continue-on-error: true
|
|
uses: ./
|
|
with:
|
|
install-node: 'true'
|
|
install-base-modules: 'true'
|
|
server-path: './test-server'
|
|
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
|
server-ref: ${{ env.TEST_SERVER_REF }}
|
|
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
|
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
|
|
|
- name: Verify the action failed
|
|
run: |
|
|
if [ "${{ steps.expect-failure.outcome }}" != "failure" ]; then
|
|
echo "::error::Expected action to fail when install-base-modules is set without install-php"
|
|
exit 1
|
|
fi
|
|
echo "✓ Action correctly rejected install-base-modules without install-php"
|
|
|
|
test-nginx:
|
|
name: Test nginx
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6.0.2
|
|
|
|
- name: Test action with nginx
|
|
uses: ./
|
|
with:
|
|
install-nginx: 'true'
|
|
server-path: './test-server'
|
|
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
|
server-ref: ${{ env.TEST_SERVER_REF }}
|
|
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
|
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
|
|
|
- name: Verify installation
|
|
run: |
|
|
test -d ./test-server || exit 1
|
|
nginx -v
|
|
# Verify nginx is running
|
|
pgrep nginx || exit 1
|
|
chmod +x ./scripts/health-check.sh
|
|
./scripts/health-check.sh ./test-server false false true
|
|
echo "✓ nginx installation successful"
|
|
|
|
test-all-components:
|
|
name: Test All Components
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6.0.2
|
|
|
|
- name: Test action with all components
|
|
uses: ./
|
|
with:
|
|
install-node: 'true'
|
|
install-php: 'true'
|
|
install-nginx: 'true'
|
|
node-version: '24'
|
|
php-version: '8.5'
|
|
server-path: './test-server'
|
|
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
|
server-ref: ${{ env.TEST_SERVER_REF }}
|
|
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
|
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
|
|
|
- name: Verify installation
|
|
run: |
|
|
test -d ./test-server || exit 1
|
|
test -d ./test-server/node_modules || exit 1
|
|
node --version
|
|
npm --version
|
|
php --version
|
|
composer --version
|
|
nginx -v
|
|
chmod +x ./scripts/health-check.sh
|
|
./scripts/health-check.sh ./test-server true true true
|
|
echo "✓ All components installation successful"
|
|
|
|
- name: Run integration tests
|
|
run: |
|
|
cd ./test-server
|
|
if [ -f package.json ] && grep -q '"test:integration"' package.json; then
|
|
npm run test:integration
|
|
else
|
|
echo "⚠ No integration test script configured, skipping"
|
|
fi
|
|
|
|
test-custom-paths:
|
|
name: Test Custom Server Path
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6.0.2
|
|
|
|
- name: Test action with custom path
|
|
uses: ./
|
|
with:
|
|
install-node: 'true'
|
|
server-path: './my-custom-server'
|
|
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
|
server-ref: ${{ env.TEST_SERVER_REF }}
|
|
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
|
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
|
|
|
- name: Verify installation
|
|
run: |
|
|
test -d ./my-custom-server || exit 1
|
|
test -d ./my-custom-server/node_modules || exit 1
|
|
echo "✓ Custom path installation successful"
|
|
|
|
- name: Run server tests
|
|
run: |
|
|
cd ./my-custom-server
|
|
if [ -f package.json ] && grep -q '"test"' package.json; then
|
|
npm test
|
|
else
|
|
echo "⚠ No test script configured, skipping"
|
|
fi
|
|
|
|
test-build-command:
|
|
name: Test Build Command
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6.0.2
|
|
|
|
- name: Test action with build command
|
|
uses: ./
|
|
with:
|
|
install-node: 'true'
|
|
server-path: './test-server'
|
|
build-command: 'echo "Build complete" > build.log'
|
|
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
|
server-ref: ${{ env.TEST_SERVER_REF }}
|
|
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
|
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
|
|
|
- name: Verify build
|
|
run: |
|
|
cd ./test-server
|
|
npm run dev
|