From 59675eca225b779b8bdea797bd58c96bd0e3df71 Mon Sep 17 00:00:00 2001 From: Frej Drejhammar Date: Wed, 27 Dec 2023 12:57:56 +0100 Subject: [PATCH 1/4] Add command line flag to dump found versions Add `--debug` command line flag which dumps the detected versions of Mercurial and Python. This will probably help future debugging when unexpected versions are used. --- hg-fast-export.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hg-fast-export.sh b/hg-fast-export.sh index be52c5d..81339ab 100755 --- a/hg-fast-export.sh +++ b/hg-fast-export.sh @@ -86,6 +86,14 @@ case "$1" in echo "" echo "$LONG_USAGE" exit 0 + ;; + + --debug) + echo -n "Using Python: " + "${PYTHON}" --version + echo -n "Using Mercurial: " + hg --version + exit 0 esac IS_BARE=$(git rev-parse --is-bare-repository) \ From efe934e16b714588cb37f59c0b5e6d61ff4e65d4 Mon Sep 17 00:00:00 2001 From: Frej Drejhammar Date: Wed, 27 Dec 2023 13:04:03 +0100 Subject: [PATCH 2/4] Update required version of Python to 3.7 Due to problems with handling of Unicode input in Python < 3.7, bump the required version of Python to 3.7. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b4aa33c..abd9a70 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,9 @@ first time. System Requirements ------------------- -This project depends on Python 3.5+, and the Mercurial >= 5.2 package. -If Python is not installed, install it before proceeding. The Mercurial -package can be installed with `pip install mercurial`. +This project depends on Python (>=3.7) and the Mercurial package (>= +5.2). If Python is not installed, install it before proceeding. The +Mercurial package can be installed with `pip install mercurial`. On windows the bash that comes with "Git for Windows" is known to work well. From d4298a09060a00ac43b5c0e901fcf2c083d59b53 Mon Sep 17 00:00:00 2001 From: Frej Drejhammar Date: Wed, 27 Dec 2023 13:09:57 +0100 Subject: [PATCH 3/4] Check for a supported Python version on startup Check that hg-fast-export is running on a supported version of Python on startup. This is an attempt to avoid problems like #314 in the future. --- hg-fast-export.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hg-fast-export.sh b/hg-fast-export.sh index 81339ab..7d6d7b7 100755 --- a/hg-fast-export.sh +++ b/hg-fast-export.sh @@ -45,6 +45,14 @@ if [ -z "${PYTHON}" ]; then exit 1 fi +"${PYTHON}" -c 'import sys; exit(sys.version_info.major==3 and sys.version_info.minor >= 7)' + +if [ $? -eq 0 ]; then + echo "Could not find an interpreter for a supported Python version (>= 3.7)" \ + "Please use the 'PYTHON' environment variable to specify the interpreter to use." + exit 1 +fi + USAGE="[--quiet] [-r ] [--force] [--ignore-unnamed-heads] [-m ] [-s] [--hgtags] [-A ] [-B ] [-T ] [-M ] [-o ] [--hg-hash] [-e ]" LONG_USAGE="Import hg repository up to either tip or If is omitted, use last hg repository as obtained from state file, From 2476d0851738b797dbb36c84f1ec881051831c24 Mon Sep 17 00:00:00 2001 From: Frej Drejhammar Date: Wed, 27 Dec 2023 13:12:12 +0100 Subject: [PATCH 4/4] Run tests with multiple Python versions Run the CI tests with both the earliest supported Python version and the latest stable release. The intent is to quickly notice when new features require adjusting the oldest supported Python version and also detect when the latest stable version breaks old code (as when 3.12 removed `imp` and we witched to `importlib` in #311). --- .github/requirements-earliest.txt | 1 + .github/requirements-latest.txt | 2 + .github/workflows/ci.yml | 69 ++++++++++++++++++++++++++++--- 3 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 .github/requirements-earliest.txt create mode 100644 .github/requirements-latest.txt diff --git a/.github/requirements-earliest.txt b/.github/requirements-earliest.txt new file mode 100644 index 0000000..cc72e71 --- /dev/null +++ b/.github/requirements-earliest.txt @@ -0,0 +1 @@ +mercurial==5.2 diff --git a/.github/requirements-latest.txt b/.github/requirements-latest.txt new file mode 100644 index 0000000..3620838 --- /dev/null +++ b/.github/requirements-latest.txt @@ -0,0 +1,2 @@ +mercurial + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57efee7..e511200 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,8 +8,70 @@ on: branches: [master] jobs: - test: - name: Run test suite + test-earliest: + name: Run test suite on the earliest supported Python version + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + name: Checkout repository + with: + fetch-depth: 1 + submodules: 'recursive' + - uses: actions/setup-python@v5 + id: earliest + with: + python-version: '3.7.x' + check-latest: true + cache: 'pip' + cache-dependency-path: '**/requirements-earliest.txt' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r .github/requirements-earliest.txt + + - name: Report selected versions + run: | + echo Selected '${{ steps.earliest.outputs.python-version }}' + ./hg-fast-export.sh --debug + + - name: Run tests on earliest supported Python version + run: make -C t + + test-latest: + name: Run test suite on the latest supported python version + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + name: Checkout repository + with: + fetch-depth: 1 + submodules: 'recursive' + - uses: actions/setup-python@v5 + id: latest + with: + python-version: '3.x' + check-latest: true + cache: 'pip' + cache-dependency-path: '**/requirements-latest.txt' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r .github/requirements-latest.txt + + - name: Report selected version + run: | + echo Selected '${{ steps.latest.outputs.python-version }}' + ./hg-fast-export.sh --debug + + - name: Run tests on 3.x + run: make -C t + + code-quality: + name: Run code quality checks runs-on: ubuntu-latest steps: @@ -19,9 +81,6 @@ jobs: fetch-depth: 1 submodules: 'recursive' - - name: Run tests - run: make -C t - - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: