All checks were successful
Test Action / Test Node (pull_request) Successful in 14s
Test Action / Test nginx (pull_request) Successful in 16s
Test Action / Test Custom Server Path (pull_request) Successful in 23s
Test Action / Test Build Command (pull_request) Successful in 25s
Test Action / Test PHP (pull_request) Successful in 52s
Test Action / Test All Components (pull_request) Successful in 1m10s
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
218 lines
5.6 KiB
Markdown
218 lines
5.6 KiB
Markdown
# Server Install Action
|
|
|
|
A action to clone the Nodarx server repository and install Node.js, PHP, and/or nginx based on test requirements. Perfect for creating lean test environments (e.g., JS tests install only Node) while supporting full integration tests with all components.
|
|
|
|
## Features
|
|
|
|
- ✅ Clone Nodarx server repository with submodule support
|
|
- ✅ Flexible component installation (Node.js, PHP, nginx)
|
|
- ✅ Automatic dependency installation (npm, composer)
|
|
- ✅ Custom build commands
|
|
- ✅ Post-installation scripts
|
|
- ✅ Comprehensive error handling and logging
|
|
|
|
## Usage
|
|
|
|
### Node.js Only (Unit Tests)
|
|
|
|
```yaml
|
|
name: Node.js Unit Tests
|
|
on: [push]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Install Server with Node.js
|
|
uses: Nodarx/action-server-install@v1
|
|
with:
|
|
install-node: 'true'
|
|
node-version: '24'
|
|
|
|
- name: Run tests
|
|
run: |
|
|
cd server
|
|
npm test
|
|
```
|
|
|
|
### PHP Only (Unit Tests)
|
|
|
|
```yaml
|
|
name: PHP Unit Tests
|
|
on: [push]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Install Server with PHP
|
|
uses: Nodarx/action-server-install@v1
|
|
with:
|
|
install-php: 'true'
|
|
php-version: '8.5'
|
|
|
|
- name: Run tests
|
|
run: |
|
|
cd server
|
|
./vendor/bin/phpunit
|
|
```
|
|
|
|
### Full Integration Test (All Components)
|
|
|
|
```yaml
|
|
name: Integration Tests
|
|
on: [push]
|
|
|
|
jobs:
|
|
integration:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Install Server with All Components
|
|
uses: Nodarx/action-server-install@v1
|
|
with:
|
|
install-node: 'true'
|
|
install-php: 'true'
|
|
install-nginx: 'true'
|
|
node-version: '24'
|
|
php-version: '8.5'
|
|
|
|
- name: Run integration tests
|
|
run: |
|
|
cd server
|
|
npm run test:integration
|
|
```
|
|
|
|
### With Custom nginx Configuration
|
|
|
|
```yaml
|
|
- name: Install Server with nginx
|
|
uses: Nodarx/action-server-install@v1
|
|
with:
|
|
install-nginx: 'true'
|
|
nginx-config: './config/nginx.conf'
|
|
```
|
|
|
|
### Advanced Example with All Options
|
|
|
|
```yaml
|
|
name: Deploy Server
|
|
on: [push]
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Install Server
|
|
uses: Nodarx/action-server-install@v1
|
|
with:
|
|
server-path: './server'
|
|
install-node: 'true'
|
|
install-php: 'true'
|
|
install-nginx: 'true'
|
|
node-version: '20'
|
|
php-version: '8.2'
|
|
php-extensions: 'mbstring, xml, ctype, json, curl, zip, pdo, pdo_mysql'
|
|
nginx-config: './config/nginx.conf'
|
|
install-dependencies: 'true'
|
|
build-command: 'npm run build'
|
|
post-install-script: './scripts/post-install.sh'
|
|
```
|
|
|
|
## Inputs
|
|
|
|
### Component Selection
|
|
|
|
| Input | Description | Required | Default |
|
|
|-------|-------------|----------|---------|
|
|
| `install-node` | Install Node.js environment | No | `false` |
|
|
| `install-php` | Install PHP environment | No | `false` |
|
|
| `install-nginx` | Install nginx web server | No | `false` |
|
|
|
|
**Note:** At least one component must be enabled.
|
|
|
|
### General Configuration
|
|
|
|
| Input | Description | Required | Default |
|
|
|-------|-------------|----------|---------|
|
|
| `server-path` | Path where the server will be cloned/installed | No | `./server` |
|
|
| `install-dependencies` | Whether to install dependencies (npm/composer) | No | `true` |
|
|
| `build-command` | Custom build command to run after install | No | `''` |
|
|
| `post-install-script` | Custom script to run after installation | No | `''` |
|
|
|
|
### Node.js Configuration
|
|
|
|
| Input | Description | Required | Default |
|
|
|-------|-------------|----------|---------|
|
|
| `node-version` | Node.js version to use | No | `24` |
|
|
|
|
|
|
### PHP Configuration
|
|
|
|
| Input | Description | Required | Default |
|
|
|-------|-------------|----------|---------|
|
|
| `php-version` | PHP version to use | No | `8.5` |
|
|
| `php-extensions` | Comma-separated list of PHP extensions to install | No | `mbstring, xml, ctype, json, curl, zip` |
|
|
|
|
### nginx Configuration
|
|
|
|
| Input | Description | Required | Default |
|
|
|-------|-------------|----------|---------|
|
|
| `nginx-config` | Path to nginx configuration file | No | `''` |
|
|
|
|
## Outputs
|
|
|
|
| Output | Description |
|
|
|--------|-------------|
|
|
| `install-status` | Status of the installation (success/failure) |
|
|
| `install-path` | Path where the server was installed |
|
|
| `node-installed` | Whether Node.js was installed (true/false) |
|
|
| `php-installed` | Whether PHP was installed (true/false) |
|
|
| `nginx-installed` | Whether nginx was installed (true/false) |
|
|
|
|
## Best Practices
|
|
|
|
1. **Enable only needed components**: For faster test runs
|
|
```yaml
|
|
# JS unit tests - Node.js only
|
|
- uses: Nodarx/action-server-install@v1
|
|
with:
|
|
install-node: 'true'
|
|
```
|
|
|
|
2. **Pin to specific versions**: Use commit SHA or version tag
|
|
```yaml
|
|
uses: Nodarx/action-server-install@v1.0.0
|
|
```
|
|
|
|
3. **Cache dependencies**: Combine with caching for faster builds
|
|
```yaml
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-node-${{ hashFiles('server/package-lock.json') }}
|
|
|
|
- uses: Nodarx/action-server-install@v1
|
|
with:
|
|
install-node: 'true'
|
|
```
|
|
|
|
4. **Test different component combinations**: Matrix testing
|
|
```yaml
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- name: Node Tests
|
|
install-node: 'true'
|
|
install-php: 'false'
|
|
- name: PHP Tests
|
|
install-node: 'false'
|
|
install-php: 'true'
|
|
- name: Integration Tests
|
|
install-node: 'true'
|
|
install-php: 'true'
|
|
```
|
|
|
|
## License
|
|
|
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|