diff --git a/.github/bin/ci-bootstrap.sh b/.github/bin/ci-bootstrap.sh new file mode 100755 index 0000000..eb71aa0 --- /dev/null +++ b/.github/bin/ci-bootstrap.sh @@ -0,0 +1,166 @@ +#!/bin/bash +# Horde CI Bootstrap Script (GitHub Actions) +# Generated by: horde-components 1.0.0-RC9 +# Template version: 1.5.1 +# Generated: 2026-06-27 08:10:43 UTC +# +# DO NOT EDIT - Regenerate with: horde-components ci init +# +# This script uses the runner's preinstalled PHP (8.3 on ubuntu-24.04). +# horde-components will install additional PHP versions as needed. + +set -e +set -o pipefail + +# Configuration +COMPONENTS_PHAR_URL="${COMPONENTS_PHAR_URL:-https://github.com/horde/components/releases/latest/download/horde-components.phar}" +COMPONENT_NAME="Prefs" +WORK_DIR="/tmp/horde-ci" + +# Colors for output (disabled in CI) +RED='' +GREEN='' +YELLOW='' +NC='' + +# Logging functions +log_info() { + # Bootstrap-stage progress lines stay as plain stdout under + # GitHub Actions. Routing them through ::notice:: would flood the + # Annotations panel with non-actionable entries. log_warn and + # log_error still emit workflow commands because bootstrap-level + # problems (missing GITHUB_TOKEN, download failure, etc.) belong + # in the panel. + echo "[INFO] $*" +} + +log_warn() { + if [ -n "$GITHUB_ACTIONS" ]; then + echo "::warning::$*" + else + echo "[WARN] $*" + fi +} + +log_error() { + if [ -n "$GITHUB_ACTIONS" ]; then + echo "::error::$*" + else + echo "[ERROR] $*" + fi >&2 +} + +# Stage 1: Validate environment +log_info "Horde CI Bootstrap (GitHub Actions mode)" +log_info "Component: $COMPONENT_NAME" + +# Check we're in GitHub Actions +if [ -z "$GITHUB_ACTIONS" ]; then + log_error "This script is for GitHub Actions. Use ci setup --ci-mode=local for local development." + exit 1 +fi + +# Validate required environment variables +if [ -z "$GITHUB_REPOSITORY" ]; then + log_error "GITHUB_REPOSITORY not set" + exit 1 +fi + +if [ -z "$GITHUB_REF" ]; then + log_error "GITHUB_REF not set" + exit 1 +fi + +if [ -z "$GITHUB_TOKEN" ]; then + log_error "GITHUB_TOKEN not set" + exit 1 +fi + +# Stage 2: Verify PHP (use runner's default - PHP 8.3) +if ! command -v php &> /dev/null; then + log_error "PHP not found. ubuntu-24.04 runner should have PHP preinstalled." + exit 1 +fi + +PHP_VERSION=$(php -r 'echo PHP_VERSION;') +log_info "Using runner's PHP version: $PHP_VERSION" + +# Stage 3: Locate horde-components.phar +# +# Lookup order: +# 1. Repo-bundled phar at $GITHUB_WORKSPACE/ci-tools/horde-components.phar +# (committed alongside the workflow for repos that pin a specific build) +# 2. Cached phar from a previous run at $WORK_DIR/bin/horde-components.phar +# 3. Download from $COMPONENTS_PHAR_URL +REPO_PHAR="$GITHUB_WORKSPACE/ci-tools/horde-components.phar" +mkdir -p "$WORK_DIR/bin" +COMPONENTS_PHAR="$WORK_DIR/bin/horde-components.phar" + +if [ -f "$REPO_PHAR" ]; then + log_info "Using repo-bundled horde-components.phar from ci-tools/" + cp "$REPO_PHAR" "$COMPONENTS_PHAR" + chmod +x "$COMPONENTS_PHAR" +elif [ -f "$COMPONENTS_PHAR" ]; then + log_info "Using cached horde-components.phar" +else + log_info "Downloading horde-components from $COMPONENTS_PHAR_URL" + + if ! curl -sS -L -o "$COMPONENTS_PHAR" "$COMPONENTS_PHAR_URL"; then + log_error "Failed to download horde-components.phar" + exit 1 + fi +fi + +# Validate it's a valid phar +if ! php "$COMPONENTS_PHAR" help &> /dev/null; then + log_error "horde-components.phar is not valid or not executable" + exit 1 +fi + +log_info "horde-components.phar ready at $COMPONENTS_PHAR" + +# Stage 4: Install sudo helper script +log_info "Installing sudo helper script" + +# Extract and install the helper script from PHAR +php -r "copy('phar://$COMPONENTS_PHAR/data/ci/sudo-helper.sh', '$WORK_DIR/sudo-helper.sh');" 2>/dev/null || \ + log_warn "Could not extract sudo helper from PHAR (older version?)" + +if [ -f "$WORK_DIR/sudo-helper.sh" ]; then + sudo install -m 755 "$WORK_DIR/sudo-helper.sh" /usr/local/bin/horde-ci-sudo-helper + log_info "Sudo helper installed successfully" +else + log_warn "Sudo helper not found, will try to proceed without it" +fi + +# Stage 5: Handoff to PHP (horde-components ci setup) +log_info "Bootstrap complete. Handing off to horde-components ci setup" + +php "$COMPONENTS_PHAR" ci setup \ + --ci-mode=github \ + --work-dir="$WORK_DIR" \ + --component="$COMPONENT_NAME" + +EXIT_CODE=$? + +if [ $EXIT_CODE -eq 0 ]; then + log_info "CI setup complete. Workspace: $WORK_DIR" +else + log_error "CI setup failed with exit code $EXIT_CODE" + exit $EXIT_CODE +fi + +# Stage 6: Run CI tests +log_info "Running CI tests" + +php "$COMPONENTS_PHAR" ci run \ + --work-dir="$WORK_DIR" + +EXIT_CODE=$? + +if [ $EXIT_CODE -eq 0 ]; then + log_info "CI tests complete" +else + log_error "CI tests failed with exit code $EXIT_CODE" + exit $EXIT_CODE +fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08e7a67..3095da0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,54 +1,58 @@ -# This is a basic workflow to help you get started with Actions - name: CI -# Controls when the action will run. +# Generated by: horde-components 1.0.0-RC9 +# Template version: 1.5.1 +# Generated: 2026-06-27 08:10:43 UTC +# +# DO NOT EDIT - Regenerate with: horde-components ci init +# +# This workflow uses the runner's preinstalled PHP 8.3 for bootstrap. +# horde-components will install additional PHP versions as needed. + on: - # Triggers the workflow on push or pull request events but only for the master branch push: - branches: - - master - - maintaina-composerfixed - - FRAMEWORK_6_0 + branches: [ FRAMEWORK_6_0 ] pull_request: - branches: - - master - - maintaina-composerfixed - - FRAMEWORK_6_0 - - - # Allows you to run this workflow manually from the Actions tab + branches: [ FRAMEWORK_6_0 ] workflow_dispatch: -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - run: - runs-on: ${{ matrix.operating-system }} - strategy: - matrix: - operating-system: ['ubuntu-20.04'] - php-versions: ['7.4', '8.0', 'latest'] - phpunit-versions: ['latest', '9.5'] + ci: + name: CI + runs-on: ubuntu-24.04 + permissions: + contents: read + pull-requests: write + checks: write + steps: - - name: Setup github ssh key - run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2.37.1 - with: - php-version: ${{ matrix.php-versions }} - extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter - ini-values: post_max_size=512M, max_execution_time=360 - coverage: xdebug - tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}, composer:v2 - - name: Setup Github Token as composer credential - run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} - - name: Install horde/test dependency and other dependencies - run: | - ## For unclear reasons, github action fails randomly if we do not install before we require. - COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer install - COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer require --dev horde/test dev-FRAMEWORK_6_0 horde/log dev-FRAMEWORK_6_0 - - name: run phpunit - run: phpunit --bootstrap test/Horde/Prefs/bootstrap.php test/Horde/Prefs/ + - name: Checkout code + uses: actions/checkout@v5 + + - name: Cache horde-components.phar + uses: actions/cache@v5 + with: + path: /tmp/horde-ci/bin + key: components-phar-${{ hashFiles('.github/bin/ci-bootstrap.sh') }} + + - name: Cache QC tools (PHPUnit, PHPStan, PHP-CS-Fixer) + uses: actions/cache@v5 + with: + path: /tmp/horde-ci/tools + key: ci-tools-${{ hashFiles('.horde.yml') }} + + - name: Run CI + run: bash .github/bin/ci-bootstrap.sh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMPONENTS_PHAR_URL: ${{ vars.COMPONENTS_PHAR_URL || 'https://github.com/horde/components/releases/latest/download/horde-components.phar' }} + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v5 + with: + name: ci-results-pr${{ github.event.pull_request.number || github.run_number }}-${{ github.sha }} + path: | + /tmp/horde-ci/lanes/*/Prefs/build/*.json + /tmp/horde-ci/lanes/*/Prefs/build/*.xml + retention-days: 30 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index ce61a52..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,63 +0,0 @@ ---- -name: make release - -# manual workflow to make a new release for the default branch -on: - workflow_dispatch: - branches: - - FRAMEWORK_6_0 -env: - components: "/home/runner/.composer/web/components/bin/horde-components -c /home/runner/.composer/web/components/config/maintaina.conf.dist" - -jobs: - run: - runs-on: ${{ matrix.operating-system }} - strategy: - matrix: - operating-system: ['ubuntu-20.04'] - php-versions: ['7.4'] - steps: - - name: Setup git - run: | - mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts - git config --global user.name "Github CI Runner" - git config --global user.email "ci-job@maintaina.com" - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Setup PHP - uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2.37.1 - with: - php-version: ${{ matrix.php-versions }} - extensions: gettext - ini-values: post_max_size=512M, max_execution_time=360 - tools: composer:v2 - - name: Setup composer - run: | - composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} - composer global config repositories.0 composer https://horde-satis.maintaina.com - composer global config minimum-stability dev - composer config --no-plugins --global allow-plugins.horde/horde-installer-plugin true - composer global require horde/components "dev-FRAMEWORK_6_0" - - name: write changelog - run: | - entries_amount=0; max_entries=100 - PATTERN="^\[.*\] .*" - - for commit in $(git rev-list FRAMEWORK_6_0) - do - msg=$(git log --format=%B -n 1 $commit | head -n 1) - if [ $entries_amount -gt $max_entries ]; then break; fi - if [[ $msg == 'Released'* ]]; then break; fi - if [[ $msg == 'Development mode for'* ]]; then break; fi - if [[ $msg =~ $PATTERN ]]; then - $components changed "$msg" - let "entries_amount+=1" - fi - done - - name: make release and push - run: | - $components release for maintaina - git push - git push origin --tags diff --git a/.github/workflows/update-satis.yml b/.github/workflows/update-satis.yml deleted file mode 100644 index 55f63d0..0000000 --- a/.github/workflows/update-satis.yml +++ /dev/null @@ -1,59 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: Update Satis - -# Controls when the action will run. -on: - # Triggers the workflow on push or pull request events but only for the master branch - push: - branches: - - FRAMEWORK_6_0 - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - run: - runs-on: ubuntu-20.04 - steps: - - name: Setup github ssh key - run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts - - name: Setup uut dir - run: | - export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") - export UUT_DIR=$(pwd) - export WORK_DIR=~ - export BIN_DIR="${WORK_DIR}/bin" - mkdir -p $BIN_DIR - git config --global user.name "PHPDOC CI Job" - git config --global user.email "ci-job@maintaina.com" - - name: Checkout - uses: actions/checkout@v2 - - name: Checkout satis web dir - uses: actions/checkout@v2 - with: - repository: maintaina-com/maintaina-com.github.io - token: ${{secrets.PHPDOC_TOKEN}} - path: "maintaina-com.github.io" - - name: Setup PHP - uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2.37.1 - with: - php-version: 7.4 - extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter - ini-values: post_max_size=512M, max_execution_time=3600 - coverage: xdebug - tools: composer:v2 - - name: Setup Github Token as composer credential - run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} - - name: Run Satis - run: | - export UUT_DIR=$(pwd) - export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") - export WORK_DIR=/home/runner/ - export BIN_DIR="${WORK_DIR}/bin" - composer create-project composer/satis:dev-main - php satis/bin/satis build -vvv maintaina-com.github.io/satis.json maintaina-com.github.io/ horde/${REPO,,} - cd maintaina-com.github.io - git add include/ index.html p2/ packages.json - git commit -m "Update for horde/${REPO,,}" - git push diff --git a/.horde.yml b/.horde.yml index 0626f76..845a249 100644 --- a/.horde.yml +++ b/.horde.yml @@ -10,20 +10,17 @@ list: dev type: library homepage: https://www.horde.org/libraries/Horde_Prefs authors: - - - name: Jan Schneider + - name: Jan Schneider user: jan email: jan@horde.org active: true role: lead - - - name: Michael Slusarz + - name: Michael Slusarz user: slusarz email: slusarz@horde.org active: false role: lead - - - name: Chuck Hagenbuch + - name: Chuck Hagenbuch user: chuck email: chuck@horde.org active: false @@ -71,3 +68,67 @@ dependencies: keywords: - preferences vendor: horde +ci-platform: + '8.0': + - php: '>=7.2' + - composer-plugin-api: ^2.2.0 + - ext-dom + - ext-hash + - ext-ldap + - ext-pcre + - ext-simplexml + - ext-spl + '8.1': + - php: '>=7.2' + - composer-plugin-api: ^2.2.0 + - ext-dom + - ext-hash + - ext-ldap + - ext-pcre + - ext-simplexml + - ext-spl + '8.2': + - php: '>=7.2' + - composer-plugin-api: ^2.2.0 + - ext-dom + - ext-hash + - ext-ldap + - ext-pcre + - ext-simplexml + - ext-spl + '8.3': + - php: '>=7.2' + - composer-plugin-api: ^2.2.0 + - ext-dom + - ext-hash + - ext-ldap + - ext-pcre + - ext-simplexml + - ext-spl + '8.4': + - php: '>=7.2' + - composer-plugin-api: ^2.2.0 + - ext-dom + - ext-hash + - ext-ldap + - ext-pcre + - ext-simplexml + - ext-spl + '8.5': + - php: '>=7.2' + - composer-plugin-api: ^2.2.0 + - ext-dom + - ext-hash + - ext-ldap + - ext-pcre + - ext-simplexml + - ext-spl + '8.6': + - php: '>=7.2' + - composer-plugin-api: ^2.2.0 + - ext-dom + - ext-hash + - ext-ldap + - ext-pcre + - ext-simplexml + - ext-spl