refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s

This commit is contained in:
Kroonk
2026-05-22 16:19:55 +02:00
parent 38cc4c09ca
commit a213a1dba0
2215 changed files with 242567 additions and 6015 deletions

28
scripts/ci/.env.mysql Normal file
View File

@@ -0,0 +1,28 @@
# ENV FILE FOR THE GITHUB ACTION RUNNING MYSQL
APP_ENV=testing
APP_KEY=base64:NTrXToqFZJlv48dgPc+kNpc3SBt333TfDnF1mDShsBg=
APP_DEBUG=true
APP_URL=http://localhost:8000
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=monica
DB_USERNAME=root
DB_PASSWORD=root
DB_USE_UTF8MB4=true
BROADCAST_DRIVER=log
LOG_CHANNEL=testing
# Values from phpunit.xml
DEBUGBAR_ENABLED=false
CACHE_DRIVER=array
CHECK_VERSION=false
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
MAIL_MAILER=array
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME=
APP_EMAIL_NEW_USERS_NOTIFICATION=

17
scripts/ci/.env.postgres Normal file
View File

@@ -0,0 +1,17 @@
APP_ENV=testing
APP_KEY=base64:NTrXToqFZJlv48dgPc+kNpc3SBt333TfDnF1mDShsBg=
APP_URL=http://localhost:8000
DB_CONNECTION=pgsqltesting
DB_TEST_HOST=127.0.0.1
DB_TEST_DATABASE=monica
DB_TEST_USERNAME=postgres
DB_TEST_PASSWORD=
CACHE_DRIVER=array
SESSION_DRIVER=file
QUEUE_CONNECTION=sync
LOG_CHANNEL=testing
MFA_ENABLED=true
DAV_ENABLED=true

101
scripts/ci/package.sh Normal file
View File

@@ -0,0 +1,101 @@
#!/bin/bash
set -eo pipefail
SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && /bin/pwd -P)
source $SELF_PATH/../realpath.sh
ROOT=$(realpath $SELF_PATH/../..)
version=$1
if [ -z "$version" ]; then
echo "Version parameter is mandatory" >&2
exit 1
fi
commit=$2
if [ -z "$commit" ]; then
commit=$(git --git-dir $ROOT/.git log --pretty="%H" -n1 HEAD)
release=$(git --git-dir $ROOT/.git log --pretty="%h" -n1 HEAD)
fi
set -v
echo -n "$version" | tee $ROOT/config/.version
echo -n $commit | tee $ROOT/config/.commit
echo -n ${release:-$version} | tee $ROOT/config/.release
# BUILD
composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader --no-dev --working-dir=$ROOT
yarn --cwd $ROOT run inst
yarn --cwd $ROOT run production
# PACKAGE
package=monica-$version
mkdir -p $package/database
ln -s $ROOT/.env.example $package/
ln -s $ROOT/app.json $package/
ln -s $ROOT/artisan $package/
ln -s $ROOT/CHANGELOG.md $package/
ln -s $ROOT/CONTRIBUTING.md $package/
ln -s $ROOT/CONTRIBUTORS $package/
ln -s $ROOT/composer.json $package/
ln -s $ROOT/composer.lock $package/
ln -s $ROOT/LICENSE.md $package/
ln -s $ROOT/nginx_app.conf $package/
ln -s $ROOT/package.json $package/
ln -s $ROOT/Procfile $package/
ln -s $ROOT/README.md $package/
ln -s $ROOT/server.php $package/
ln -s $ROOT/webpack.mix.js $package/
ln -s $ROOT/yarn.lock $package/
ln -s $ROOT/app $package/
ln -s $ROOT/bootstrap $package/
ln -s $ROOT/config $package/
ln -s $ROOT/docs $package/
ln -s $ROOT/public $package/
ln -s $ROOT/resources $package/
ln -s $ROOT/routes $package/
ln -s $ROOT/vendor $package/
ln -s $ROOT/database/factories $package/database/
ln -s $ROOT/database/migrations $package/database/
ln -s $ROOT/database/seeds $package/database/
mkdir -p $package/storage/app/public
mkdir -p $package/storage/logs
mkdir -p $package/storage/framework/cache
mkdir -p $package/storage/framework/views
mkdir -p $package/storage/framework/sessions
tar chfj $package.tar.bz2 --exclude .gitignore --exclude .gitkeep $package
sha512sum "$package.tar.bz2" > "$package.tar.bz2.sha512"
echo "package=$package.tar.bz2" >> $GITHUB_OUTPUT
# ASSETS
assets=monica-assets-$version
mkdir -p $assets/public
ln -s $ROOT/public/mix-manifest.json $assets/public/
ln -s $ROOT/public/js $assets/public/
ln -s $ROOT/public/css $assets/public/
ln -s $ROOT/public/fonts $assets/public/
tar chfj $assets.tar.bz2 --exclude .gitignore --exclude .gitkeep $assets
sha512sum "$assets.tar.bz2" > "$assets.tar.bz2.sha512"
echo "assets=$assets.tar.bz2" >> $GITHUB_OUTPUT
# SIGN
if [ -n "${GPG_FINGERPRINT:-}" -a -n "${GPG_PASSPHRASE:-}" ]; then
for f in {$package,$assets}.tar.bz2{,.sha512}; do
echo "Signing '$f'..."
echo "$GPG_PASSPHRASE" | gpg --batch --yes --passphrase-fd 0 --pinentry-mode=loopback --local-user $GPG_FINGERPRINT --sign --armor --detach-sig --output "$f.asc" "$f"
echo -e "\nSigned with key fingerprint $GPG_FINGERPRINT" >> "$f.asc"
done
fi

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit Tests">
<directory suffix="Test.php">./tests/Unit/Models</directory>
</testsuite>
<testsuite name="Helpers Tests">
<directory suffix="Test.php">./tests/Unit/Helpers</directory>
</testsuite>
<testsuite name="Feature Tests">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
<testsuite name="Api Tests">
<directory suffix="Test.php">./tests/Api</directory>
</testsuite>
<testsuite name="Commands Tests">
<directory suffix="Test.php">./tests/Commands</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
<exclude>
<file>./app/Http/routes.php</file>
</exclude>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="base64:NTrXToqFZJlv48dgPc+kNpc3SBt333TfDnF1mDShsBg="/>
<env name="DB_CONNECTION" value="pgsqltesting"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="APP_DEFAULT_LOCALE" value="en"/>
</php>
<logging>
<log type="coverage-clover" target="./results/coverage.xml"/>
<log type="junit" target="./results/junit.xml"/>
</logging>
</phpunit>

