Skip to content

Commit

Permalink
Merge pull request #2 from punktDe/task/extend-testing
Browse files Browse the repository at this point in the history
Create a PHP project during the test workflow and ensure that Roadrunner is running properly
  • Loading branch information
medanthelinium authored Jan 26, 2024
2 parents c8ae3c5 + 7886549 commit a89303e
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 6 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.DS_Store
*.pyc
__pycache__
files/
5 changes: 5 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
environment:
GITHUB_ACTIONS: "maybe"
vars:
php:
install_composer: yes
roadrunner:
config:
main:
system:
features:
proserver_user: yes
Expand Down
23 changes: 23 additions & 0 deletions molecule/default/files/app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

use Spiral\RoadRunner;
use Nyholm\Psr7;

include "vendor/autoload.php";

$worker = RoadRunner\Worker::create();
$psrFactory = new Psr7\Factory\Psr17Factory();

$worker = new RoadRunner\Http\PSR7Worker($worker, $psrFactory, $psrFactory, $psrFactory);

while ($req = $worker->waitRequest()) {
try {
$rsp = new Psr7\Response();
$rsp->getBody()->write('Hello world!');

$worker->respond($rsp);
} catch (\Throwable $e) {
$worker->getWorker()->error((string)$e);
}
}
?>
69 changes: 64 additions & 5 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,69 @@
---
# This is an example playbook to execute Ansible tests.

- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Example assertion
ansible.builtin.assert:
that: true
- name: Create the current_release folder
ansible.builtin.file:
dest: "{{ item }}"
state: "directory"
owner: proserver
mode: "0755"
loop:
- "/var/www/current"

- name: Initialize the composer project
community.general.composer:
command: init
arguments: >-
--name punktde/roadrunner-test
--description=
--type=project
--author=
--homepage=
--no-interaction
working_dir: "/var/www/current"

- name: Install PHP dependencies
community.general.composer:
command: require
arguments: "{{ item }}"
working_dir: "/var/www/current"
loop:
- "nyholm/psr7"
- "spiral/roadrunner"
- "spiral/roadrunner-http"

- name: Create the current_release public folder
ansible.builtin.file:
dest: "{{ item }}"
state: "directory"
owner: proserver
mode: "0755"
loop:
- "/var/www/current/public"

- name: Copy the example PHP script
ansible.builtin.copy:
owner: proserver
mode: "0644"
src: "app.php"
dest: "/var/www/current/app.php"

- name: Start the roadrunner-main service
ansible.builtin.service:
name: "roadrunner@main"
state: "started"
enabled: yes

- name: Check that a page returns successfully but fail if the word 'Hello world' is not in the page contents
ansible.builtin.uri:
url: http://localhost:8080
return_content: true
register: this
retries: 3
delay: 3
until: not this.failed
failed_when:
- this is failed
- "'Hello world!' not in this.content"
2 changes: 2 additions & 0 deletions tasks/config-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
dest: "/etc/systemd/system/roadrunner@{{ roadrunner_config.key }}.service"

- name: Start and enable roadrunner@{{ roadrunner_config.key }}.path
tags:
- molecule-idempotence-notest
ansible.builtin.service:
daemon_reload: yes
name: roadrunner@{{ roadrunner_config.key }}.service
Expand Down

0 comments on commit a89303e

Please sign in to comment.