Skip to content
Merged
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
85 changes: 44 additions & 41 deletions .github/workflows/updates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ name: "Updates"
on:
schedule:
- cron: "0 1 */3 * *" # At 01:00 on every 3rd day-of-month.
# push:
# branches: 'pipenv-fix'
# push:
# branches: 'drupals'

env:
# Update vars.
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
template: ${{fromJSON(needs.build.outputs.templates)}}
exclude:
# PHP
- template: "drupal8-govcms8"
# - template: "drupal8-govcms8"
- template: "magento2ce"
- template: "pimcore"
- template: "laravel"
Expand Down Expand Up @@ -139,44 +139,47 @@ jobs:
################################
# Working excludes for testing #
################################
# - template: nuxtjs
# - template: lisp
# - template: 'wordpress-woocommerce'
# - template: 'wordpress-bedrock'
# - template: wagtail
# - template: strapi
# - template: mattermost
# - template: golang
# - template: nodejs
# - template: wordpress-composer
# - template: meilisearch
# - template: drupal9
# - template: 'drupal8-multisite'
# - template: 'drupal8'
# - template: django2
# - template: nextcloud
# - template: gatsby
# - template: strapi4
# - template: flask
# - template: php
# - template: django3
# - template: python3
# - template: python3-uwsgi
# - template: pyramid
# - template: rails
# - template: hugo
# - template: backdrop
# - template: gin
# - template: beego
# - template: pelican
# - template: probot
# - template: nextjs
# - template: koa
# - template: django4
# - template: express
# - template: echo
# - template: fastapi
# - template: 'drupal8-opigno'
# - template: contentacms
# - template: koa
# - template: wagtail
# - template: backdrop
# - template: drupal8
# - template: wordpress-bedrock
# - template: wordpress-composer
# - template: django2
# - template: rails
# - template: echo
# - template: beego
# - template: nodejs
# - template: django4
# - template: nuxtjs
# - template: drupal8-opigno
# - template: nextcloud
# - template: drupal9-multisite
# - template: mattermost
# - template: gatsby
# - template: hugo
# - template: drupal8-multisite
# - template: php
# - template: django3
# - template: lisp
# - template: wordpress-woocommerce
# - template: golang
# - template: express
# - template: strapi4
# - template: python3-uwsgi
# - template: python3
# - template: nextjs
# - template: meilisearch
# - template: drupal9
# - template: flask
# - template: fastapi
# - template: pyramid
# - template: contentacms
# - template: gin
# - template: pelican



steps:
# Before beginning we need set up all our tools and dependencies
Expand Down
248 changes: 248 additions & 0 deletions common/.preload/preloader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
<?php

// https://github.com/cloudpanel-io/clp-opcache-preloader

error_reporting((E_ALL | E_STRICT) ^ E_NOTICE);
//ini_set('display_errors', 1);

class ClpPreloader
{
/**
* @var array
*/
private $ignores = [];

/**
* @var array
*/
private $paths = [];

/**
* @var array
*/
private $loaded = [];

/**
* @var int
*/
private $count = 0;

/**
* @var bool
*/
private $debug = false;

/**
* @var array
*/
private $included = [];

/**
* Constructor
*
* @param string $paths
*/
public function __construct(string ...$paths)
{
$this->paths = $paths;
}

/**
* Paths
*
* Path to load
*
* @param string $paths
*
* @return $this
*/
public function paths(string ...$paths): void
{
$this->paths = \array_merge(
$this->paths,
$paths
);
}

/**
* Ignore
*
* Ignore a given path or file
*
* @param string $names
*
* @return $this
*/
public function ignore(string ...$names): void
{
foreach ($names as $name) {
if (true === is_readable($name)) {
$this->ignores[] = $name;
} else {
if (true === $this->debug) {
echo sprintf('Preloader] Failed to ignore path %s', $name).PHP_EOL;
}
}
}
}

/**
* Preload
*/
public function preload(): void
{
$this->loaded = get_included_files();
foreach ($this->paths as $path) {
$path = \rtrim($path, '/');
$this->loadPath($path);
}
if (true === $this->debug) {
echo sprintf('[Preloader] Preloaded: %s files', $this->count).PHP_EOL;
}
}

/**
* Get Count
*
* Get the total number of loaded files.
*
* @return int
*/
public function getCount(): int
{
return $this->count;
}

/**
* Get List
*
* @return array
*/
public function getList(): array
{
return $this->included;
}

/**
* Set Debug
*
* @param bool $flag
*/
public function setDebug(bool $flag = true): void
{
$this->debug = $flag;
}

/**
* Load Path
*
* Load a specific file or folder and nested folders.
*
* @param string $path
* @return void
*/
private function loadPath(string $path): void
{
if (true === \is_dir($path)) {
$this->loadDir($path);
return;
}
$this->loadFile($path);
}

/**
* Load Directory
*
* Load a specific folder and nested folders.
*
* @param string $path
* @return void
*/
private function loadDir(string $path): void
{
$handle = \opendir($path);
while ($file = \readdir($handle)) {
if (true === \in_array($file, ['.', '..'])) {
continue;
}
$this->loadPath("{$path}/{$file}");
}
\closedir($handle);
}

/**
* Load File
*
* Load a specific file.
*
* @param string $path
* @return void
*/
private function loadFile(string $path): void
{
if (true === $this->shouldIgnore($path)) {
return;
}
if (true === \in_array(\realpath($path), $this->included)) {
if (true === $this->debug) {
echo sprintf('[Preloader] Skipped: %s', $path).PHP_EOL;
}
return;
}
if (true === \in_array(\realpath($path), $this->loaded)) {
if (true === $this->debug) {
echo sprintf('[Preloader] Skipped: %s', $path).PHP_EOL;
}
return;
}
try {
require $path;
} catch (\Throwable $th) {
if (true === $this->debug) {
echo sprintf('[[Preloader] Failed to load: %s, Error Message: %s', $path, $th->getMessage()).PHP_EOL;
}
return;
}
$this->loaded = get_included_files();
$this->included[] = $path;
$this->count++;
}

/**
* Should Ignore
*
* Should a given path be ignored or not?
*
* @param string $path
* @return bool
*/
private function shouldIgnore(?string $path): bool
{
if ($path === null) {
return true;
}
$pathExtension = \pathinfo($path, PATHINFO_EXTENSION);
if (false === \in_array($pathExtension, ['php']) || 'html.php' == substr($path, -8) || 'tpl.php' == substr($path, -7)) {
return true;
}
foreach ($this->ignores as $ignore) {
if (\strpos($path, $ignore) === 0) {
return true;
}
}
return false;
}
}

$vendorDirectory = __DIR__.'/vendor/';
$vendorAutoloadFile = sprintf('%s/autoload.php', \rtrim($vendorDirectory, '/'));
if (true === file_exists($vendorAutoloadFile)) {
require $vendorAutoloadFile;
}

$clpPreloader = new ClpPreloader();
$clpPreloader->setDebug(false);
$clpPreloader->paths(realpath(__DIR__ . '/src'));
$clpPreloader->paths(realpath(__DIR__ . '/vendor'));
$clpPreloader->ignore(realpath(__DIR__ . '/vendor/twig/twig'));
$clpPreloader->preload();
Loading