Skip to content

Move .github actions directory #1

Move .github actions directory

Move .github actions directory #1

Workflow file for this run

name: COmanage Registry setup + PHPUnit (multi-PHP, multi-DB)
on:
workflow_dispatch:
push:
pull_request:
jobs:
setup-and-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ["8.3", "8.4", "8.5"]
db_engine: ["postgres", "mysql", "mariadb"]
env:
COMANAGE_REGISTRY_DIR: /srv/comanage-registry
COMANAGE_REGISTRY_URL_PATH: registry
COMANAGE_REGISTRY_VERSION: develop
# COMANAGE_REGISTRY_SRC_URL is computed dynamically in a step.
# Values used by your PHPUnit setup test
COMANAGE_REGISTRY_ADMIN_GIVEN_NAME: Admin
COMANAGE_REGISTRY_ADMIN_FAMILY_NAME: User
COMANAGE_REGISTRY_ADMIN_USERNAME: admin
COMANAGE_REGISTRY_SECURITY_SALT: phpunit-security-salt
# Values used by tests/bootstrap.php to create containers (host/port are set dynamically after start)
COMANAGE_REGISTRY_DATABASE: registry_test
COMANAGE_REGISTRY_DATABASE_USER: test_user
COMANAGE_REGISTRY_DATABASE_USER_PASSWORD: test_password
COMANAGE_REGISTRY_DATABASE_PERSISTENT: "false"
steps:
- name: Checkout (only for workflow files)
uses: actions/checkout@v4
- name: Setup PHP (recommended approach)
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none
extensions: >
mbstring, json, openssl, intl, ldap, xml, zlib, sodium,
pdo, pdo_mysql, pdo_pgsql, gd, xsl, memcached, pcntl, posix
- name: Compute COMANAGE_REGISTRY_SRC_URL
shell: bash
run: |
set -euo pipefail
echo "COMANAGE_REGISTRY_SRC_URL=https://github.internet2.edu/COmanage/registry/archive/${COMANAGE_REGISTRY_VERSION}.tar.gz" >> "$GITHUB_ENV"
- name: Show versions
shell: bash
run: |
set -euxo pipefail
php -v
composer --version
docker --version
- name: Install OS packages needed for setup
shell: bash
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
wget curl tar ca-certificates \
git unzip \
libicu-dev \
libldap2-dev \
libxml2 \
zlib1g \
libsodium23 \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
libxslt1.1 \
libmemcached11
- name: Create apache user/group (to match your chown step)
shell: bash
run: |
set -euxo pipefail
if ! getent group apache >/dev/null; then
sudo groupadd --system apache
fi
if ! id -u apache >/dev/null 2>&1; then
sudo useradd --system --no-create-home --gid apache apache
fi
- name: Download and unpack COmanage Registry (${COMANAGE_REGISTRY_VERSION})
shell: bash
env:
GHE_TOKEN: ${{ secrets.GHE_TOKEN }}
run: |
set -euxo pipefail
sudo mkdir -p "${COMANAGE_REGISTRY_DIR}"
sudo rm -rf "${COMANAGE_REGISTRY_DIR:?}/"*
# If your GitHub Enterprise requires auth, use token. If not needed, wget/curl will still work.
if [ -n "${GHE_TOKEN:-}" ]; then
curl -fL \
-H "Authorization: token ${GHE_TOKEN}" \
-o /tmp/comanage.tar.gz \
"${COMANAGE_REGISTRY_SRC_URL}"
else
wget -O /tmp/comanage.tar.gz "${COMANAGE_REGISTRY_SRC_URL}"
fi
sudo tar -zxf /tmp/comanage.tar.gz -C "${COMANAGE_REGISTRY_DIR}" --strip-components=1
rm -f /tmp/comanage.tar.gz
sudo rm -rf "${COMANAGE_REGISTRY_DIR}/local/"*
- name: Create local tmp/cache + webroot symlink
shell: bash
run: |
set -euxo pipefail
sudo mkdir -p "${COMANAGE_REGISTRY_DIR}/local"
sudo mkdir -p /var/cache/registry/tmp
sudo rm -rf "${COMANAGE_REGISTRY_DIR}/local/tmp"
sudo ln -s /var/cache/registry/tmp "${COMANAGE_REGISTRY_DIR}/local/tmp"
sudo chown -h apache:apache "${COMANAGE_REGISTRY_DIR}/local/tmp"
sudo mkdir -p /var/www/html
sudo rm -f "/var/www/html/${COMANAGE_REGISTRY_URL_PATH}"
sudo ln -s "${COMANAGE_REGISTRY_DIR}/app/webroot" "/var/www/html/${COMANAGE_REGISTRY_URL_PATH}"
echo "Registry URL path is: ${COMANAGE_REGISTRY_URL_PATH}"
echo "Registry Version is: ${COMANAGE_REGISTRY_VERSION}"
- name: Composer install (app/)
shell: bash
working-directory: /srv/comanage-registry/app
run: |
set -euxo pipefail
composer install --no-interaction --no-progress
- name: Run PHPUnit (DB_ENGINE=${{ matrix.db_engine }})
shell: bash
working-directory: /srv/comanage-registry/app
env:
DB_ENGINE: ${{ matrix.db_engine }}
run: |
set -euxo pipefail
DB_ENGINE="${DB_ENGINE}" vendor/bin/phpunit --testsuite app