diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..70215be --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +# Exclude files from releases/tarballs +tests/ export-ignore +.github/ export-ignore +.gitattributes export-ignore diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 5d88d2a..1c103b8 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,16 +1,21 @@ ## The Issue -- # +- Fixes #REPLACE_ME_WITH_RELATED_ISSUE_NUMBER ## How This PR Solves The Issue + + ## Manual Testing Instructions + + ```bash -ddev add-on get https://github.com///tarball/ +ddev add-on get https://github.com/stasadev/ddev-python2/tarball/refs/pull/REPLACE_ME_WITH_THIS_PR_NUMBER/head ddev restart +ddev exec python -V ``` ## Automated Testing Overview diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 67a5936..ffdc8a4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,11 +1,15 @@ name: tests on: pull_request: + paths-ignore: + - "**.md" push: branches: [ main ] + paths-ignore: + - "**.md" schedule: - - cron: '25 08 * * *' + - cron: '25 08 * * *' workflow_dispatch: inputs: diff --git a/README.md b/README.md index b75d04d..306c238 100644 --- a/README.md +++ b/README.md @@ -15,28 +15,21 @@ It is only needed if your `npm` setup requires Python 2 to build dependencies. ## Installation -For DDEV v1.23.5 or above run: - ```bash ddev add-on get stasadev/ddev-python2 ddev restart ``` -For earlier versions of DDEV run: - -```bash -ddev get stasadev/ddev-python2 -ddev restart -``` +After installation, make sure to commit the `.ddev` directory to version control. ## Usage -After installation, you can run Python 2: - -- `python2.7` (installed at `/usr/bin/python2.7`) -- `python` (symlink to `python2.7` installed at `/usr/local/bin/python`) +| Command | Description | +| ------- | ----------- | +| `ddev exec python2.7` | Run Python 2.7.18 inside the `web` container.
Installed at `/usr/bin/python2.7` | +| `ddev exec python` | Run Python 2.7.18 inside the `web` container.
Symlink at `/usr/local/bin/python` | -This add-on also adds packages that are normally required for `npm` build, see [config.python2.yaml](./config.python2.yaml). Remove or replace the contents of this file if you only need Python 2. +This add-on also installs the `build-essential` package, which is usually required for the `npm build`, see [config.python2.yaml](./config.python2.yaml). Remove or replace the contents of this file if you only need Python 2. ## Credits diff --git a/install.yaml b/install.yaml index 1557dd2..cb601d3 100644 --- a/install.yaml +++ b/install.yaml @@ -1,13 +1,7 @@ name: python2 -# list of files and directories listed that are copied into project .ddev directory project_files: - config.python2.yaml - web-build/Dockerfile.python2 -pre_install_actions: - # Ensure we're on DDEV 1.23+ which uses Debian 12+ with Python3, - # Python2 is available by default in previous versions of Debian. - - | - #ddev-description:Checking DDEV version - (ddev debug capabilities | grep corepack >/dev/null) || (echo "This addon should only be installed in DDEV v1.23+ since you already have Python2 in yours $(ddev --version)" && false) +ddev_version_constraint: '>= v1.23.5' diff --git a/tests/test.bats b/tests/test.bats index 7b7d09e..7fa175d 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -26,8 +26,8 @@ setup() { export DIR="$(cd "$(dirname "${BATS_TEST_FILENAME}")/.." >/dev/null 2>&1 && pwd)" export PROJNAME="test-$(basename "${GITHUB_REPO}")" - mkdir -p ~/tmp - export TESTDIR=$(mktemp -d ~/tmp/${PROJNAME}.XXXXXX) + mkdir -p "${HOME}/tmp" + export TESTDIR="$(mktemp -d "${HOME}/tmp/${PROJNAME}.XXXXXX")" export DDEV_NONINTERACTIVE=true export DDEV_NO_INSTRUMENTATION=true ddev delete -Oy "${PROJNAME}" >/dev/null 2>&1 || true @@ -50,8 +50,14 @@ health_checks() { teardown() { set -eu -o pipefail - ddev delete -Oy ${PROJNAME} >/dev/null 2>&1 - [ "${TESTDIR}" != "" ] && rm -rf ${TESTDIR} + ddev delete -Oy "${PROJNAME}" >/dev/null 2>&1 + # Persist TESTDIR if running inside GitHub Actions. Useful for uploading test result artifacts + # See example at https://github.com/ddev/github-action-add-on-test#preserving-artifacts + if [ -n "${GITHUB_ENV:-}" ]; then + [ -e "${GITHUB_ENV:-}" ] && echo "TESTDIR=${HOME}/tmp/${PROJNAME}" >> "${GITHUB_ENV}" + else + [ "${TESTDIR}" != "" ] && rm -rf "${TESTDIR}" + fi } @test "install from directory" {