diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d6ff580..cbec2f47 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,8 +18,8 @@ jobs: strategy: matrix: stack: - - scalingo-20 - scalingo-22 + - scalingo-24 container: image: "scalingo/${{ matrix.stack }}:latest" env: diff --git a/Makefile b/Makefile index a55bf9a2..4e27bdaa 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,12 @@ BASH_COMMAND := /bin/bash .DEFAULT := all all: test -test: test20 test22 +test: test22 test24 -test20: STACK := "scalingo-20" +test24: STACK := "scalingo-24" -test20 test22: BASH_COMMAND := test/run -test20 test22: IMAGE := "scalingo/$(STACK):latest" -test20 test22: +test22 test24: BASH_COMMAND := test/run +test22 test24: IMAGE := "scalingo/$(STACK):latest" +test22 test24: @echo "Running tests in Docker using $(IMAGE)" @docker run --pull always --mount type=bind,src=$(PWD),dst=/buildpack,readonly --workdir /buildpack --rm --interactive --tty --env "GITLAB_TOKEN=$(GITLAB_TOKEN)" --env "GITHUB_TOKEN=$(GITHUB_TOKEN)" --env "STACK=$(STACK)" $(IMAGE) bash -c "$(BASH_COMMAND)" diff --git a/README.md b/README.md index 778f6ca4..f110117c 100644 --- a/README.md +++ b/README.md @@ -486,4 +486,19 @@ Node.js script at that time. ## Contributing -Please see the [CONTRIBUTING](/CONTRIBUTING.md) file for all the details. +### Unit Tests + +The buildpack is tested with unit tests. One can execute them using `make`: + +```sh +make +``` + +Understanding the root cause of a failing test is (not yet) easy. In case of failing test, we suggest you execute this single test by commenting all the other tests in `test/tests`. Then find the location of your test and add the following right after the failed test: + +```sh +cat "${STD_OUT}" +cat "${STD_ERR}" +``` + +Execute the test again, these two `cat` calls will output the stdout and stderr. diff --git a/bin/compile b/bin/compile index ba3496bc..bb8c54f0 100755 --- a/bin/compile +++ b/bin/compile @@ -22,7 +22,7 @@ if [ "$PHP_BUILDPACK_NO_NODE" != "true" ] ; then fi if [ -n "$BUILDPACK_DEBUG" ]; then - set -x + set -x fi BUILD_DIR="$1" diff --git a/test/defaults b/test/defaults index aafb43ab..2082c5a7 100644 --- a/test/defaults +++ b/test/defaults @@ -5,18 +5,18 @@ declare -gA default_nginx declare -gA default_composer declare -gA latest_composer -# Defaults for scalingo-20: -default_php["scalingo-20"]="8.1." -default_nginx["scalingo-20"]="1.26." -default_composer["scalingo-20"]="2.8." -latest_composer["scalingo-20"]="2.8.8" - # Defaults for scalingo-22: -default_php["scalingo-22"]="8.1." +default_php["scalingo-22"]="8.1." # This one depends on the semver stable rule configuration default_nginx["scalingo-22"]="1.28." default_composer["scalingo-22"]="2.8." latest_composer["scalingo-22"]="2.8.11" +# Defaults for scalingo-24: +default_php["scalingo-24"]="8.4." +default_nginx["scalingo-24"]="1.28." +default_composer["scalingo-24"]="2.8." +latest_composer["scalingo-24"]="2.8.11" + test::defaults::classic() { # diff --git a/test/fixtures/nginx-1.28.0/composer/composer.json b/test/fixtures/nginx-1.28.0/composer/composer.json new file mode 100644 index 00000000..ed11ecc4 --- /dev/null +++ b/test/fixtures/nginx-1.28.0/composer/composer.json @@ -0,0 +1,9 @@ +{ + "extra": { + "paas": { + "engines": { + "nginx": "1.28.0" + } + } + } +} diff --git a/test/fixtures/nginx-1.28.0/composer/composer.lock b/test/fixtures/nginx-1.28.0/composer/composer.lock new file mode 100644 index 00000000..4f967fe3 --- /dev/null +++ b/test/fixtures/nginx-1.28.0/composer/composer.lock @@ -0,0 +1,18 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "df7fd9ca7fdce9bf5ca88bbdb6baeb5f", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.2.0" +} diff --git a/test/fixtures/nginx-1.29.0/composer/composer.json b/test/fixtures/nginx-1.29.0/composer/composer.json new file mode 100644 index 00000000..7e1270d1 --- /dev/null +++ b/test/fixtures/nginx-1.29.0/composer/composer.json @@ -0,0 +1,9 @@ +{ + "extra": { + "paas": { + "engines": { + "nginx": "1.29.0" + } + } + } +} diff --git a/test/fixtures/nginx-1.29.0/composer/composer.lock b/test/fixtures/nginx-1.29.0/composer/composer.lock new file mode 100644 index 00000000..4f967fe3 --- /dev/null +++ b/test/fixtures/nginx-1.29.0/composer/composer.lock @@ -0,0 +1,18 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "df7fd9ca7fdce9bf5ca88bbdb6baeb5f", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.2.0" +} diff --git a/test/nginx b/test/nginx index 4d1f4e31..63009315 100644 --- a/test/nginx +++ b/test/nginx @@ -12,14 +12,14 @@ test::nginx::classic() { # the one expected. # - NGINX_VERSION="1.22.1" + NGINX_VERSION="1.28.0" export NGINX_VERSION test::utils::setupFixture "defaults/classic" test::utils::compile test::helpers::enter_prod - test::helpers::nginx "1.22.1" + test::helpers::nginx "1.28.0" } test::nginx::composer() { @@ -28,11 +28,11 @@ test::nginx::composer() { # Specifying the nginx version only via composer.json # - test::utils::setupFixture "nginx-1.21.6/composer" + test::utils::setupFixture "nginx-1.28.0/composer" test::utils::compile test::helpers::enter_prod - test::helpers::nginx "1.21.6" + test::helpers::nginx "1.28.0" } #test::composer::nginx_version_via_env() { @@ -59,30 +59,30 @@ test::nginx::composer_over_lower_classic() { # specified in NGINX_VERSION. # - NGINX_VERSION="1.21.6" + NGINX_VERSION="1.28.0" export NGINX_VERSION - test::utils::setupFixture "nginx-1.22.1/composer" + test::utils::setupFixture "nginx-1.29.0/composer" test::utils::compile test::helpers::enter_prod - test::helpers::nginx "1.22.1" + test::helpers::nginx "1.29.0" } test::nginx::composer_over_higher_classic() { # # Test a deployment of a PHP app using Composer -# Specifying the Nginx version via both composer.json and NGINX_VERSION. +# Specifying the Nginx version via both composer.json and NGINX_VERSION. # And where the version specified in composer.json is lower than the one # specified in NGINX_VERSION. # - NGINX_VERSION="1.22.1" + NGINX_VERSION="1.29.0" export NGINX_VERSION - test::utils::setupFixture "nginx-1.21.6/composer" + test::utils::setupFixture "nginx-1.28.0/composer" test::utils::compile test::helpers::enter_prod - test::helpers::nginx "1.21.6" + test::helpers::nginx "1.28.0" } diff --git a/test/utils b/test/utils index 3f5cf448..62a2260d 100644 --- a/test/utils +++ b/test/utils @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # taken from # https://github.com/ryanbrainard/heroku-buildpack-testrunner/blob/master/lib/test_utils.sh @@ -112,7 +112,7 @@ test::utils::assertMatches() { local needle local haystack - + needle="${1}" haystack="${2}"