mirror of
https://code.castopod.org/adaures/castopod.git
synced 2024-09-28 12:41:47 +02:00
ci(gitlabci): add easy-coding-standard check for code-style + fix quality scripts
This commit is contained in:
parent
aa1612342e
commit
6802bee0db
@ -13,74 +13,62 @@ cache:
|
|||||||
before_script:
|
before_script:
|
||||||
- apt-get update -y
|
- apt-get update -y
|
||||||
|
|
||||||
# Install git (the php image doesn't have it) which is required by composer
|
# Install git which is required by composer (the php image doesn't have it)
|
||||||
- apt-get install git -y
|
- apt-get install git -y
|
||||||
|
|
||||||
- apt-get install -y libicu-dev
|
- apt-get install -y libicu-dev
|
||||||
|
|
||||||
# Install intl PHP extension
|
# Install intl PHP extension for tests
|
||||||
- docker-php-ext-install intl
|
- docker-php-ext-install intl
|
||||||
|
|
||||||
# install rsync for file transfers
|
|
||||||
- apt-get install rsync -y
|
|
||||||
|
|
||||||
# install wget to download archives
|
|
||||||
- apt-get install wget
|
|
||||||
|
|
||||||
# Install composer
|
# Install composer
|
||||||
- apt-get install zip unzip
|
|
||||||
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
||||||
- php composer-setup.php
|
- php composer-setup.php
|
||||||
- php -r "unlink('composer-setup.php');"
|
- php -r "unlink('composer-setup.php');"
|
||||||
|
|
||||||
# Install NodeJS for NPM
|
# Install NodeJS for NPM
|
||||||
- curl -sL https://deb.nodesource.com/setup_12.x | bash -
|
- curl -sL https://deb.nodesource.com/setup_lts.x | bash -
|
||||||
- apt-get update && apt-get install -y nodejs
|
- apt-get update && apt-get install -y nodejs
|
||||||
|
|
||||||
# Install all php and js dependencies
|
# Install all php dependencies
|
||||||
- php composer.phar install --prefer-dist --no-ansi --no-interaction --no-progress --ignore-platform-reqs
|
- php composer.phar install --prefer-dist --no-ansi --no-interaction --no-progress --ignore-platform-reqs
|
||||||
- npm install
|
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
stage: quality
|
stage: quality
|
||||||
script:
|
script:
|
||||||
- composer test
|
# run phpunit without code coverage
|
||||||
|
# TODO: add code coverage
|
||||||
|
- vendor/bin/phpunit --no-coverage
|
||||||
|
|
||||||
analysis:
|
code-style:
|
||||||
stage: quality
|
stage: quality
|
||||||
script:
|
script:
|
||||||
# run phpstan
|
- vendor/bin/ecs check --ansi
|
||||||
- composer analyse
|
|
||||||
|
static-analysis:
|
||||||
|
stage: quality
|
||||||
|
script:
|
||||||
|
- vendor/bin/phpstan analyse --ansi
|
||||||
|
|
||||||
code-review:
|
code-review:
|
||||||
stage: quality
|
stage: quality
|
||||||
script:
|
script:
|
||||||
- composer rector
|
- vendor/bin/rector process --dry-run --ansi
|
||||||
|
|
||||||
bundle_app:
|
bundle_app:
|
||||||
stage: bundle
|
stage: bundle
|
||||||
script:
|
script:
|
||||||
# delete installed git hooks because captainhooks (dev dependency) will be removed
|
# make scripts/bundle.sh executable
|
||||||
- rm -rf ./.git/hooks
|
- chmod +x ./scripts/bundle-prepare.sh
|
||||||
|
- chmod +x ./scripts/bundle.sh
|
||||||
|
|
||||||
# remove dev dependencies using the --no-dev option
|
# bundle castopod-host with commit ref as version
|
||||||
- php composer.phar install --no-dev --prefer-dist --no-ansi --no-interaction --no-progress --ignore-platform-reqs
|
- ./scripts/bundle-prepare.sh
|
||||||
|
- ./scripts/bundle.sh ${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHORT_SHA}
|
||||||
# build all UI assets
|
|
||||||
- npm run build
|
|
||||||
|
|
||||||
# download GeoLite2-City archive and extract it to writable/uploads
|
|
||||||
- wget -c "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=$MAXMIND_LICENCE_KEY&suffix=tar.gz" -O - | tar -xz -C ./writable/uploads/
|
|
||||||
|
|
||||||
# rename extracted archives' folders
|
|
||||||
- mv ./writable/uploads/GeoLite2-City* ./writable/uploads/GeoLite2-City
|
|
||||||
|
|
||||||
# create bundle folder: uses .rsync-filter (-F) file to copy only needed files
|
|
||||||
- rsync -aF --progress . ./castopod-host
|
|
||||||
artifacts:
|
artifacts:
|
||||||
name: "castopod-host-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHORT_SHA}"
|
name: "castopod-host-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHORT_SHA}"
|
||||||
paths:
|
paths:
|
||||||
- castopod-host
|
- castopod-host-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHORT_SHA}
|
||||||
except:
|
except:
|
||||||
- main
|
- main
|
||||||
- beta
|
- beta
|
||||||
@ -89,12 +77,13 @@ bundle_app:
|
|||||||
release_app:
|
release_app:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
# install required packages for prepare-release.sh script
|
# make release scripts executable
|
||||||
- apt-get install jq -y
|
- chmod +x ./scripts/bundle-prepare.sh
|
||||||
- apt-get install zip -y
|
- chmod +x ./scripts/bundle.sh
|
||||||
|
- chmod +x ./scripts/package.sh
|
||||||
|
|
||||||
# make scripts/prepare-release.sh executable
|
# prepare bundle before release, both bundle and package scripts will be run by semantic-release
|
||||||
- chmod +x ./scripts/prepare-release.sh
|
- ./scripts/bundle-prepare.sh
|
||||||
|
|
||||||
# IMPORTANT: delete local git tags before release to prevent eventual script failure (ie. tag already exists)
|
# IMPORTANT: delete local git tags before release to prevent eventual script failure (ie. tag already exists)
|
||||||
- git tag | xargs git tag -d
|
- git tag | xargs git tag -d
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
[
|
[
|
||||||
"@semantic-release/exec",
|
"@semantic-release/exec",
|
||||||
{
|
{
|
||||||
"prepareCmd": "./scripts/prepare-release.sh ${nextRelease.version}"
|
"prepareCmd": "./scripts/bundle.sh ${nextRelease.version} && ./scripts/package.sh"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"@semantic-release/npm",
|
"@semantic-release/npm",
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
FROM php:8.0-fpm
|
FROM php:8.0-fpm
|
||||||
|
|
||||||
LABEL maintainer="Yassine Doghri<yassine@podlibre.org>"
|
LABEL maintainer="Yassine Doghri <yassine@doghri.fr>"
|
||||||
|
|
||||||
COPY . /castopod-host
|
COPY . /castopod-host
|
||||||
WORKDIR /castopod-host
|
WORKDIR /castopod-host
|
||||||
@ -38,7 +38,7 @@ RUN apt-get update && apt-get install -y \
|
|||||||
&& docker-php-ext-install intl
|
&& docker-php-ext-install intl
|
||||||
|
|
||||||
RUN docker-php-ext-configure gd --with-jpeg \
|
RUN docker-php-ext-configure gd --with-jpeg \
|
||||||
&& docker-php-ext-install gd
|
&& docker-php-ext-install gd
|
||||||
|
|
||||||
RUN pecl install -o -f redis \
|
RUN pecl install -o -f redis \
|
||||||
&& rm -rf /tmp/pear \
|
&& rm -rf /tmp/pear \
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
'class' => 'form-input mb-4',
|
'class' => 'form-input mb-4',
|
||||||
'value' => old(
|
'value' => old(
|
||||||
'hostname',
|
'hostname',
|
||||||
host_url( === null) ? config('App')->baseURL : host_url(),
|
host_url() === null ? config('App')->baseURL : host_url(),
|
||||||
),
|
),
|
||||||
'required' => 'required',
|
'required' => 'required',
|
||||||
]) ?>
|
]) ?>
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use CodeIgniter\Pager\PagerRenderer;
|
use CodeIgniter\Pager\PagerRenderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @copyright 2020 Podlibre
|
|
||||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
||||||
* @link https://castopod.org/
|
|
||||||
*
|
|
||||||
* @var PagerRenderer $pager
|
* @var PagerRenderer $pager
|
||||||
*/
|
*/
|
||||||
$pager->setSurroundCount(2);
|
$pager->setSurroundCount(2);
|
||||||
|
12
scripts/bundle-prepare.sh
Normal file
12
scripts/bundle-prepare.sh
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# delete possibly installed git hooks because captainhooks (dev dependency)
|
||||||
|
# isn't included in the production dependencies
|
||||||
|
rm -rf ./.git/hooks
|
||||||
|
|
||||||
|
# install only dev dependencies using the --no-dev option
|
||||||
|
php composer.phar install --no-dev --prefer-dist --no-ansi --no-interaction --no-progress --ignore-platform-reqs
|
||||||
|
|
||||||
|
# install js dependencies and build all production UI assets
|
||||||
|
npm install
|
||||||
|
npm run build
|
@ -4,20 +4,23 @@ VERSION=$1
|
|||||||
COMPOSER_VERSION=$(echo "$VERSION" | perl -pe 's/(?<=[alpha|beta])\.//g')
|
COMPOSER_VERSION=$(echo "$VERSION" | perl -pe 's/(?<=[alpha|beta])\.//g')
|
||||||
|
|
||||||
# replace composer.json version using jq
|
# replace composer.json version using jq
|
||||||
|
apt-get install jq -y
|
||||||
echo "$( jq '.version = "'$COMPOSER_VERSION'"' composer.json )" > composer.json
|
echo "$( jq '.version = "'$COMPOSER_VERSION'"' composer.json )" > composer.json
|
||||||
|
|
||||||
# replace CP_VERSION constant in app/config/constants
|
# replace CP_VERSION constant in app/config/constants
|
||||||
sed -i "s/^defined('CP_VERSION').*/defined('CP_VERSION') || define('CP_VERSION', '$VERSION');/" ./app/Config/Constants.php
|
sed -i "s/^defined('CP_VERSION').*/defined('CP_VERSION') || define('CP_VERSION', '$VERSION');/" ./app/Config/Constants.php
|
||||||
|
|
||||||
|
# install wget to download archives
|
||||||
|
apt-get install wget
|
||||||
|
|
||||||
# download GeoLite2-City archive and extract it to writable/uploads
|
# download GeoLite2-City archive and extract it to writable/uploads
|
||||||
wget -c "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=$MAXMIND_LICENCE_KEY&suffix=tar.gz" -O - | tar -xz -C ./writable/uploads/
|
wget -c "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=$MAXMIND_LICENCE_KEY&suffix=tar.gz" -O - | tar -xz -C ./writable/uploads/
|
||||||
|
|
||||||
# rename extracted archives' folders
|
# rename extracted archives' folders
|
||||||
mv ./writable/uploads/GeoLite2-City* ./writable/uploads/GeoLite2-City
|
mv ./writable/uploads/GeoLite2-City* ./writable/uploads/GeoLite2-City
|
||||||
|
|
||||||
|
# install rsync for file transfers
|
||||||
|
apt-get install rsync -y
|
||||||
|
|
||||||
# create castopo-host folder bundle: uses .rsync-filter (-F) file to copy only needed files
|
# create castopo-host folder bundle: uses .rsync-filter (-F) file to copy only needed files
|
||||||
rsync -aF --progress . ./castopod-host
|
rsync -aF --progress . ./castopod-host
|
||||||
|
|
||||||
# create zip and tar.gz packages for release upload
|
|
||||||
zip -r castopod-host-$VERSION.zip castopod-host
|
|
||||||
tar -zcvf castopod-host-$VERSION.tar.gz castopod-host
|
|
7
scripts/package.sh
Normal file
7
scripts/package.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
apt-get install zip -y
|
||||||
|
|
||||||
|
# create zip and tar.gz packages for release upload
|
||||||
|
zip -r castopod-host-$VERSION.zip castopod-host
|
||||||
|
tar -zcvf castopod-host-$VERSION.tar.gz castopod-host
|
Loading…
Reference in New Issue
Block a user