Skip to content

Commit b4e96ac

Browse files
committed
feat(ci): add GitHub Actions CI workflow with components v1.0.0-alpha27
Deploy horde-components CI system for automated testing. Features: - GitHub Actions workflow with multi-version PHP testing (8.2-8.5) - Tool caching (PHPUnit, PHPStan, PHP-CS-Fixer) - Test result artifact upload - Bootstrap script for CI setup - Organization variable support (COMPONENTS_PHAR_URL) - Manual workflow dispatch with PHP version selection Generated with: horde-components v1.0.0-alpha27 ci init Template version: 1.0.0 Related to Phase 3 deployment of horde-components CI infrastructure.
1 parent 236ee89 commit b4e96ac

File tree

2 files changed

+177
-49
lines changed

2 files changed

+177
-49
lines changed

.github/workflows/ci.yml

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,62 @@
1-
# This is a basic workflow to help you get started with Actions
2-
31
name: CI
42

5-
# Controls when the action will run.
3+
# Generated by: horde-components 1.0.0-alpha27
4+
# Template version: 1.0.0
5+
# Generated: 2026-03-03 18:18:42 UTC
6+
#
7+
# DO NOT EDIT - Regenerate with: horde-components ci init
8+
69
on:
7-
# Triggers the workflow on push or pull request events but only for the master branch
810
push:
9-
branches:
10-
- master
11-
- maintaina-composerfixed
12-
- FRAMEWORK_6_0
11+
branches: [ FRAMEWORK_6_0 ]
1312
pull_request:
14-
branches:
15-
- master
16-
- maintaina-composerfixed
17-
- FRAMEWORK_6_0
18-
19-
20-
# Allows you to run this workflow manually from the Actions tab
13+
branches: [ FRAMEWORK_6_0 ]
2114
workflow_dispatch:
15+
inputs:
16+
php_versions:
17+
description: 'PHP versions to test (comma-separated, e.g., 8.2,8.4)'
18+
required: false
19+
default: 'all'
2220

