Files
action-server-install/.github/workflows/test.yml
T
Sebastian 893071b22f
Test Action / Test Base Modules Requires PHP (pull_request) Successful in 7s
Test Action / Test Build Command (pull_request) Successful in 46s
Test Action / Test Custom Server Path (pull_request) Successful in 54s
Test Action / Test Node (pull_request) Successful in 55s
Test Action / Test nginx (pull_request) Successful in 58s
Test Action / Test Base Modules Installation (pull_request) Successful in 1m20s
Test Action / Test Database Configuration (pull_request) Successful in 1m59s
Test Action / Test PHP (pull_request) Successful in 2m0s
Test Action / Test All Components (pull_request) Successful in 2m1s
fix: test hang
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-23 08:18:26 -04:00

284 lines
9.8 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' }}
TEST_DATABASE_URI: ${{ vars.TEST_DATABASE_URI || 'mongodb://mongo:27017/?tls=false' }}
jobs:
test-node:
name: Test Node
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Test action with Node.js (npm)
id: install
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
test "${{ steps.install.outputs.install-status }}" = "success"
test "${{ steps.install.outputs.node-installed }}" = "true"
echo "✓ Node.js (npm) installation successful"
test-php:
name: Test PHP
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Test action with PHP
id: install
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
test "${{ steps.install.outputs.install-status }}" = "success"
test "${{ steps.install.outputs.php-installed }}" = "true"
echo "✓ PHP installation successful"
test-database-config:
name: Test Database Configuration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Test action with database configuration
uses: ./
with:
install-php: 'true'
php-version: '8.5'
server-path: './test-server'
database-uri: ${{ env.TEST_DATABASE_URI }}
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;
$expectedUri = getenv("TEST_DATABASE_URI");
if ($uri !== $expectedUri) { 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"
test-base-modules:
name: Test Base Modules Installation
runs-on: ubuntu-latest
services:
mongo:
image: mongo:7
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Test action with base modules
id: install
uses: ./
with:
install-php: 'true'
php-version: '8.5'
server-path: './test-server'
database-uri: ${{ env.TEST_DATABASE_URI }}
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: |
test -d ./test-server/modules/authentication_provider_password
test "${{ steps.install.outputs.install-status }}" = "success"
test "${{ steps.install.outputs.base-modules-installed }}" = "true"
echo "✓ authentication_provider_password is installed and enabled"
test-base-modules-requires-php:
name: Test Base Modules Requires PHP
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Verify base modules require PHP
run: |
if bash ./scripts/validate-inputs.sh true false false true; then
echo "::error::Expected validation to fail when install-base-modules is set without install-php"
exit 1
fi
echo "✓ Validation correctly rejected install-base-modules without install-php"
test-nginx:
name: Test nginx
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- 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@v4
with:
persist-credentials: false
- name: Test action with all components
id: install
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
test "${{ steps.install.outputs.install-status }}" = "success"
test "${{ steps.install.outputs.node-installed }}" = "true"
test "${{ steps.install.outputs.php-installed }}" = "true"
test "${{ steps.install.outputs.nginx-installed }}" = "true"
echo "✓ All components installation successful"
test-custom-paths:
name: Test Custom Server Path
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Test action with custom path
id: install
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
test "${{ steps.install.outputs.install-path }}" = "./my-custom-server"
test "${{ steps.install.outputs.install-status }}" = "success"
echo "✓ Custom path installation successful"
test-build-command:
name: Test Build Command
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- 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
test -f build.log
grep -q '^Build complete$' build.log
echo "✓ Custom build command completed successfully"