Skip to content

Commit

Permalink
Misc integration test improvements
Browse files Browse the repository at this point in the history
As part of adding Poetry + `.python-version` file support, a fair
amount of buildpack refactoring will be required.

This backports some of the additional test scenarios we now have
in the new Python CNB, along with some test general improvements.

It's been split out of later PRs for easier review.
  • Loading branch information
edmorley committed Sep 22, 2024
1 parent d13fbbd commit 717145f
Show file tree
Hide file tree
Showing 48 changed files with 659 additions and 155 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ jobs:
matrix:
stack: ["heroku-20", "heroku-22", "heroku-24"]
env:
HATCHET_APP_LIMIT: 200
HATCHET_APP_LIMIT: 300
HATCHET_DEFAULT_STACK: ${{ matrix.stack }}
HATCHET_EXPENSIVE_MODE: 1
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
HEROKU_API_USER: ${{ secrets.HEROKU_API_USER }}
HEROKU_DISABLE_AUTOUPDATE: 1
PARALLEL_SPLIT_TEST_PROCESSES: 60
RSPEC_RETRY_RETRY_COUNT: 3
PARALLEL_SPLIT_TEST_PROCESSES: 70
RSPEC_RETRY_RETRY_COUNT: 2
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
24 changes: 12 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ GEM
base64 (0.2.0)
diff-lcs (1.5.1)
erubis (2.7.0)
excon (0.110.0)
excon (0.111.0)
heroics (0.1.3)
base64
erubis (~> 2.0)
Expand All @@ -27,7 +27,7 @@ GEM
parallel_split_test (0.10.0)
parallel (>= 0.5.13)
rspec-core (>= 3.9.0)
parser (3.3.4.2)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
platform-api (3.7.0)
Expand All @@ -39,32 +39,32 @@ GEM
rate_throttle_client (0.1.2)
regexp_parser (2.9.2)
rrrretry (1.0.0)
rspec-core (3.13.0)
rspec-core (3.13.1)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.2)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.13.1)
rubocop (1.66.0)
rubocop (1.66.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.1, < 2.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.1)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
rubocop-rspec (3.0.4)
rubocop-rspec (3.0.5)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
thor (1.3.1)
thor (1.3.2)
threaded (0.0.4)
unicode-display_width (2.5.0)
unicode-display_width (2.6.0)
webrick (1.8.1)

PLATFORMS
Expand All @@ -80,7 +80,7 @@ DEPENDENCIES
rubocop-rspec

RUBY VERSION
ruby 3.3.2p78
ruby 3.3.5p100

BUNDLED WITH
2.5.11
2.5.18
1 change: 1 addition & 0 deletions bin/steps/pipenv
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if [[ -f Pipfile ]]; then
meta_set "package_manager" "pipenv"

# Skip installing dependencies using pip later.
# TODO: Stop leaking this env var into subshells such as post_compile hooks.
export SKIP_PIP_INSTALL=1

# Set Pip env vars
Expand Down
10 changes: 10 additions & 0 deletions spec/fixtures/ci_pipenv/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
typing-extensions = "*"

[dev-packages]
pytest = "*"
62 changes: 62 additions & 0 deletions spec/fixtures/ci_pipenv/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions spec/fixtures/ci_pipenv/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"environments": {
"test": {
"scripts": {
"test": "./bin/print-env-vars.sh && pytest --version"
}
}
}
}
12 changes: 12 additions & 0 deletions spec/fixtures/ci_pipenv/bin/compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# This file is run by the inline buildpack, and tests that the environment is
# configured as expected for buildpacks that run after the Python buildpack.

set -euo pipefail

BUILD_DIR="${1}"

cd "${BUILD_DIR}"

exec bin/print-env-vars.sh
7 changes: 7 additions & 0 deletions spec/fixtures/ci_pipenv/bin/detect
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

# This file is run by the inline buildpack.

set -euo pipefail

echo "Inline"
5 changes: 5 additions & 0 deletions spec/fixtures/ci_pipenv/bin/post_compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -euo pipefail

exec bin/print-env-vars.sh
5 changes: 5 additions & 0 deletions spec/fixtures/ci_pipenv/bin/print-env-vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -euo pipefail