23-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
2421
jobs:
25-
run:
26-
runs-on: ${{ matrix.operating-system }}
27-
strategy:
28-
matrix:
29-
operating-system: ['ubuntu-20.04']
30-
php-versions: ['7.4', '8.0', 'latest']
31-
phpunit-versions: ['latest', '9.5']
22+
test:
23+
runs-on: ubuntu-24.04
24+
3225
steps:
33-
- name: Setup github ssh key
34-
run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts
35-
- name: Checkout
36-
uses: actions/checkout@v2
37-
38-
- name: Setup PHP
39-
uses: shivammathur/setup-php@v2
40-
with:
41-
php-version: ${{ matrix.php-versions }}
42-
extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter
43-
ini-values: post_max_size=512M, max_execution_time=360
44-
coverage: xdebug
45-
tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}, composer:v2
46-
- name: Setup Github Token as composer credential
47-
run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
48-
- name: Install horde/test dependency and other dependencies
49-
run: |
50-
COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer config minimum-stability dev
51-
COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer install
52-
COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer require --dev horde/test dev-FRAMEWORK_6_0
53-
- name: Redo install due to many fails
54-
run: |
55-
COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer install
56-
COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer require --dev horde/test dev-FRAMEWORK_6_0
57-
- name: run phpunit
58-
run: phpunit --bootstrap test/bootstrap.php
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
29+
- name: Setup PHP 8.4 (for bootstrap)
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: '8.4'
33+
extensions: json, mbstring, curl
34+
coverage: none
35+
36+
- name: Cache QC tools (PHPUnit, PHPStan, PHP-CS-Fixer)
37+
uses: actions/cache@v4
38+
with:
39+
path: /tmp/horde-ci/tools
40+
key: ci-tools-${{ hashFiles('.horde.yml') }}
41+
restore-keys: |
42+
ci-tools-
43+
44+
- name: CI Setup
45+
run: bash bin/ci-bootstrap.sh
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
COMPONENTS_PHAR_URL: ${{ vars.COMPONENTS_PHAR_URL || 'https://github.com/horde/components/releases/latest/download/horde-components.phar' }}
49+
50+
- name: CI Run
51+
run: |
52+
php /tmp/horde-ci/bin/horde-components.phar ci run \
53+
--work-dir=/tmp/horde-ci
54+
55+
- name: Upload test results
56+
if: always()
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: ci-results-${{ github.run_number }}
60+
path: |
61+
/tmp/horde-ci/lanes/*/build/*.json
62+
retention-days: 30

bin/ci-bootstrap.sh

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/bin/bash
2+
# Horde CI Bootstrap Script (GitHub Actions)
3+
# Generated by: horde-components 1.0.0-alpha27
4+
# Template version: 1.0.0
5+
# Generated: 2026-03-03 18:18:42 UTC
6+
#
7+
# DO NOT EDIT - Regenerate with: horde-components ci init
8+
9+
set -e
10+
set -o pipefail
11+
12+
# Configuration
13+
BOOTSTRAP_PHP_VERSION="8.4"
14+
COMPONENTS_PHAR_URL="https://github.com/horde/components/releases/latest/download/horde-components.phar"
15+
COMPONENT_NAME="Http"
16+
WORK_DIR="/tmp/horde-ci"
17+
18+
# Colors for output (disabled in CI)
19+
RED=''
20+
GREEN=''
21+
YELLOW=''
22+
NC=''
23+
24+
# Logging functions
25+
log_info() {
26+
if [ -n "$GITHUB_ACTIONS" ]; then
27+
echo "::notice::$*"
28+
else
29+
echo "[INFO] $*"
30+
fi
31+
}
32+
33+
log_warn() {
34+
if [ -n "$GITHUB_ACTIONS" ]; then
35+
echo "::warning::$*"
36+
else
37+
echo "[WARN] $*"
38+
fi
39+
}
40+
41+
log_error() {
42+
if [ -n "$GITHUB_ACTIONS" ]; then
43+
echo "::error::$*"
44+
else
45+
echo "[ERROR] $*"
46+
fi >&2
47+
}
48+
49+
# Stage 1: Validate environment
50+
log_info "Horde CI Bootstrap - Stage 1 (GitHub Actions mode)"
51+
log_info "Component: $COMPONENT_NAME"
52+
log_info "Bootstrap PHP: $BOOTSTRAP_PHP_VERSION"
53+
54+
# Check we're in GitHub Actions
55+
if [ -z "$GITHUB_ACTIONS" ]; then
56+
log_error "This script is for GitHub Actions. Use bootstrap-local.sh for local development."
57+
exit 1
58+
fi
59+
60+
# Validate required environment variables
61+
if [ -z "$GITHUB_REPOSITORY" ]; then
62+
log_error "GITHUB_REPOSITORY not set"
63+
exit 1
64+
fi
65+
66+
if [ -z "$GITHUB_REF" ]; then
67+
log_error "GITHUB_REF not set"
68+
exit 1
69+
fi
70+
71+
if [ -z "$GITHUB_TOKEN" ]; then
72+
log_error "GITHUB_TOKEN not set"
73+
exit 1
74+
fi
75+
76+
# Stage 2: Verify PHP
77+
if ! command -v php &> /dev/null; then
78+
log_error "PHP not found. Ensure setup-php action runs before this script."
79+
exit 1
80+
fi
81+
82+
PHP_VERSION=$(php -r 'echo PHP_VERSION;')
83+
log_info "PHP version: $PHP_VERSION"
84+
85+
if [ "${PHP_VERSION:0:3}" != "$BOOTSTRAP_PHP_VERSION" ]; then
86+
log_warn "Expected PHP $BOOTSTRAP_PHP_VERSION, got $PHP_VERSION (proceeding anyway)"
87+
fi
88+
89+
# Stage 3: Download horde-components.phar
90+
log_info "Downloading horde-components from $COMPONENTS_PHAR_URL"
91+
92+
mkdir -p "$WORK_DIR/bin"
93+
COMPONENTS_PHAR="$WORK_DIR/bin/horde-components.phar"
94+
95+
if ! curl -sS -L -o "$COMPONENTS_PHAR" "$COMPONENTS_PHAR_URL"; then
96+
log_error "Failed to download horde-components.phar"
97+
exit 1
98+
fi
99+
100+
# Validate it's a valid phar
101+
if ! php "$COMPONENTS_PHAR" --version &> /dev/null; then
102+
log_error "Downloaded phar is not valid or not executable"
103+
exit 1
104+
fi
105+
106+
log_info "horde-components.phar downloaded successfully"
107+
php "$COMPONENTS_PHAR" --version
108+
109+
# Stage 4: Handoff to PHP (horde-components ci setup)
110+
log_info "Bootstrap complete. Handing off to horde-components ci setup"
111+
112+
php "$COMPONENTS_PHAR" ci setup \
113+
--mode=github \
114+
--work-dir="$WORK_DIR" \
115+
--component="$COMPONENT_NAME"
116+
117+
EXIT_CODE=$?
118+
119+
if [ $EXIT_CODE -eq 0 ]; then
120+
log_info "CI setup complete. Workspace: $WORK_DIR"
121+
else
122+
log_error "CI setup failed with exit code $EXIT_CODE"
123+
exit $EXIT_CODE
124+
fi

0 commit comments

Comments
 (0)