106
scripts/ci/update-assets.sh Normal file
View File

@@ -0,0 +1,106 @@
#!/bin/bash
if [ "$CIRCLECI" == "true" ]; then
if [[ ! -z $CIRCLE_PULL_REQUEST ]] ; then
CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}"
REPO=$CIRCLE_PULL_REQUEST
REPO=${REPO##https://github.com/}
REPO=${REPO%%/pull/$CIRCLE_PR_NUMBER}
else
REPO=$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
fi
BRANCH=${CIRCLE_BRANCH:-$CIRCLE_TAG}
PR_NUMBER=${CIRCLE_PR_NUMBER:-false}
elif [ "$TRAVIS" == "true" ]; then
REPO=$TRAVIS_REPO_SLUG
BRANCH=${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}
PR_NUMBER=$TRAVIS_PULL_REQUEST
elif [ "$TF_BUILD" == "True" ]; then
REPO=$BUILD_REPOSITORY_NAME
BRANCH=${SYSTEM_PULLREQUEST_SOURCEBRANCH:-$BUILD_SOURCEBRANCHNAME}
PR_NUMBER=${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER:-false}
elif [[ -n $BUILD_NUMBER ]]; then
echo "CHANGE_ID=$CHANGE_ID"
echo "CHANGE_URL=$CHANGE_URL"
REPO=${CHANGE_URL##https://github.com/}
if [[ ! -z $CHANGE_ID ]] ; then
REPO=${REPO%%/pull/$CHANGE_ID}
fi
PR_NUMBER=${CHANGE_ID:-false}
BRANCH=$BRANCH_NAME
fi
REPOSITORY_OWNER=monicahq/monica
set -euo pipefail
# Update assets
echo -e "\033[1;32m# Build assets ...\033[0;37m"
echo -e "\033[1;36myarn run production\033[0;37m"
yarn run production
echo ""
# Check if there is zero update needed
status=$(git status --porcelain)
if [ "$status" = "" ]; then
echo "Nothing to push, already up to date."
exit 0;
fi
echo "Waiting modifications:"
echo $status
# Add files
git add public/mix-manifest.json
git add public/js/*
git add public/css/*
git add public/fonts/*
# Commit
if [ -z "${ASSETS_USERNAME:-}" ]; then
#No username
echo -e "\033[0;31mMonica asset are not up to date.\033[0;37m"
echo "Please update the Monica assets yourself by running:"
echo " ~ yarn run production"
exit 2
fi
git config user.email $ASSETS_EMAIL
git config user.name $ASSETS_USERNAME
git commit -m "chore(assets): Update assets"
# Push
if [ "$BRANCH" == "main" ] && [ "$PR_NUMBER" == "false" ]; then
echo -e "\033[0;31mmain branch is not up to date, but we can't update it directly...\033[0;37m"
exit 0
elif [ -n "${ASSETS_GITHUB_TOKEN:-}" ]; then
REPOS_VALUES=($(curl -H "Authorization: token $ASSETS_GITHUB_TOKEN" -sSL https://api.github.com/repos/$REPO/pulls/$PR_NUMBER | jq -r -c ".head.repo.full_name, .head.ref"))
PULL_REQUEST_BRANCH=
PULL_REQUEST_REPOSITORY=${REPOS_VALUES[0]}
PULL_REQUEST_HEADBRANCH=${REPOS_VALUES[1]}
if [ -z "${PULL_REQUEST_REPOSITORY:-}" ] || [ "$PULL_REQUEST_REPOSITORY" == "null" ]; then
echo -e "\033[0;31mError with github api call\033[0;37m"
exit 1
elif [ "$PULL_REQUEST_REPOSITORY" == "$REPOSITORY_OWNER" ]; then
PULL_REQUEST_BRANCH=$PULL_REQUEST_HEADBRANCH
else
echo -e "\033[0;31mMonica asset are not up to date.\033[0;37m"
echo "We can't commit in $PULL_REQUEST_REPOSITORY to update them directly."
echo "Please update the Monica assets yourself by running:"
echo " ~ yarn run production"
exit 2
fi
echo "Pushing files to $PULL_REQUEST_BRANCH branch ..."
remote=monica-origin
remoteurl="https://$ASSETS_USERNAME:$ASSETS_GITHUB_TOKEN@github.com/$REPO"
git remote remove $remote || true
git remote add -f $remote $remoteurl || true
git push $remote HEAD:$PULL_REQUEST_BRANCH
# Exit with error to stop the current build
echo "...pushed files successfully."
echo "Exit with error to stop the current build."
exit -1
fi

View File

@@ -0,0 +1,10 @@
#!/bin/sh
file=$1
release=$2
curl -H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
-X POST \
--data-binary @"$file" \
"https://uploads.github.com/repos/monicahq/monica/releases/$release/assets?name=$(basename $file)"