printenv | sort | grep -vE '^(_|BUILDPACK_LOG_FILE|BUILD_DIR|CACHE_DIR|CI_NODE_.+|DYNO|ENV_DIR|HEROKU_TEST_RUN_.+|HOME|OLDPWD|PORT|PWD|SHLVL|STACK|TERM)='
2 changes: 1 addition & 1 deletion spec/fixtures/ci_requirements/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"environments": {
"test": {
"scripts": {
"test": "pytest --version"
"test": "./bin/print-env-vars.sh && pytest --version"
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions spec/fixtures/ci_requirements/bin/compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# This file is run by the inline buildpack, and tests that the environment is
# configured as expected for buildpacks that run after the Python buildpack.

set -euo pipefail

BUILD_DIR="${1}"

cd "${BUILD_DIR}"

exec bin/print-env-vars.sh
7 changes: 7 additions & 0 deletions spec/fixtures/ci_requirements/bin/detect
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

# This file is run by the inline buildpack.

set -euo pipefail

echo "Inline"
5 changes: 5 additions & 0 deletions spec/fixtures/ci_requirements/bin/post_compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -euo pipefail

exec bin/print-env-vars.sh
5 changes: 5 additions & 0 deletions spec/fixtures/ci_requirements/bin/print-env-vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -euo pipefail

printenv | sort | grep -vE '^(_|BUILDPACK_LOG_FILE|BUILD_DIR|CACHE_DIR|CI_NODE_.+|DYNO|ENV_DIR|HEROKU_TEST_RUN_.+|HOME|OLDPWD|PORT|PWD|SHLVL|STACK|TERM)='
2 changes: 1 addition & 1 deletion spec/fixtures/ci_requirements/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pytest
pytest==8.3.3
3 changes: 2 additions & 1 deletion spec/fixtures/ci_requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
urllib3
# This package has been picked since it has no dependencies and is small/fast to install.
typing-extensions==4.12.2
5 changes: 3 additions & 2 deletions spec/fixtures/hooks/bin/post_compile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

set -euo pipefail

echo 'post_compile ran with env vars:'
printenv | cut -d '=' -f 1 | sort
echo '~ post_compile ran with env vars:'
bin/print-env-vars.sh
echo '~ post_compile complete'
5 changes: 3 additions & 2 deletions spec/fixtures/hooks/bin/pre_compile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

set -euo pipefail

echo 'pre_compile ran with env vars:'
printenv | cut -d '=' -f 1 | sort
echo '~ pre_compile ran with env vars:'
bin/print-env-vars.sh
echo '~ pre_compile complete'
10 changes: 10 additions & 0 deletions spec/fixtures/hooks/bin/print-env-vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -euo pipefail

printenv | sort \
| grep -vE '^(_|BUILDPACK_LOG_FILE|DYNO|OLDPWD|REQUEST_ID|SHLVL)=' \
| sed --regexp-extended \
--expression 's#(=/tmp/build_)[^:/]+#\1<hash>#' \
--expression 's#^(ENV_DIR=/tmp/).*#\1...#' \
--expression 's#^(SOURCE_VERSION=).*#\1...#'
2 changes: 1 addition & 1 deletion spec/fixtures/pipenv_editable/bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ BUILD_DIR="${1}"

cd "${BUILD_DIR}"

exec bin/test-entrypoints
exec bin/test-entrypoints.sh
2 changes: 1 addition & 1 deletion spec/fixtures/pipenv_editable/bin/post_compile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -euo pipefail

exec bin/test-entrypoints
exec bin/test-entrypoints.sh
2 changes: 1 addition & 1 deletion spec/fixtures/pipenv_python_version_unspecified/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ verify_ssl = true
name = "pypi"

[packages]
urllib3 = "*"
typing-extensions = "*"

[dev-packages]
10 changes: 5 additions & 5 deletions spec/fixtures/pipenv_python_version_unspecified/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions spec/fixtures/pipenv_python_version_unspecified/bin/compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# This file is run by the inline buildpack, and tests that the environment is
# configured as expected for buildpacks that run after the Python buildpack.

set -euo pipefail

printenv | sort | grep -vE '^(_|BUILDPACK_LOG_FILE|DYNO|HOME|PWD|REQUEST_ID|SHLVL|SOURCE_VERSION|STACK)='
echo

python -c 'import pprint, sys; pprint.pp(sys.path)'
echo

# TODO: Investigate why 'pipenv graph' doesn't work here.
# TODO: Remove --disable-pip-version-check in favour of exporting PIP_DISABLE_PIP_VERSION_CHECK
pip list --disable-pip-version-check
echo

python -c 'import typing_extensions; print(typing_extensions)'
7 changes: 7 additions & 0 deletions spec/fixtures/pipenv_python_version_unspecified/bin/detect
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

# This file is run by the inline buildpack.

set -euo pipefail

echo "Inline"
9 changes: 9 additions & 0 deletions spec/fixtures/pipenv_python_version_unspecified/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file is here to confirm we don't try and create the fallback requirements
# file containing '-e .' when using Pipenv.

from setuptools import setup

setup(
name='test',
install_requires=['six'],
)
2 changes: 1 addition & 1 deletion spec/fixtures/python_3.10_outdated/runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.10.5
python-3.10.0
2 changes: 1 addition & 1 deletion spec/fixtures/python_3.8_outdated/runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.8.12
python-3.8.0
2 changes: 1 addition & 1 deletion spec/fixtures/python_3.9_outdated/runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.9.12
python-3.9.0
Loading

0 comments on commit 717145f

Please sign in to comment.