From 35d562e7e45e01a8faebf8990c3193dca2547d0c Mon Sep 17 00:00:00 2001 From: Shady Sharaf Date: Wed, 12 Jan 2022 10:40:32 +0200 Subject: [PATCH 1/3] Add Travis config --- .travis.yml | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1d7954e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,63 @@ +# Default Travis CI config for Altis +os: linux +dist: xenial + +# Ensure PHP CLI and Composer are available +language: php +php: + - '7.4' + +# Set NodeJS version to match the build server. +node_js: + - 12 + +# Ensure docker-compose is available +services: + - docker + +# Configure local-server to ensure startup will complete in Travis CI +env: + global: + - COMPOSE_HTTP_TIMEOUT=360 + - ES_MEM_LIMIT=2g + +# Default notification settings +notifications: + email: + on_success: never + on_failure: change + +# Cache composer dependencies by default +cache: + directories: + - $HOME/.composer/cache + +# Ensure correct node version is used for build +before_install: + - nvm install v12 + - nvm use v12 + # Authenticate with docker hub. + - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + +# We handle installation via composer create-project +install: skip + +# Only run for target branch +branches: + only: + - master + - main + - /v\d+-branch/ + - travis + +before_script: + # Install Altis and start the local server + - composer create-project altis/skeleton:dev-$TRAVIS_BRANCH --stability=dev $HOME/test-root + # Require the current module and alias the branch to be tested to the target version main branch + - cd $HOME/test-root && composer require "$ALTIS_PACKAGE:dev-$TRAVIS_PULL_REQUEST_BRANCH as dev-$TRAVIS_BRANCH" + +script: + # Start local server + - cd $HOME/test-root && composer serve + # Run Codeception for module tests, if test suites are found. + - cd $HOME/test-root && test -n "$(find vendor/$ALTIS_PACKAGE/tests -name '*.suite.yml')" && composer dev-tools codecept run -p vendor/$ALTIS_PACKAGE/tests \ No newline at end of file From 0f037327ff50b0fef676e9bd912a574f6b91acf6 Mon Sep 17 00:00:00 2001 From: Shady Sharaf Date: Wed, 12 Jan 2022 11:21:35 +0200 Subject: [PATCH 2/3] Bail early if no tests are found --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1d7954e..2c61bd2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,8 +51,10 @@ branches: - travis before_script: + # Exit early if no tests are found + - test -n "$(find vendor/$ALTIS_PACKAGE/tests -name '*.suite.yml' 2>/dev/null)" || exit 0 # Install Altis and start the local server - - composer create-project altis/skeleton:dev-$TRAVIS_BRANCH --stability=dev $HOME/test-root + - composer create-project altis/skeleton:dev-$TRAVIS_BRANCH --stability=dev $HOME/test-root || exit 1 # Require the current module and alias the branch to be tested to the target version main branch - cd $HOME/test-root && composer require "$ALTIS_PACKAGE:dev-$TRAVIS_PULL_REQUEST_BRANCH as dev-$TRAVIS_BRANCH" @@ -60,4 +62,4 @@ script: # Start local server - cd $HOME/test-root && composer serve # Run Codeception for module tests, if test suites are found. - - cd $HOME/test-root && test -n "$(find vendor/$ALTIS_PACKAGE/tests -name '*.suite.yml')" && composer dev-tools codecept run -p vendor/$ALTIS_PACKAGE/tests \ No newline at end of file + - cd $HOME/test-root && composer dev-tools codecept run -p vendor/$ALTIS_PACKAGE/tests \ No newline at end of file From f6cdf8a0bced9ee6eb3075e69cce4be66303c6fc Mon Sep 17 00:00:00 2001 From: Shady Sharaf Date: Wed, 12 Jan 2022 11:57:54 +0200 Subject: [PATCH 3/3] Bail early if no tests are found --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2c61bd2..2e0be1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,8 @@ cache: # Ensure correct node version is used for build before_install: + # Exit early if no tests are found + - test -n "$(find $TRAVIS_BUILD_DIR/tests -name '*.suite.yml' 2>/dev/null)" || exit 0 - nvm install v12 - nvm use v12 # Authenticate with docker hub. @@ -51,8 +53,6 @@ branches: - travis before_script: - # Exit early if no tests are found - - test -n "$(find vendor/$ALTIS_PACKAGE/tests -name '*.suite.yml' 2>/dev/null)" || exit 0 # Install Altis and start the local server - composer create-project altis/skeleton:dev-$TRAVIS_BRANCH --stability=dev $HOME/test-root || exit 1 # Require the current module and alias the branch to be tested to the target version main branch