feat(deployment): update Semaphore stack and Traefik configuration
- Add QUICKSTART.md and SETUP_REPOSITORY.md for Semaphore stack - Add playbooks directory for Semaphore deployment - Update Semaphore docker-compose.yml, env.example, and README - Add Traefik local configuration files - Disable semaphore.yml in Traefik dynamic config - Update docker-compose.local.yml and build-image workflow
This commit is contained in:
103
deployment/stacks/semaphore/playbooks/ci-tests.yml
Normal file
103
deployment/stacks/semaphore/playbooks/ci-tests.yml
Normal file
@@ -0,0 +1,103 @@
|
||||
---
|
||||
# CI Tests Playbook f?r Semaphore
|
||||
# F?hrt PHP Tests und Quality Checks aus
|
||||
|
||||
- name: Run CI Tests and Quality Checks
|
||||
hosts: localhost
|
||||
gather_facts: no
|
||||
vars:
|
||||
repo_url: "{{ repo_url | default('https://git.michaelschiemer.de/michael/michaelschiemer.git') }}"
|
||||
repo_branch: "{{ repo_branch | default('main') }}"
|
||||
build_dir: "/tmp/ci-build"
|
||||
|
||||
tasks:
|
||||
- name: Clean up build directory
|
||||
file:
|
||||
path: "{{ build_dir }}"
|
||||
state: absent
|
||||
|
||||
- name: Checkout repository
|
||||
git:
|
||||
repo: "{{ repo_url }}"
|
||||
dest: "{{ build_dir }}"
|
||||
version: "{{ repo_branch }}"
|
||||
force: yes
|
||||
register: git_result
|
||||
|
||||
- name: Display checked out commit
|
||||
debug:
|
||||
msg: "Checked out commit: {{ git_result.after }}"
|
||||
|
||||
- name: Install Composer if not present
|
||||
get_url:
|
||||
url: https://getcomposer.org/installer
|
||||
dest: /tmp/composer-installer.php
|
||||
mode: '0755'
|
||||
when: ansible_facts.os_family == "Debian"
|
||||
|
||||
- name: Install Composer (Debian)
|
||||
shell: php /tmp/composer-installer.php && mv composer.phar /usr/local/bin/composer
|
||||
when: ansible_facts.os_family == "Debian"
|
||||
args:
|
||||
creates: /usr/local/bin/composer
|
||||
|
||||
- name: Install PHP dependencies
|
||||
command: composer install --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-req=php
|
||||
args:
|
||||
chdir: "{{ build_dir }}"
|
||||
register: composer_result
|
||||
|
||||
- name: Display composer output
|
||||
debug:
|
||||
var: composer_result.stdout_lines
|
||||
when: composer_result.stdout_lines is defined
|
||||
|
||||
- name: Run PHP tests
|
||||
command: ./vendor/bin/pest
|
||||
args:
|
||||
chdir: "{{ build_dir }}"
|
||||
register: test_result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Display test results
|
||||
debug:
|
||||
msg: "{{ test_result.stdout_lines }}"
|
||||
when: test_result.stdout_lines is defined
|
||||
|
||||
- name: Run PHPStan
|
||||
command: composer phpstan
|
||||
args:
|
||||
chdir: "{{ build_dir }}"
|
||||
register: phpstan_result
|
||||
ignore_errors: yes
|
||||
when: test_result.rc == 0
|
||||
|
||||
- name: Display PHPStan results
|
||||
debug:
|
||||
msg: "{{ phpstan_result.stdout_lines }}"
|
||||
when: phpstan_result.stdout_lines is defined and phpstan_result.rc == 0
|
||||
|
||||
- name: Run code style check
|
||||
command: composer cs
|
||||
args:
|
||||
chdir: "{{ build_dir }}"
|
||||
register: cs_result
|
||||
ignore_errors: yes
|
||||
when: test_result.rc == 0
|
||||
|
||||
- name: Display code style results
|
||||
debug:
|
||||
msg: "{{ cs_result.stdout_lines }}"
|
||||
when: cs_result.stdout_lines is defined
|
||||
|
||||
- name: Fail if tests failed
|
||||
fail:
|
||||
msg: "Tests failed! Check output above."
|
||||
when: test_result.rc != 0
|
||||
|
||||
- name: Summary
|
||||
debug:
|
||||
msg:
|
||||
- "? CI Tests completed successfully!"
|
||||
- "Commit: {{ git_result.after }}"
|
||||
- "Branch: {{ repo_branch }}"
|
||||
Reference in New Issue
Block a user