diff --git a/Dockerfile b/Dockerfile index 4fd172e5..8334b9e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -399,8 +399,8 @@ RUN wget --tries=5 -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sger git git-lfs \ glibc-${GLIBC_VERSION}.apk \ gnupg \ - php7 php7-phar php7-json php7-mbstring php-xmlwriter \ - php7-tokenizer php7-ctype php7-curl php7-dom php7-simplexml \ + php7 php7-curl php7-ctype php7-dom php7-iconv php7-json php7-mbstring \ + php7-openssl php7-phar php7-simplexml php7-tokenizer php-xmlwriter \ && rm glibc-${GLIBC_VERSION}.apk \ && wget -q --tries=5 -O /tmp/libz.tar.xz https://www.archlinux.org/packages/core/x86_64/zlib/download \ && mkdir /tmp/libz \ @@ -437,6 +437,11 @@ COPY --from=base_image /home/r-library /home/r-library COPY --from=base_image /root/.tflint.d/ /root/.tflint.d/ COPY --from=clang-format-build /tmp/llvm-project/llvm/build/bin/clang-format /usr/bin/clang-format +#################################################### +# Install Composer after all Libs have been copied # +#################################################### +RUN sh -c 'curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer' + ######################################## # Add node packages to path and dotnet # ######################################## diff --git a/Dockerfile-slim b/Dockerfile-slim index 0b46f716..d4c8332d 100644 --- a/Dockerfile-slim +++ b/Dockerfile-slim @@ -336,8 +336,8 @@ RUN wget --tries=5 -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sger git git-lfs \ glibc-${GLIBC_VERSION}.apk \ gnupg \ - php7 php7-phar php7-json php7-mbstring php-xmlwriter \ - php7-tokenizer php7-ctype php7-curl php7-dom php7-simplexml \ + php7 php7-curl php7-ctype php7-dom php7-iconv php7-json php7-mbstring \ + php7-openssl php7-phar php7-simplexml php7-tokenizer php-xmlwriter \ && rm glibc-${GLIBC_VERSION}.apk \ && wget -q --tries=5 -O /tmp/libz.tar.xz https://www.archlinux.org/packages/core/x86_64/zlib/download \ && mkdir /tmp/libz \ @@ -373,6 +373,11 @@ COPY --from=base_image /home/r-library /home/r-library COPY --from=base_image /root/.tflint.d/ /root/.tflint.d/ COPY --from=clang-format-build /tmp/llvm-project/llvm/build/bin/clang-format /usr/bin/clang-format +#################################################### +# Install Composer after all Libs have been copied # +#################################################### +RUN sh -c 'curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer' + ######################################## # Add node packages to path and dotnet # ######################################## diff --git a/lib/functions/detectFiles.sh b/lib/functions/detectFiles.sh index 813bfea1..b61be320 100755 --- a/lib/functions/detectFiles.sh +++ b/lib/functions/detectFiles.sh @@ -394,3 +394,47 @@ function IsGenerated() { return 0 fi } +################################################################################ +#### Function RunAdditionalInstalls ############################################ +function RunAdditionalInstalls() { + ################################## + # Run installs for Psalm and PHP # + ################################## + if [ "${VALIDATE_PHP_PSALM}" == "true" ] && [ "${#FILE_ARRAY_PHP_PSALM[@]}" -ne 0 ]; then + # found PHP files and were validating it, need to composer install + info "Found PHP files to validate, and [VALIDATE_PHP_PSALM] set to true, need to run composer install" + info "looking for composer.json in the users repository..." + mapfile -t COMPOSER_FILE_ARRAY < <(find / -name composer.json 2>&1) + debug "COMPOSER_FILE_ARRAY contents: ${COMPOSER_FILE_ARRAY[*]}" + ############################################ + # Check if we found the file in the system # + ############################################ + if [ "${#COMPOSER_FILE_ARRAY[@]}" -ne 0 ]; then + for LINE in "${COMPOSER_FILE_ARRAY[@]}"; do + PATH=$(dirname "${LINE}" 2>&1) + info "Found [composer.json] at:[${LINE}]" + COMPOSER_CMD=$( + cd "${PATH}" || exit 1 + composer install 2>&1 + ) + + ############## + # Error code # + ############## + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ "${ERROR_CODE}" -ne 0 ]; then + # Error + error "ERROR! Failed to run composer install at location:[${PATH}]" + fatal "ERROR:[${COMPOSER_CMD}]" + else + # Success + info "Successfully ran:[composer install] for PHP validation" + fi + done + fi + fi +} diff --git a/lib/linter.sh b/lib/linter.sh index 97d92b77..59c24ff3 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -914,6 +914,11 @@ CheckSSLCert ########################################### BuildFileList "${VALIDATE_ALL_CODEBASE}" "${TEST_CASE_RUN}" "${ANSIBLE_DIRECTORY}" +##################################### +# Run additional Installs as needed # +##################################### +RunAdditionalInstalls + ############### # Run linters # ###############