diff --git a/.gitignore b/.gitignore index bf1b8fb17..188cb7de5 100644 --- a/.gitignore +++ b/.gitignore @@ -8,12 +8,9 @@ composer.phar .editorconfig test.php .idea/ -test/prism_linux_amd64 -test/prism/* -!test/prim *.code-workspace .vscode -prism* +prism temp.php example*.php TODO.txt diff --git a/.travis.yml b/.travis.yml index caa7456f4..f50fdb61f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,21 @@ language: php -before_script: - - if [ -n "$GIT_HUB_TOKEN" ]; then composer config -g github-oauth.github.com "$GIT_HUB_TOKEN"; fi; - - composer install - - if [ "$dependencies" = "lowest" ]; then composer update --prefer-lowest --prefer-stable -n; fi; - - "./test/prism.sh &" - - sleep 60 +services: + - docker script: - - "vendor/bin/phpunit test --filter test*" + - make test-docker after_success: - bash <(curl -s https://codecov.io/bash) -php: - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - 7.3 - - 7.4 - env: - - dependencies=lowest - - dependencies=highest + - version=5.6 + - version=7.0 + - version=7.1 + - version=7.2 + - version=7.3 + - version=7.4 notifications: slack: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..8ad1cfd66 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +ARG version=latest +FROM php:$version + +RUN apt-get update \ + && apt-get install -y zip + +RUN curl -s https://getcomposer.org/installer | php \ + && mv composer.phar /usr/local/bin/composer + +COPY prism/prism/nginx/cert.crt /usr/local/share/ca-certificates/cert.crt +RUN update-ca-certificates + +WORKDIR /app +COPY . . + +RUN make install diff --git a/Makefile b/Makefile index c4bdf199e..517b669c5 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,32 @@ -.PHONY: clean install ci-install test bundle +.PHONY: clean install ci-install test test-integ test-docker bundle clean: @rm -rf vendor composer.lock sendgrid-php.zip install: clean +ifdef GIT_HUB_TOKEN + composer config -g github-oauth.github.com $(GIT_HUB_TOKEN) +endif + composer install +ifeq ($(dependencies), lowest) + composer update --prefer-lowest --prefer-stable -n +endif + ci-install: clean composer install --no-dev -test: install +test: vendor/bin/phpunit test/unit --filter test* +test-integ: test + vendor/bin/phpunit test --filter test* + +version ?= latest +test-docker: + curl -s https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/prism/prism.sh | dependencies=lowest version=$(version) bash + curl -s https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/prism/prism.sh | dependencies=highest version=$(version) bash + bundle: ci-install zip -r sendgrid-php.zip . -x \*.git\* \*composer.json\* \*scripts\* \*test\* \*.travis.yml\* \*prism\* diff --git a/test/BaseTestClass.php b/test/BaseTestClass.php index 742cbeb4e..36fa92a48 100644 --- a/test/BaseTestClass.php +++ b/test/BaseTestClass.php @@ -31,9 +31,8 @@ class BaseTestClass extends TestCase */ public static function setUpBeforeClass() { - self::$apiKey = "SENDGRID_API_KEY"; - $host = ['host' => 'http://localhost:4010']; - self::$sg = new SendGrid(self::$apiKey, $host); + self::$apiKey = 'SENDGRID_API_KEY'; + self::$sg = new SendGrid(self::$apiKey); } /** diff --git a/test/prism.sh b/test/prism.sh deleted file mode 100755 index 453744529..000000000 --- a/test/prism.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash - -get_latest_release() { - curl --silent "https://api.github.com/repos/stoplightio/prism/releases/latest" | # Get latest release from GitHub api - grep '"tag_name":' | # Get tag line - sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value -} -set -eu - -install () { - -echo "Installing Prism..." - -UNAME=$(uname) -ARCH=$(uname -m) -if [ "$UNAME" != "Linux" ] && [ "$UNAME" != "Darwin" ] && [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "i686" ]; then - echo "Sorry, OS/Architecture not supported: ${UNAME}/${ARCH}. Download binary from https://github.com/stoplightio/prism/releases" - exit 1 -fi - -if [ "$UNAME" = "Darwin" ] ; then - OSX_ARCH=$(uname -m) - if [ "${OSX_ARCH}" = "x86_64" ] ; then - PLATFORM="darwin_amd64" - fi -elif [ "$UNAME" = "Linux" ] ; then - LINUX_ARCH=$(uname -m) - if [ "${LINUX_ARCH}" = "i686" ] ; then - PLATFORM="linux_386" - elif [ "${LINUX_ARCH}" = "x86_64" ] ; then - PLATFORM="linux_amd64" - fi -fi - -mkdir -p ../prism/bin -LATEST=$(get_latest_release) -# URL="https://github.com/stoplightio/prism/releases/download/$LATEST/prism_$PLATFORM" -URL="https://github.com/stoplightio/prism/releases/download/v2.0.17/prism_$PLATFORM" -DEST=../prism/bin/prism - -# if [ -z $LATEST ] ; then -# echo "Error requesting. Download binary from ${URL}" -# exit 1 -# else -curl -L $URL -o $DEST -chmod +x $DEST -# fi -} - -run () { - echo "Running prism..." - cd ../prism/bin - ./prism mock --spec https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json -} - -if [ -f ../prism/bin/prism ]; then - echo "Prism is already installed." - run -else - echo "Prism is not installed." - install - run -fi