Some checks failed
Test Module Installation Action / Node.js Module with NPM (pull_request) Successful in 23s
Test Module Installation Action / PHP Module with Composer (pull_request) Successful in 1m5s
Test Module Installation Action / Mixed PHP and Node Modules (pull_request) Successful in 1m3s
Test Module Installation Action / Error Handling (pull_request) Successful in 1m13s
Test Module Installation Action / Single Module (No Dependencies) (pull_request) Successful in 1m37s
Test Module Installation Action / Test Summary (pull_request) Failing after 3s
Signed-off-by: Sebastian Krupinski <root@LAPTOP-7DVOR6NC>
529 lines
17 KiB
YAML
529 lines
17 KiB
YAML
name: Test Module Installation Action
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [ main ]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
# Test basic single module installation
|
|
test-single-module:
|
|
name: Single Module (No Dependencies)
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout action-module-install
|
|
uses: actions/checkout@v6.0.2
|
|
with:
|
|
path: action-module-install
|
|
|
|
- name: Checkout action-server-install
|
|
uses: actions/checkout@v6.0.2
|
|
with:
|
|
repository: Nodarx/action-server-install
|
|
ref: main
|
|
path: action-server-install
|
|
github-server-url: https://git.ktrix.dev
|
|
|
|
- name: Setup server environment
|
|
uses: ./action-server-install
|
|
with:
|
|
install-php: 'true'
|
|
install-node: 'true'
|
|
php-version: '8.5'
|
|
node-version: '24'
|
|
server-path: './server'
|
|
|
|
- name: Create test module repository
|
|
run: |
|
|
mkdir -p /tmp/test-repos/simple-module
|
|
cd /tmp/test-repos/simple-module
|
|
git init
|
|
git config user.email "test@example.com"
|
|
git config user.name "Test User"
|
|
|
|
# Create a simple Node.js module
|
|
cat > package.json << 'EOF'
|
|
{
|
|
"name": "simple-module",
|
|
"version": "1.0.0",
|
|
"description": "Test module",
|
|
"main": "index.js"
|
|
}
|
|
EOF
|
|
|
|
echo "console.log('Simple module loaded');" > index.js
|
|
|
|
git add .
|
|
git commit -m "Initial commit"
|
|
|
|
- name: Install single module
|
|
id: install
|
|
uses: ./action-module-install
|
|
with:
|
|
modules: |
|
|
[
|
|
{
|
|
"name": "simple-module",
|
|
"repo": "file:///tmp/test-repos/simple-module"
|
|
}
|
|
]
|
|
|
|
- name: Verify installation
|
|
run: |
|
|
echo "Checking installation..."
|
|
|
|
# Check module directory exists
|
|
if [ ! -d "./modules/simple-module" ]; then
|
|
echo "::error::Module directory not found"
|
|
exit 1
|
|
fi
|
|
|
|
# Check files were cloned
|
|
if [ ! -f "./modules/simple-module/package.json" ]; then
|
|
echo "::error::package.json not found"
|
|
exit 1
|
|
fi
|
|
|
|
# Check npm install result (node_modules required only if production deps exist)
|
|
DEP_COUNT=$(node -e 'const p=require("./modules/simple-module/package.json"); const c=Object.keys(p.dependencies||{}).length+Object.keys(p.optionalDependencies||{}).length; console.log(c);')
|
|
if [ "$DEP_COUNT" -gt 0 ] && [ ! -d "./modules/simple-module/node_modules" ]; then
|
|
echo "::error::node_modules not found for module with production dependencies"
|
|
exit 1
|
|
fi
|
|
|
|
# Check outputs
|
|
if [ "${{ steps.install.outputs.status }}" != "success" ]; then
|
|
echo "::error::Installation status is not success"
|
|
exit 1
|
|
fi
|
|
|
|
if [ "${{ steps.install.outputs.installed-modules }}" != "simple-module" ]; then
|
|
echo "::error::Installed modules output is incorrect"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✓ Single module installation verified"
|
|
|
|
# Test PHP module
|
|
test-php-module:
|
|
name: PHP Module with Composer
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout action-module-install
|
|
uses: actions/checkout@v6.0.2
|
|
with:
|
|
path: action-module-install
|
|
|
|
- name: Clone action-server-install
|
|
uses: actions/checkout@v6.0.2
|
|
with:
|
|
repository: Nodarx/action-server-install
|
|
ref: main
|
|
path: action-server-install
|
|
github-server-url: https://git.ktrix.dev
|
|
|
|
- name: Setup PHP environment
|
|
uses: ./action-server-install
|
|
with:
|
|
install-php: 'true'
|
|
php-version: '8.5'
|
|
server-path: './server'
|
|
|
|
- name: Create PHP test module
|
|
run: |
|
|
mkdir -p /tmp/test-repos/php-module
|
|
cd /tmp/test-repos/php-module
|
|
git init
|
|
git config user.email "test@example.com"
|
|
git config user.name "Test User"
|
|
|
|
cat > composer.json << 'EOF'
|
|
{
|
|
"name": "test/php-module",
|
|
"description": "PHP test module",
|
|
"require": {
|
|
"php": ">=8.0"
|
|
},
|
|
"autoload": {
|
|
"psr-4": {
|
|
"Test\\PhpModule\\": "src/"
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
|
|
mkdir -p src
|
|
cat > src/TestClass.php << 'EOF'
|
|
<?php
|
|
namespace Test\PhpModule;
|
|
|
|
class TestClass {
|
|
public function getMessage() {
|
|
return "PHP Module loaded";
|
|
}
|
|
}
|
|
EOF
|
|
|
|
git add . && git commit -m "Initial commit"
|
|
|
|
- name: Install PHP module
|
|
uses: ./action-module-install
|
|
with:
|
|
modules: |
|
|
[
|
|
{
|
|
"name": "php-module",
|
|
"repo": "file:///tmp/test-repos/php-module"
|
|
}
|
|
]
|
|
|
|
- name: Verify PHP installation
|
|
run: |
|
|
# Check composer.json exists
|
|
if [ ! -f "./modules/php-module/composer.json" ]; then
|
|
echo "::error::composer.json not found"
|
|
exit 1
|
|
fi
|
|
|
|
# Check vendor directory created
|
|
if [ ! -d "./modules/php-module/vendor" ]; then
|
|
echo "::error::vendor directory not found - composer install failed"
|
|
exit 1
|
|
fi
|
|
|
|
# Check autoload file exists
|
|
if [ ! -f "./modules/php-module/vendor/autoload.php" ]; then
|
|
echo "::error::autoload.php not found"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✓ PHP module installation verified"
|
|
|
|
# Test Node.js module
|
|
test-node-module:
|
|
name: Node.js Module with NPM
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout action-module-install
|
|
uses: actions/checkout@v6.0.2
|
|
with:
|
|
path: action-module-install
|
|
|
|
- name: Clone action-server-install
|
|
uses: actions/checkout@v6.0.2
|
|
with:
|
|
repository: Nodarx/action-server-install
|
|
ref: main
|
|
path: action-server-install
|
|
github-server-url: https://git.ktrix.dev
|
|
|
|
- name: Setup Node.js environment
|
|
uses: ./action-server-install
|
|
with:
|
|
install-node: 'true'
|
|
node-version: '24'
|
|
server-path: './server'
|
|
|
|
- name: Create Node.js test module
|
|
run: |
|
|
mkdir -p /tmp/test-repos/vue-module
|
|
cd /tmp/test-repos/vue-module
|
|
git init
|
|
git config user.email "test@example.com"
|
|
git config user.name "Test User"
|
|
|
|
cat > package.json << 'EOF'
|
|
{
|
|
"name": "vue-module",
|
|
"version": "1.0.0",
|
|
"description": "Vue test module",
|
|
"main": "index.js",
|
|
"dependencies": {}
|
|
}
|
|
EOF
|
|
|
|
cat > index.js << 'EOF'
|
|
export default {
|
|
name: 'VueModule',
|
|
getMessage() {
|
|
return 'Vue module loaded';
|
|
}
|
|
};
|
|
EOF
|
|
|
|
git add . && git commit -m "Initial commit"
|
|
|
|
- name: Install Node.js module
|
|
uses: ./action-module-install
|
|
with:
|
|
modules: |
|
|
[
|
|
{
|
|
"name": "vue-module",
|
|
"repo": "file:///tmp/test-repos/vue-module"
|
|
}
|
|
]
|
|
|
|
- name: Verify Node.js installation
|
|
run: |
|
|
# Check package.json exists
|
|
if [ ! -f "./modules/vue-module/package.json" ]; then
|
|
echo "::error::package.json not found"
|
|
exit 1
|
|
fi
|
|
|
|
# Check npm install result (node_modules required only if production deps exist)
|
|
DEP_COUNT=$(node -e 'const p=require("./modules/vue-module/package.json"); const c=Object.keys(p.dependencies||{}).length+Object.keys(p.optionalDependencies||{}).length; console.log(c);')
|
|
if [ "$DEP_COUNT" -gt 0 ] && [ ! -d "./modules/vue-module/node_modules" ]; then
|
|
echo "::error::node_modules directory not found for module with production dependencies"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✓ Node.js module installation verified"
|
|
|
|
# Test mixed PHP and Node.js modules
|
|
test-mixed-modules:
|
|
name: Mixed PHP and Node Modules
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout action-module-install
|
|
uses: actions/checkout@v6.0.2
|
|
with:
|
|
path: action-module-install
|
|
|
|
- name: Clone action-server-install
|
|
uses: actions/checkout@v6.0.2
|
|
with:
|
|
repository: Nodarx/action-server-install
|
|
ref: main
|
|
path: action-server-install
|
|
github-server-url: https://git.ktrix.dev
|
|
|
|
- name: Setup both PHP and Node.js
|
|
uses: ./action-server-install
|
|
with:
|
|
install-php: 'true'
|
|
install-node: 'true'
|
|
php-version: '8.5'
|
|
node-version: '24'
|
|
server-path: './server'
|
|
|
|
- name: Create mixed test modules
|
|
run: |
|
|
# PHP backend module
|
|
mkdir -p /tmp/test-repos/backend
|
|
cd /tmp/test-repos/backend
|
|
git init
|
|
git config user.email "test@example.com"
|
|
git config user.name "Test User"
|
|
cat > composer.json << 'EOF'
|
|
{
|
|
"name": "test/backend",
|
|
"require": {}
|
|
}
|
|
EOF
|
|
git add . && git commit -m "Initial commit"
|
|
|
|
# Node.js frontend module
|
|
mkdir -p /tmp/test-repos/frontend
|
|
cd /tmp/test-repos/frontend
|
|
git init
|
|
git config user.email "test@example.com"
|
|
git config user.name "Test User"
|
|
cat > package.json << 'EOF'
|
|
{
|
|
"name": "frontend",
|
|
"version": "1.0.0"
|
|
}
|
|
EOF
|
|
git add . && git commit -m "Initial commit"
|
|
|
|
- name: Install mixed modules
|
|
uses: ./action-module-install
|
|
with:
|
|
modules: |
|
|
[
|
|
{
|
|
"name": "backend",
|
|
"repo": "file:///tmp/test-repos/backend"
|
|
},
|
|
{
|
|
"name": "frontend",
|
|
"repo": "file:///tmp/test-repos/frontend"
|
|
}
|
|
]
|
|
|
|
- name: Verify mixed installation
|
|
run: |
|
|
# Verify PHP module
|
|
if [ ! -d "./modules/backend/vendor" ]; then
|
|
echo "::error::Backend composer dependencies not installed"
|
|
exit 1
|
|
fi
|
|
|
|
# Verify Node module (node_modules required only if production deps exist)
|
|
DEP_COUNT=$(node -e 'const p=require("./modules/frontend/package.json"); const c=Object.keys(p.dependencies||{}).length+Object.keys(p.optionalDependencies||{}).length; console.log(c);')
|
|
if [ "$DEP_COUNT" -gt 0 ] && [ ! -d "./modules/frontend/node_modules" ]; then
|
|
echo "::error::Frontend module has production dependencies but node_modules is missing"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✓ Mixed PHP and Node.js modules verified"
|
|
|
|
# Test error handling for invalid inputs
|
|
test-error-handling:
|
|
name: Error Handling
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout action-module-install
|
|
uses: actions/checkout@v6.0.2
|
|
with:
|
|
path: action-module-install
|
|
|
|
- name: Clone action-server-install
|
|
uses: actions/checkout@v6.0.2
|
|
with:
|
|
repository: Nodarx/action-server-install
|
|
ref: main
|
|
path: action-server-install
|
|
github-server-url: https://git.ktrix.dev
|
|
|
|
- name: Setup environment
|
|
uses: ./action-server-install
|
|
with:
|
|
install-php: 'true'
|
|
install-node: 'true'
|
|
server-path: './server'
|
|
|
|
- name: Test invalid JSON
|
|
id: test-invalid-json
|
|
continue-on-error: true
|
|
uses: ./action-module-install
|
|
with:
|
|
modules: 'invalid json string'
|
|
|
|
- name: Verify invalid JSON was caught
|
|
run: |
|
|
if [ "${{ steps.test-invalid-json.outcome }}" = "success" ]; then
|
|
echo "::error::Action should have failed with invalid JSON"
|
|
exit 1
|
|
fi
|
|
echo "✓ Invalid JSON properly rejected"
|
|
|
|
- name: Test missing dependency
|
|
id: test-missing-dep
|
|
continue-on-error: true
|
|
uses: ./action-module-install
|
|
with:
|
|
modules: |
|
|
[
|
|
{
|
|
"name": "module-a",
|
|
"repo": "file:///tmp/fake",
|
|
"dependencies": ["non-existent-module"]
|
|
}
|
|
]
|
|
|
|
- name: Verify missing dependency was caught
|
|
run: |
|
|
if [ "${{ steps.test-missing-dep.outcome }}" = "success" ]; then
|
|
echo "::error::Action should have failed with missing dependency"
|
|
exit 1
|
|
fi
|
|
echo "✓ Missing dependency properly detected"
|
|
|
|
- name: Test circular dependency
|
|
id: test-circular
|
|
continue-on-error: true
|
|
run: |
|
|
# Create repos for circular dependency test
|
|
mkdir -p /tmp/test-repos/circle-a /tmp/test-repos/circle-b
|
|
|
|
cd /tmp/test-repos/circle-a
|
|
git init
|
|
git config user.email "test@example.com"
|
|
git config user.name "Test User"
|
|
echo '{"name": "circle-a"}' > package.json
|
|
git add . && git commit -m "Initial"
|
|
|
|
cd /tmp/test-repos/circle-b
|
|
git init
|
|
git config user.email "test@example.com"
|
|
git config user.name "Test User"
|
|
echo '{"name": "circle-b"}' > package.json
|
|
git add . && git commit -m "Initial"
|
|
|
|
- name: Run circular dependency test
|
|
id: test-circular-run
|
|
continue-on-error: true
|
|
uses: ./action-module-install
|
|
with:
|
|
modules: |
|
|
[
|
|
{
|
|
"name": "circle-a",
|
|
"repo": "file:///tmp/test-repos/circle-a",
|
|
"dependencies": ["circle-b"]
|
|
},
|
|
{
|
|
"name": "circle-b",
|
|
"repo": "file:///tmp/test-repos/circle-b",
|
|
"dependencies": ["circle-a"]
|
|
}
|
|
]
|
|
|
|
- name: Verify circular dependency was caught
|
|
run: |
|
|
if [ "${{ steps.test-circular-run.outcome }}" = "success" ]; then
|
|
echo "::error::Action should have failed with circular dependency"
|
|
exit 1
|
|
fi
|
|
echo "✓ Circular dependency properly detected"
|
|
|
|
# Test summary
|
|
test-summary:
|
|
name: Test Summary
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- test-single-module
|
|
- test-linear-dependencies
|
|
- test-php-module
|
|
- test-node-module
|
|
- test-mixed-modules
|
|
- test-error-handling
|
|
if: always()
|
|
|
|
steps:
|
|
- name: Check test results
|
|
run: |
|
|
echo "## Test Results Summary" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Test | Result |" >> $GITHUB_STEP_SUMMARY
|
|
echo "|------|--------|" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Single Module | ${{ needs.test-single-module.result }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Linear Dependencies | ${{ needs.test-linear-dependencies.result }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| PHP Module | ${{ needs.test-php-module.result }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Node Module | ${{ needs.test-node-module.result }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Mixed Modules | ${{ needs.test-mixed-modules.result }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Error Handling | ${{ needs.test-error-handling.result }} |" >> $GITHUB_STEP_SUMMARY
|
|
|
|
# Check if any test failed
|
|
if [ "${{ needs.test-single-module.result }}" != "success" ] || \
|
|
[ "${{ needs.test-linear-dependencies.result }}" != "success" ] || \
|
|
[ "${{ needs.test-php-module.result }}" != "success" ] || \
|
|
[ "${{ needs.test-node-module.result }}" != "success" ] || \
|
|
[ "${{ needs.test-mixed-modules.result }}" != "success" ] || \
|
|
[ "${{ needs.test-error-handling.result }}" != "success" ]; then
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "❌ One or more tests failed" >> $GITHUB_STEP_SUMMARY
|
|
exit 1
|
|
fi
|
|
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "✅ All tests passed!" >> $GITHUB_STEP_SUMMARY
|