1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

ci: improve workflow

1. Run tests, iff the other prerequisites are met
2. In case of a translation PR, skip tests not related to translations
This commit is contained in:
Helmut K. C. Tessarek 2024-12-03 16:27:56 -05:00
parent 9ea80c2e2b
commit 417a3b05b9
No known key found for this signature in database
GPG Key ID: BE0985349D44DD00
2 changed files with 65 additions and 47 deletions

View File

@ -55,6 +55,7 @@ echo "GIT_TAG_NAME=$GIT_TAG_NAME"
echo "BUILD_SEQUENCIAL=$BUILD_SEQUENCIAL"
echo "SERVER_REPOSITORY=$SERVER_REPOSITORY"
echo "SERVER_TAG_PREFIX=$SERVER_TAG_PREFIX"
echo "PR_TITLE=$PR_TITLE"
echo "IS_CONTINUOUS_INTEGRATION=$IS_CONTINUOUS_INTEGRATION"
echo "IS_PULL_REQUEST=$IS_PULL_REQUEST"
@ -81,40 +82,6 @@ if [ $testResult -ne 0 ]; then
exit $testResult
fi
# =============================================================================
# Run test units
# =============================================================================
if [ "$RUN_TESTS" == "1" ]; then
echo "Step: Running tests..."
# On Linux, we run the Joplin Server tests using PostgreSQL
if [ "$IS_LINUX" == "1" ]; then
echo "Running Joplin Server tests using PostgreSQL..."
sudo docker compose --file docker-compose.db-dev.yml up -d
cmdResult=$?
if [ $cmdResult -ne 0 ]; then
exit $cmdResult
fi
export JOPLIN_TESTS_SERVER_DB=pg
else
echo "Running Joplin Server tests using SQLite..."
fi
# Need this because we're getting this error:
#
# @joplin/lib: FATAL ERROR: Ineffective mark-compacts near heap limit
# Allocation failed - JavaScript heap out of memory
#
# https://stackoverflow.com/questions/38558989
export NODE_OPTIONS="--max-old-space-size=32768"
yarn test-ci
testResult=$?
if [ $testResult -ne 0 ]; then
exit $testResult
fi
fi
# =============================================================================
# Run linter for pull requests only. We also don't want this to make the desktop
# release randomly fail.
@ -172,6 +139,23 @@ if [ "$RUN_TESTS" == "1" ]; then
fi
fi
# =============================================================================
# Check whether this is a translation PR. There is no need to run the entire
# pipeline in such a case, thus exit early.
# =============================================================================
if [ "$RUN_TESTS" == "1" ]; then
# Due to the ancient bash release in macOS, the following is required, instead
# of using ${var,,}
PR_TITLE=$(echo $PR_TITLE |tr '[:upper:]' '[:lower:]')
echo "Step: Checking for translation PR..."
if [[ "$PR_TITLE" =~ ^.*(translation|(add|fix|update) .*language|\.po)( .*)?$ ]]; then
echo "It is a translation PR. Exit early."
exit 0
fi
fi
# =============================================================================
# Check .gitignore and .eslintignore files - they should be updated when
# new TypeScript files are added by running `yarn updateIgnored`.
@ -224,6 +208,40 @@ if [ "$IS_LINUX" == "1" ]; then
fi
fi
# =============================================================================
# Run test units
# =============================================================================
if [ "$RUN_TESTS" == "1" ]; then
echo "Step: Running tests..."
# On Linux, we run the Joplin Server tests using PostgreSQL
if [ "$IS_LINUX" == "1" ]; then
echo "Running Joplin Server tests using PostgreSQL..."
sudo docker compose --file docker-compose.db-dev.yml up -d
cmdResult=$?
if [ $cmdResult -ne 0 ]; then
exit $cmdResult
fi
export JOPLIN_TESTS_SERVER_DB=pg
else
echo "Running Joplin Server tests using SQLite..."
fi
# Need this because we're getting this error:
#
# @joplin/lib: FATAL ERROR: Ineffective mark-compacts near heap limit
# Allocation failed - JavaScript heap out of memory
#
# https://stackoverflow.com/questions/38558989
export NODE_OPTIONS="--max-old-space-size=32768"
yarn test-ci
testResult=$?
if [ $testResult -ne 0 ]; then
exit $testResult
fi
fi
# =============================================================================
# Find out if we should run the build or not. Electron-builder gets stuck when
# building PRs so we disable it in this case. The Linux build should provide

View File

@ -115,6 +115,7 @@ jobs:
SERVER_REPOSITORY: joplin/server
SERVER_TAG_PREFIX: server
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
"${GITHUB_WORKSPACE}/.github/scripts/run_ci.sh"
@ -220,4 +221,3 @@ jobs:
echo 'Failed while checking the body response after request to /api/ping'
exit 1;
fi