Skip to content

Commit

Permalink
chore: add docs build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
yenfryherrerafeliz committed Feb 7, 2024
1 parent a85127e commit 1f9756a
Showing 1 changed file with 128 additions and 0 deletions.
128 changes: 128 additions & 0 deletions .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Docs Build Workflow

on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build_docs:
runs-on: ubuntu-20.04
strategy:
matrix:
php-versions: ['5.6']
composer-options: ['']
name: Build Docs Test for PHP ${{ matrix.php-versions }} ${{ matrix.composer-options }}
steps:
- name: Setup PHP with Xdebug
uses: shivammathur/setup-php@v2
with:
coverage: xdebug
php-version: ${{ matrix.php-versions }}
ini-values: xdebug.overload_var_dump=0, memory_limit=4G, phar.readonly=false

- name: Checkout CodeBase
uses: actions/checkout@v4

- name: Replace Platform Requirements
run: |
sed -i 's/"php": ">=7.2.5"/"php": ">=5.6.0"/g' composer.json
- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer update ${{ matrix.composer-options }} --no-interaction --prefer-source

- name: Prepare OS Environment
run: |
sudo sed -i s/deb.debian.org/archive.debian.org/g /etc/apt/sources.list
sudo sed -i 's|security.debian.org|archive.debian.org/|g' /etc/apt/sources.list
sudo sed -i '/stretch-updates/d' /etc/apt/sources.list
sudo apt-get -y update && \
sudo apt-get -y install git wget zip unzip libzip-dev libssl-dev libtidy-dev python3 cmake python3-distutils-extra python3-apt
curl -O https://bootstrap.pypa.io/pip/3.5/get-pip.py && \
python3 get-pip.py && \
rm get-pip.py && \
pip install awscli
# Git Secrets Install
cd /usr/local/bin && \
curl -sO https://raw.githubusercontent.com/awslabs/git-secrets/master/git-secrets && \
chmod -R +x ./git-secrets

curl -s https://raw.githubusercontent.com/mtdowling/chag/master/install.sh | sudo bash

PHP_CONF_DIR=$(php -i | grep "Scan this dir for additional .ini files" | awk '{print $9}')
sudo touch "$PHP_CONF_DIR"/memory.ini \
&& sudo chmod 666 "$PHP_CONF_DIR"/memory.ini \
&& sudo echo "memory_limit = 5048M;" >> "$PHP_CONF_DIR"/memory.ini

sudo touch "$PHP_CONF_DIR"/phar.ini \
&& sudo chmod 666 "$PHP_CONF_DIR"/phar.ini \
&& sudo echo "phar.readonly = Off;" >> "$PHP_CONF_DIR"/phar.ini

sudo touch "$PHP_CONF_DIR"/timezone.ini \
&& sudo chmod 666 "$PHP_CONF_DIR"/timezone.ini \
&& sudo echo "date.timezone ='America/New_York'" >> "$PHP_CONF_DIR"/timezone.ini

- name: Prepare Function Return Hints Script
run: |
cat << EOF > replacer.php
<?php
if ($argc < 3) {
die("Usage: php remove-return-types.php <targetDir> <excludedDir>\n");
}
$targetDir = $argv[1];
$excludedDir = $argv[2];
$dirIterator = new RecursiveDirectoryIterator(
$targetDir,
RecursiveDirectoryIterator::SKIP_DOTS
);
$iterator = new RecursiveIteratorIterator(
new RecursiveCallbackFilterIterator(
$dirIterator,
function ($current, $key, $iterator) use ($excludedDir) {
// Exclude data directory
if ($current->isDir() && $current->getRealPath() == realpath($excludedDir)) {
return false;
}
return $current->getExtension() === 'php' || $current->isDir();
}
)
);
foreach ($iterator as $file) {
if ($file->isFile()) {
processFile($file->getRealPath());
}
}
function processFile($file)
{
$sourceCode = file_get_contents($file);
$pattern = '/(function\s+\w+\([^)]*\))\s*:\s*?\??\w+\s*\n\s*\{/';
if (preg_match($pattern, $sourceCode)) {
$newSourceCode = preg_replace($pattern, '$1 {', $sourceCode);
file_put_contents($file, $newSourceCode);
}
}
echo "Removed return types for doc generation!\n";
EOF
- name: Run Function Return Hits Removal
run: |
php replacer.php ./src ./vendor \
&& rm -f replacer.php
- name: Run Docs Build
run: |
make package \
&& make api-get-apigen \
&& make api

0 comments on commit 1f9756a

Please sign in to comment.