Skip to content

CFM-505_Github_actions_bootstraping_and_comanage_setup_testing #372

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 153 additions & 0 deletions .github/workflows/registry-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
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
23 changes: 0 additions & 23 deletions app/.github/ISSUE_TEMPLATE.md

This file was deleted.

14 changes: 0 additions & 14 deletions app/.github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

82 changes: 0 additions & 82 deletions app/.github/workflows/ci.yml

This file was deleted.

23 changes: 0 additions & 23 deletions app/.github/workflows/stale.yml

This file was deleted.

7 changes: 5 additions & 2 deletions app/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"cakephp/debug_kit": "^5.0.0",
"josegonzalez/dotenv": "^4.0",
"phpunit/phpunit": "^10.5.5 || ^11.1.3 || ^12.1",
"psy/psysh": "@stable"
"psy/psysh": "@stable",
"symfony/http-client": "^7.4",
"testcontainers/testcontainers": "^1.0"
},
"suggest": {
"markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.",
Expand Down Expand Up @@ -89,8 +91,9 @@
"config": {
"sort-packages": true,
"allow-plugins": {
"cakephp/plugin-installer": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"cakephp/plugin-installer": true
"php-http/discovery": true
}
}
}
Loading