diff --git a/run-build-functions.sh b/run-build-functions.sh index 5d84faf6..db7a49c1 100755 --- a/run-build-functions.sh +++ b/run-build-functions.sh @@ -76,6 +76,7 @@ mkdir -p $NETLIFY_CACHE_DIR/.cargo : ${NPM_FLAGS=""} : ${PNPM_FLAGS=""} : ${BUNDLER_FLAGS=""} +: ${COMPOSER_FLAGS=""} # Feature flags are a comma-separated list. # The following logic relies on the fact that feature flags cannot currently @@ -291,6 +292,10 @@ run_npm() { export PATH=$(npm bin):$PATH } +run_composer() { + composer install ${COMPOSER_FLAGS:+$COMPOSER_FLAGS} +} + install_node() { local defaultNodeVersion=$1 local featureFlags=$2 @@ -773,7 +778,7 @@ install_dependencies() { if [ -f composer.json ] then restore_home_cache ".composer" "composer dependencies" - composer install + run_composer fi install_go $installGoVersion diff --git a/tests/php/composer.bats b/tests/php/composer.bats new file mode 100644 index 00000000..e73925cf --- /dev/null +++ b/tests/php/composer.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats + +load "../helpers.sh" + +load '../../node_modules/bats-support/load' +load '../../node_modules/bats-assert/load' +load '../../node_modules/bats-file/load' + +setup() { + TMP_DIR=$(setup_tmp_dir) + set_fixture_as_repo 'simple-php' "$TMP_DIR" + + # Load functions + load '../../run-build-functions.sh' +} + +teardown() { + rm -rf "$TMP_DIR" + # Return to original dir + cd - || return +} + +@test 'composer install' { + run run_composer + assert_success + assert_output --partial "(including require-dev)" +} + +@test 'composer install with flags' { + COMPOSER_FLAGS="--no-dev" + + run run_composer + assert_success + refute_output --partial "(including require-dev)" +} \ No newline at end of file diff --git a/tests/php/fixtures/simple-php/composer.json b/tests/php/fixtures/simple-php/composer.json new file mode 100644 index 00000000..e5c748f9 --- /dev/null +++ b/tests/php/fixtures/simple-php/composer.json @@ -0,0 +1,4 @@ +{ + "name": "fixture/simple-php", + "require": {} +}