Skip to content

Commit

Permalink
Seperate action for documentation
Browse files Browse the repository at this point in the history
- Shared setup action between workflows
- doc action uses new github pages approach
  • Loading branch information
ajparsons committed Feb 8, 2024
1 parent 975d462 commit 9d85c29
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 32 deletions.
34 changes: 34 additions & 0 deletions .github/actions/setup-twfy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'Setup TWFY'
description: |
Common setup actions to share between workflows
Still relies on the different services being defined in the original action.
inputs:
php_version:
description: "Path to action being checked."

runs:
using: "composite"
steps:

- uses: niden/actions-memcached@v7

- uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php_version }}
extensions: memcached

- name: Get Composer Cache Directory
id: composer-cache
shell: bash
run: echo "dir=$(php composer.phar config cache-files-dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-php-composer-

- name: Set up database and code
shell: bash
run: |
php composer.phar install --no-interaction
57 changes: 57 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Generate docs

permissions:
contents: write
pages: write
id-token: write

on:
push:
branches: ["main"]
workflow_dispatch:

jobs:
docs:
name: Generate documentation
runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v4
with:
submodules: true

- name:
uses: ./.github/actions/setup-twfy
with:
php_version: "7.4"

- name: Build documentation
run: |
sudo apt-get update && sudo apt-get install -y graphviz
rm -rf docs || exit 0
mkdir docs
./vendor/bin/phpdoc
- name: Setup Pages
uses: actions/configure-pages@v3

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: docs

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: docs
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2

- uses: geekyeggo/delete-artifact@v2
with:
name: github-pages
37 changes: 5 additions & 32 deletions .github/workflows/default.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,43 +50,22 @@ jobs:
--health-retries 5
steps:
# - name: Stop any running MySQL
# run: sudo systemctl stop mysql.service
# - uses: chhsiung/github-actions-mysql@0f348ad54f14038adafed5914b5ce775806768ab
# with:
# rootPassword: 'password'
# sqlMode: 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

- uses: niden/actions-memcached@v7

- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_version }}
extensions: memcached

- uses: actions/checkout@v4
with:
submodules: true

- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(php composer.phar config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
- name: Setup TWFY Project
uses: ./.github/actions/setup-twfy
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-php-composer-
php_version: ${{ matrix.php_version }}

- name: Verify MariaDB connection
- name: Verify MariaDB connection and setup database
run: |
while ! mysqladmin ping -h"127.0.0.1" --silent; do
sleep 1
done
- name: Set up database and code
run: |
mysql -h 127.0.0.1 -u root -ppassword twfy_test < db/schema.sql
php composer.phar install --no-interaction
- name: Run tests
env:
Expand All @@ -102,10 +81,4 @@ jobs:
if: matrix.php_version == '7.4'
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
- name: Documentation
if: matrix.php_version == '7.4' && github.ref_name == 'master' && github.event_name == 'push'
run: |
sudo apt-get update && sudo apt-get install -y graphviz
./build-docs.sh
php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml

0 comments on commit 9d85c29

Please sign in to comment.