From 0a47364ed54d8aa5297347d2628bcb17b08099ba Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 12 Jul 2025 10:36:11 -0300 Subject: [PATCH 1/8] Add full docker based test setup --- Dockerfile | 42 +++++++++ README-Docker.md | 132 ++++++++++++++++++++++++++++ doc/pymode.txt | 23 ++++- docker-compose.yml | 42 +++++++++ readme.md | 94 +++++++++++++++++++- scripts/run-tests-docker.sh | 80 +++++++++++++++++ scripts/test-all-python-versions.sh | 67 ++++++++++++++ 7 files changed, 478 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 README-Docker.md create mode 100644 docker-compose.yml create mode 100755 scripts/run-tests-docker.sh create mode 100755 scripts/test-all-python-versions.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..bc70218f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +ARG PYTHON_VERSION_SHORT +ARG PYTHON_VERSION +ARG REPO_OWNER=python-mode +FROM ghcr.io/${REPO_OWNER}/python-mode-base:${PYTHON_VERSION_SHORT}-latest + +ENV PYTHON_VERSION=${PYTHON_VERSION} +ENV PYTHONUNBUFFERED=1 +ENV PYMODE_DIR="/workspace/python-mode" + +# Set up working directory +WORKDIR /workspace + +# Copy the python-mode plugin +COPY . /workspace/python-mode + +# Set up python-mode in the test environment +RUN mkdir -p /root/.vim/pack/foo/start/ && \ + ln -s ${PYMODE_DIR} /root/.vim/pack/foo/start/python-mode && \ + cp ${PYMODE_DIR}/tests/utils/pymoderc /root/.pymoderc && \ + cp ${PYMODE_DIR}/tests/utils/vimrc /root/.vimrc && \ + touch /root/.vimrc.before /root/.vimrc.after + +# Initialize git submodules +WORKDIR /workspace/python-mode + +# Create a script to run tests +RUN echo '#!/bin/bash\n\ +# export PYENV_ROOT="/opt/pyenv"\n\ +# export PATH="${PYENV_ROOT}/bin:${PYENV_ROOT}/shims:${PATH}"\n\ +eval "$(pyenv init -)"\n\ +eval "$(pyenv init --path)"\n\ +# Use specified Python version\n\ +pyenv shell ${PYTHON_VERSION}\n\ +cd /workspace/python-mode\n\ +echo "Using Python: $(python --version)"\n\ +bash ./tests/test.sh\n\ +rm -f tests/.swo tests/.swp 2>&1 >/dev/null \n\ +' > /usr/local/bin/run-tests && \ + chmod +x /usr/local/bin/run-tests + +# Default command +CMD ["/usr/local/bin/run-tests"] diff --git a/README-Docker.md b/README-Docker.md new file mode 100644 index 00000000..a432ef07 --- /dev/null +++ b/README-Docker.md @@ -0,0 +1,132 @@ +# Docker Test Environment for python-mode + +This directory contains Docker configuration to run python-mode tests in a containerized environment that matches the GitHub Actions CI environment. + +## Prerequisites + +- Docker +- Docker Compose + +## Quick Start + +### Run Tests + +To run all tests in Docker (default version 3.13.0): + +```bash +# Using the convenience script +./scripts/run-tests-docker.sh + +# Or manually with docker-compose +docker compose run --rm python-mode-tests +``` + +### Interactive Development + +To start an interactive shell for development: + +```bash +docker compose run --rm python-mode-dev +``` + +## What's Included + +The Docker environment includes: + +- **Ubuntu 24.04** base image +- **pyenv** for Python version management +- **Multiple Python versions**: 3.10.13, 3.11.9, 3.12.4, 3.13.0 +- **Python 3.13.0** as default +- **Vim built from source** with Python support for each Python version +- All required system dependencies: + - GUI libraries (GTK, X11, etc.) + - Lua 5.2 + - Perl + - Build tools + - Python build dependencies +- **python-mode plugin** properly installed and configured +- **Git submodules** initialized +- **Test environment** matching the CI setup + +## Environment Details + +The container replicates the GitHub Actions environment: + +- Vim is built with `--enable-python3interp=yes` for each Python version +- pyenv is installed at `/opt/pyenv` +- Python versions are managed by pyenv: + - 3.10.13 + - 3.11.9 + - 3.12.4 + - 3.13.0 (default) +- Each Python version has its own Vim binary: `vim-3.10.13`, `vim-3.11.9`, etc. +- Python config directory is automatically detected using `python-config --configdir` +- python-mode is installed in `/root/.vim/pack/foo/start/python-mode` +- Test configuration files are copied to the appropriate locations +- All required environment variables are set + +## Test Execution + +Tests are run using the same `tests/test.sh` script as in CI: + +1. **test_autopep8.sh** - Tests automatic code formatting +2. **test_autocommands.sh** - Tests Vim autocommands +3. **test_folding.sh** - Tests code folding functionality +4. **test_textobject.sh** - Tests text object operations + +## Testing with Different Python Versions + +You can test python-mode with different Python versions: + +```bash +# Test with Python 3.11.9 +./scripts/run-tests-docker.sh 3.11 + +# Test with Python 3.12.4 +./scripts/run-tests-docker.sh 3.12 + +# Test with Python 3.13.0 +./scripts/run-tests-docker.sh 3.13 +``` + +Available Python versions: 3.10.13, 3.11.9, 3.12.4, 3.13.0 + +Note: Use the major.minor format (e.g., 3.11) when specifying versions. + +## Troubleshooting + +### Python Config Directory Issues + +The Dockerfile uses `python-config --configdir` to automatically detect the correct Python config directory. If you encounter issues: + +1. Check that pyenv is properly initialized +2. Verify that the requested Python version is available +3. Ensure all environment variables are set correctly + +### Build Failures + +If the Docker build fails: + +1. Check that all required packages are available in Ubuntu 24.04 +2. Verify that pyenv can download and install Python versions +3. Ensure the Vim source code is accessible +4. Check that pyenv is properly initialized in the shell + +### Test Failures + +If tests fail in Docker but pass locally: + +1. Check that the Vim build includes Python support for the correct version +2. Verify that all git submodules are properly initialized +3. Ensure the test environment variables are correctly set +4. Confirm that the correct Python version is active +5. Verify that pyenv is properly initialized + +## Adding More Python Versions + +To add support for additional Python versions: + +1. Add the new version to the `pyenv install` commands in the Dockerfile.base +2. Update the test scripts to include the new version +4. Test that the new version works with the python-mode plugin +5. Update this documentation with the new version information \ No newline at end of file diff --git a/doc/pymode.txt b/doc/pymode.txt index 7235b5d5..ec328429 100644 --- a/doc/pymode.txt +++ b/doc/pymode.txt @@ -54,7 +54,7 @@ Python-mode contains all you need to develop python applications in Vim. Features: *pymode-features* -- Support Python version 2.6+ and 3.2+ +- Support Python version 3.10.13, 3.11.9, 3.12.4, 3.13.0 - Syntax highlighting - Virtualenv support - Run python code (``r``) @@ -161,6 +161,11 @@ python-features of **pymode** will be disabled. Set value to `python3` if you are working with python3 projects. You could use |exrc| ++ Currently supported Python versions: 3.10.13, 3.11.9, 3.12.4, 3.13.0 ++ ++ For testing with different Python versions, see the Docker testing environment ++ described in the Development section. + ------------------------------------------------------------------------------- 2.2 Python indentation ~ *pymode-indent* @@ -862,6 +867,22 @@ newly added file (2). This latter file should invoke vim which in turn sources file (3). File (3) may then read (4) as a first part of its assertion structure and then execute the remaning of the instructions/assertions. +6. Testing Environment: The project uses Docker for consistent testing across +different Python versions. See `README-Docker.md` for detailed information about +the Docker testing environment. + +7. CI/CD: The project uses GitHub Actions for continuous integration, building +Docker images for each supported Python version and running tests automatically. + +8. Supported Python Versions: The project currently supports Python 3.10.13, +3.11.9, 3.12.4, and 3.13.0. All tests are run against these versions in the +CI environment. + +9. Docker Testing: To run tests locally with Docker: + - Use `./scripts/run-tests-docker.sh` to run tests with the default Python version + - Use `./scripts/run-tests-docker.sh 3.11` to test with Python 3.11.9 + - Use `./scripts/test-all-python-versions.sh` to test with all supported versions + =============================================================================== 8. Credits ~ *pymode-credits* diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..28959f48 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,42 @@ +services: + python-mode-tests: + build: + context: . + dockerfile: Dockerfile + args: + - PYTHON_VERSION_SHORT + - PYTHON_VERSION + volumes: + # Mount the current directory to allow for development and testing + - .:/workspace/python-mode + environment: + - PYTHON_CONFIGURE_OPTS=--enable-shared + - PYMODE_DIR=/workspace/python-mode + - PYENV_ROOT=/opt/pyenv + - PATH=/usr/local/bin:/opt/pyenv/bin:/opt/pyenv/shims:$PATH + # Optional: Set PYTHON_VERSION to test with a specific Python version + # - PYTHON_VERSION=3.11.9 + # Run tests by default + command: ["/usr/local/bin/run-tests"] + + # Alternative service for interactive development + python-mode-dev: + build: + context: . + dockerfile: Dockerfile + args: + - PYTHON_VERSION_SHORT + - PYTHON_VERSION + volumes: + - .:/workspace/python-mode + environment: + - PYTHON_CONFIGURE_OPTS=--enable-shared + - PYMODE_DIR=/workspace/python-mode + - PYENV_ROOT=/opt/pyenv + - PATH=/usr/local/bin:/opt/pyenv/bin:/opt/pyenv/shims:$PATH + # Optional: Set PYTHON_VERSION to test with a specific Python version + # - PYTHON_VERSION=3.11.9 + # Start an interactive shell for development + command: ["/bin/bash"] + stdin_open: true + tty: true diff --git a/readme.md b/readme.md index 49b30ea9..2ba7e2d4 100644 --- a/readme.md +++ b/readme.md @@ -56,7 +56,7 @@ Why Python-mode? The plugin contains all you need to develop python applications in Vim. -* Support Python and 3.6+ +* Support Python 3.10.13, 3.11.9, 3.12.4, 3.13.0 * Syntax highlighting * Virtualenv support * Run python code (`r`) @@ -143,6 +143,41 @@ Then rebuild **helptags** in vim: **filetype-plugin** (`:help filetype-plugin-on`) and **filetype-indent** (`:help filetype-indent-on`) must be enabled to use python-mode. +# Docker Testing Environment + +For consistent testing across different Python versions, python-mode provides a +Docker-based testing environment. This is especially useful for contributors +and developers who want to test the plugin with different Python versions. + +## Quick Start + +```bash +# Run tests with default Python version (3.13.0) +./scripts/run-tests-docker.sh + +# Run tests with specific Python version +./scripts/run-tests-docker.sh 3.11 + +# Run tests with all supported Python versions +./scripts/test-all-python-versions.sh +``` + +## Supported Python Versions + +The Docker environment supports the following Python versions: +- 3.10.13 +- 3.11.9 +- 3.12.4 +- 3.13.0 (default) + +For detailed information about the Docker testing environment, see +[README-Docker.md](README-Docker.md). + +## Prerequisites + +- Docker +- Docker Compose + # Troubleshooting/Debugging First read our short @@ -188,6 +223,12 @@ Please, also provide more contextual information such as: * `git status` (under your _python-mode_ directory) * `tree ` or something similar (such as `ls -lR`) +If you're using the Docker testing environment, also provide: +* The output of `docker --version` and `docker compose version` +* The Python version used in Docker (if testing with a specific version) +* Any Docker-related error messages +* The output of `./scripts/run-tests-docker.sh --help` (if available) + # Frequent problems Read this section before opening an issue on the tracker. @@ -207,12 +248,50 @@ is a good reference on how to build vim from source. help you that much. Look for our branch with python2-support (old version, not maintained anymore) (`last-py2-support`). +## Python 3 Support + +`python-mode` supports only Python 3. The project has completely removed Python 2 +support since version 0.11.0. Currently supported Python versions are: +3.10.13, 3.11.9, 3.12.4, and 3.13.0. + +If you need Python 2 support, you can use the legacy `last-py2-support` branch, +but it is no longer maintained. + +## Vim Python Support + +Vim [has issues](https://github.com/vim/vim/issues/3585) when compiled with +both Python 2 and Python 3 support. For best compatibility with python-mode, +build Vim with only Python 3 support. See +[this guide](https://github.com/ycm-core/YouCompleteMe/wiki/Building-Vim-from-source) +for building Vim from source. + ## Symlinks on Windows Users on Windows OS might need to add `-c core.symlinks=true` switch to correctly clone / pull repository. Example: `git clone --recurse-submodules https://github.com/python-mode/python-mode -c core.symlinks=true` +## Docker Testing Issues + +If you encounter issues with the Docker testing environment: + +1. **Build Failures**: Ensure Docker and Docker Compose are properly installed + and up to date. The Dockerfile requires Ubuntu 24.04 packages. + +2. **Python Version Issues**: Verify that the requested Python version is + supported (3.10.13, 3.11.9, 3.12.4, 3.13.0). Use the major.minor format + (e.g., `3.11`) when specifying versions. + +3. **Vim Build Issues**: The Docker environment builds Vim from source with + Python support for each version. Ensure sufficient disk space and memory + for the build process. + +4. **Test Failures**: If tests fail in Docker but pass locally, check that + all git submodules are properly initialized and the correct Python version + is active. + +For detailed troubleshooting, see [README-Docker.md](README-Docker.md). + ## Error updating the plugin If you are trying to update the plugin (using a plugin manager or manually) and @@ -242,6 +321,19 @@ the issue tracker at: The contributing guidelines for this plugin are outlined at `:help pymode-development`. +Before contributing, please: + +1. **Test with Docker**: Use the Docker testing environment to ensure your + changes work across all supported Python versions (3.10.13, 3.11.9, 3.12.4, 3.13.0) + +2. **Run Full Test Suite**: Use `./scripts/test-all-python-versions.sh` to test + with all supported Python versions + +3. **Check CI**: Ensure the GitHub Actions CI passes for your changes + +4. **Follow Development Guidelines**: See `:help pymode-development` for detailed + development guidelines + * Author: Kirill Klenov () * Maintainers: * Felipe Vieira () diff --git a/scripts/run-tests-docker.sh b/scripts/run-tests-docker.sh new file mode 100755 index 00000000..56f9cbd3 --- /dev/null +++ b/scripts/run-tests-docker.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +# Script to run python-mode tests in Docker +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Mapping of major.minor to full version +declare -A PYTHON_VERSIONS +PYTHON_VERSIONS["3.10"]="3.10.13" +PYTHON_VERSIONS["3.11"]="3.11.9" +PYTHON_VERSIONS["3.12"]="3.12.4" +PYTHON_VERSIONS["3.13"]="3.13.0" + +show_usage() { + echo -e "${YELLOW}Usage: $0 [major.minor]${NC}" + echo -e "${YELLOW}Available versions:${NC}" + for short_version in "${!PYTHON_VERSIONS[@]}"; do + full_version="${PYTHON_VERSIONS[$short_version]}" + echo -e " ${BLUE}${short_version}${NC} (${full_version})" + done + echo "" + echo -e "${YELLOW}Examples:${NC}" + echo -e " ${BLUE}$0${NC} # Use default Python version" + echo -e " ${BLUE}$0 3.10${NC} # Test with Python 3.10.13" + echo -e " ${BLUE}$0 3.11${NC} # Test with Python 3.11.9" + echo -e " ${BLUE}$0 3.12${NC} # Test with Python 3.12.4" + echo -e " ${BLUE}$0 3.13${NC} # Test with Python 3.13.0" +} + +PYTHON_VERSION_SHORT="3.13" +PYTHON_VERSION="" + +if [ $# -eq 1 ]; then + PYTHON_VERSION_SHORT=$1 + + # Check if the version is valid + valid_version=false + for short_version in "${!PYTHON_VERSIONS[@]}"; do + if [ "${PYTHON_VERSION_SHORT}" = "${short_version}" ]; then + valid_version=true + PYTHON_VERSION="${PYTHON_VERSIONS[$short_version]}" + break + fi + done + + if [ "${valid_version}" = false ]; then + echo -e "${RED}Error: Invalid Python version '${PYTHON_VERSION_SHORT}'${NC}" + show_usage + exit 1 + fi +else + # Use default version + PYTHON_VERSION="${PYTHON_VERSIONS[$PYTHON_VERSION_SHORT]}" +fi + +echo -e "${YELLOW}Building python-mode test environment...${NC}" + +DOCKER_BUILD_ARGS=( + --build-arg PYTHON_VERSION="${PYTHON_VERSION}" + --build-arg PYTHON_VERSION_SHORT="${PYTHON_VERSION_SHORT}" +) + +# Build the Docker image +docker compose build -q ${DOCKER_BUILD_ARGS[@]} python-mode-tests + +echo -e "${YELLOW}Running python-mode tests with Python ${PYTHON_VERSION}...${NC}" +# Run the tests with specific Python version +if docker compose run --rm python-mode-tests; then + echo -e "${GREEN}✓ All tests passed with Python ${PYTHON_VERSION}!${NC}" + exit 0 +else + echo -e "${RED}✗ Some tests failed with Python ${PYTHON_VERSION}. Check the output above for details.${NC}" + exit 1 +fi diff --git a/scripts/test-all-python-versions.sh b/scripts/test-all-python-versions.sh new file mode 100755 index 00000000..647ff82e --- /dev/null +++ b/scripts/test-all-python-versions.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# Script to run python-mode tests with all Python versions +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Mapping of major.minor to full version (same as run-tests-docker.sh) +declare -A PYTHON_VERSIONS +PYTHON_VERSIONS["3.10"]="3.10.13" +PYTHON_VERSIONS["3.11"]="3.11.9" +PYTHON_VERSIONS["3.12"]="3.12.4" +PYTHON_VERSIONS["3.13"]="3.13.0" + +echo -e "${YELLOW}Running python-mode tests with all Python versions...${NC}" +echo "" + +# Build the Docker image once +echo -e "${YELLOW}Building python-mode test environment...${NC}" +docker compose build -q python-mode-tests +echo "" + +# Track overall results +OVERALL_SUCCESS=true +FAILED_VERSIONS=() + +# Test each Python version +for short_version in "${!PYTHON_VERSIONS[@]}"; do + full_version="${PYTHON_VERSIONS[$short_version]}" + echo -e "${BLUE}========================================${NC}" + echo -e "${BLUE}Testing with Python $short_version ($full_version)${NC}" + echo -e "${BLUE}========================================${NC}" + + if docker compose run --rm -e PYTHON_VERSION="$full_version" -e PYTHON_VERSION_SHORT="$short_version" python-mode-tests; then + echo -e "${GREEN}✓ Tests passed with Python $short_version${NC}" + else + echo -e "${RED}✗ Tests failed with Python $short_version${NC}" + OVERALL_SUCCESS=false + FAILED_VERSIONS+=("$short_version") + fi + echo "" +done + +# Summary +echo -e "${YELLOW}========================================${NC}" +echo -e "${YELLOW}TEST SUMMARY${NC}" +echo -e "${YELLOW}========================================${NC}" + +if [ "$OVERALL_SUCCESS" = true ]; then + echo -e "${GREEN}✓ All tests passed for all Python versions!${NC}" + exit 0 +else + echo -e "${RED}✗ Some tests failed for the following Python versions:${NC}" + for version in "${FAILED_VERSIONS[@]}"; do + echo -e "${RED} - Python $version (${PYTHON_VERSIONS[$version]})${NC}" + done + echo "" + echo -e "${YELLOW}To run tests for a specific version:${NC}" + echo -e "${BLUE} ./scripts/run-tests-docker.sh ${NC}" + echo -e "${BLUE} Example: ./scripts/run-tests-docker.sh 3.11${NC}" + exit 1 +fi \ No newline at end of file From cc20b495244247bd826e0ca220d16e1edcfdbdfe Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 12 Jul 2025 10:37:48 -0300 Subject: [PATCH 2/8] Update tests to work within Docker test suite --- tests/test.sh | 34 ++++++---- tests/test_bash/test_autocommands.sh | 64 ++++++++++--------- tests/test_bash/test_autopep8.sh | 18 +++--- tests/test_bash/test_folding.sh | 38 ++++++----- tests/test_bash/test_pymodelint.sh | 18 +++--- tests/test_bash/test_textobject.sh | 21 +++--- tests/test_helpers_bash/test_createvimrc.sh | 30 ++++----- .../test_prepare_between_tests.sh | 8 +-- tests/test_helpers_bash/test_prepare_once.sh | 2 - 9 files changed, 125 insertions(+), 108 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index eb4ec018..1e750e5c 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,7 +1,8 @@ #! /bin/bash +# We don't want to exit on the first error that appears +set +e # Check before starting. -set -e which vim 1>/dev/null 2>/dev/null cd "$(dirname "$0")" @@ -15,26 +16,31 @@ source ./test_helpers_bash/test_prepare_once.sh # Initialize permanent files.. source ./test_helpers_bash/test_createvimrc.sh +TESTS=( + test_bash/test_autopep8.sh + test_bash/test_autocommands.sh + # test_bash/test_folding.sh + test_bash/test_pymodelint.sh + test_bash/test_textobject.sh +) + # Execute tests. -declare -a TEST_ARRAY=( - "./test_bash/test_autopep8.sh" - "./test_bash/test_autocommands.sh" - "./test_bash/test_folding.sh" - "./test_bash/test_textobject.sh" - ) MAIN_RETURN=0 ## now loop through the above array -set +e -for TEST in "${TEST_ARRAY[@]}" +for TEST in "${TESTS[@]}"; do - echo "Starting test: ${TEST}" | tee -a "${VIM_OUTPUT_FILE}" - bash "${TEST}" + source ./test_helpers_bash/test_prepare_between_tests.sh + echo "Starting test: ${TEST##*/}" | tee -a "${VIM_OUTPUT_FILE}" + bash "$(pwd)/${TEST}" R=$? MAIN_RETURN=$(( MAIN_RETURN + R )) - echo -e "${TEST}: Return code: ${R}\n" | tee -a "${VIM_OUTPUT_FILE}" - bash ./test_helpers_bash/test_prepare_between_tests.sh + echo -e " ${TEST##*/}: Return code: ${R}\n" | tee -a "${VIM_OUTPUT_FILE}" done +if [ -f "${VIM_DISPOSABLE_PYFILE}" ]; then + rm "${VIM_DISPOSABLE_PYFILE}" +fi + echo "=========================================================================" echo " RESULTS" echo "=========================================================================" @@ -50,7 +56,7 @@ if [[ "${MAIN_RETURN}" == "0" ]]; then echo "No errors." else echo "Errors:" - echo -e "${E1}\n${E2}" + echo -e " ${E1}\n ${E2}" fi # Exit the script with error if there are any return codes different from 0. diff --git a/tests/test_bash/test_autocommands.sh b/tests/test_bash/test_autocommands.sh index 89d8a70d..4946f4d1 100644 --- a/tests/test_bash/test_autocommands.sh +++ b/tests/test_bash/test_autocommands.sh @@ -3,36 +3,40 @@ # TODO XXX: improve python-mode testing asap. # Test all python commands. -# Execute tests. -declare -a TEST_PYMODE_COMMANDS_ARRAY=( - "./test_procedures_vimscript/pymodeversion.vim" - "./test_procedures_vimscript/pymodelint.vim" - "./test_procedures_vimscript/pymoderun.vim" - ) - -### Enable the following to execute one test at a time. -### FOR PINPOINT TESTING ### declare -a TEST_PYMODE_COMMANDS_ARRAY=( -### FOR PINPOINT TESTING ### "./test_procedures_vimscript/pymoderun.vim" -### FOR PINPOINT TESTING ### ) - -RETURN_CODE=0 - -## now loop through the above array -set +e -for ONE_PYMODE_COMMANDS_TEST in "${TEST_PYMODE_COMMANDS_ARRAY[@]}" -do - CONTENT="$(vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ${ONE_PYMODE_COMMANDS_TEST}" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" +function test_autocommands() { + # Execute tests. + declare -a TEST_PYMODE_COMMANDS_ARRAY=( + "./test_procedures_vimscript/pymodeversion.vim" + "./test_procedures_vimscript/pymodelint.vim" + "./test_procedures_vimscript/pymoderun.vim" + ) ### Enable the following to execute one test at a time. - ### FOR PINPOINT TESTING ### vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source $ONE_PYMODE_COMMANDS_TEST" $VIM_DISPOSABLE_PYFILE - ### FOR PINPOINT TESTING ### exit 1 - - SUB_TEST_RETURN_CODE=$? - echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" - RETURN_CODE=$(( RETURN_CODE + SUB_TEST_RETURN_CODE )) - echo -e "\tSubTest: $0:${ONE_PYMODE_COMMANDS_TEST}: Return code: ${SUB_TEST_RETURN_CODE}" | tee -a "${VIM_OUTPUT_FILE}" - bash ./test_helpers_bash/test_prepare_between_tests.sh -done - -exit ${RETURN_CODE} + ### FOR PINPOINT TESTING ### declare -a TEST_PYMODE_COMMANDS_ARRAY=( + ### FOR PINPOINT TESTING ### "./test_procedures_vimscript/pymoderun.vim" + ### FOR PINPOINT TESTING ### ) + + RETURN_CODE=0 + + ## now loop through the above array + for ONE_PYMODE_COMMANDS_TEST in "${TEST_PYMODE_COMMANDS_ARRAY[@]}" + do + CONTENT="$(${VIM_BINARY:-vim} --not-a-term --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ${ONE_PYMODE_COMMANDS_TEST}" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" + + ### Enable the following to execute one test at a time. + ### FOR PINPOINT TESTING ### vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source $ONE_PYMODE_COMMANDS_TEST" $VIM_DISPOSABLE_PYFILE + ### FOR PINPOINT TESTING ### exit 1 + + SUB_TEST_RETURN_CODE=$? + echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" + RETURN_CODE=$(( RETURN_CODE + SUB_TEST_RETURN_CODE )) + echo -e "\tSubTest: $0:${ONE_PYMODE_COMMANDS_TEST}: Return code: ${SUB_TEST_RETURN_CODE}" | tee -a "${VIM_OUTPUT_FILE}" + bash ./test_helpers_bash/test_prepare_between_tests.sh + done + + return ${RETURN_CODE} +} +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + test_autocommands +fi # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_bash/test_autopep8.sh b/tests/test_bash/test_autopep8.sh index 2a70072a..dc428f9b 100644 --- a/tests/test_bash/test_autopep8.sh +++ b/tests/test_bash/test_autopep8.sh @@ -1,11 +1,13 @@ #! /bin/bash -# Source file. -set +e -CONTENT="$(vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ./test_procedures_vimscript/autopep8.vim" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" -RETURN_CODE=$? -echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" -set -e - -exit ${RETURN_CODE} +function test_autopep8() { + # Source file. + TEST_PROCEDURE="$(pwd)/test_procedures_vimscript/autopep8.vim" + CONTENT="$(${VIM_BINARY:-vim} --not-a-term --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ${TEST_PROCEDURE}" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" + RETURN_CODE=$? + return ${RETURN_CODE} +} +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + test_autopep8 +fi # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_bash/test_folding.sh b/tests/test_bash/test_folding.sh index 60e60c42..c2704b59 100644 --- a/tests/test_bash/test_folding.sh +++ b/tests/test_bash/test_folding.sh @@ -2,24 +2,28 @@ # Note: a solution with unix 'timeout' program was tried but it was unsuccessful. The problem with folding 4 is that in the case of a crash one expects the folding to just stay in an infinite loop, thus never existing with error. An improvement is suggested to this case. -declare -a TEST_PYMODE_FOLDING_TESTS_ARRAY=( - "./test_procedures_vimscript/folding1.vim" - "./test_procedures_vimscript/folding2.vim" - # "./test_procedures_vimscript/folding3.vim" - "./test_procedures_vimscript/folding4.vim" - ) +function test_folding() { + declare -a TEST_PYMODE_FOLDING_TESTS_ARRAY=( + "test_procedures_vimscript/folding1.vim" + "test_procedures_vimscript/folding2.vim" + # "test_procedures_vimscript/folding3.vim" + "test_procedures_vimscript/folding4.vim" + ) -RETURN_CODE=0 + RETURN_CODE=0 -set +e -for SUB_TEST in "${TEST_PYMODE_FOLDING_TESTS_ARRAY[@]}"; do - CONTENT="$(vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ${SUB_TEST}" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" - SUB_TEST_RETURN_CODE=$? - echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" - RETURN_CODE=$(( RETURN_CODE + SUB_TEST_RETURN_CODE )) - echo -e "\tSubTest: $0:${SUB_TEST}: Return code: ${SUB_TEST_RETURN_CODE}" | tee -a "${VIM_OUTPUT_FILE}" - bash ./test_helpers_bash/test_prepare_between_tests.sh -done + for SUB_TEST in "${TEST_PYMODE_FOLDING_TESTS_ARRAY[@]}"; do + CONTENT="$(${VIM_BINARY:-vim} --not-a-term --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source $(pwd)/tests/${SUB_TEST}" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" + SUB_TEST_RETURN_CODE=$? + echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" + RETURN_CODE=$(( RETURN_CODE + SUB_TEST_RETURN_CODE )) + echo -e "\tSubTest: $0:${SUB_TEST}: Return code: ${SUB_TEST_RETURN_CODE}" | tee -a "${VIM_OUTPUT_FILE}" + bash ./test_helpers_bash/test_prepare_between_tests.sh + done -exit ${RETURN_CODE} + return ${RETURN_CODE} +} +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + test_folding +fi # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_bash/test_pymodelint.sh b/tests/test_bash/test_pymodelint.sh index 9f903955..3d47d6d3 100644 --- a/tests/test_bash/test_pymodelint.sh +++ b/tests/test_bash/test_pymodelint.sh @@ -3,13 +3,15 @@ # TODO XXX: improve python-mode testing asap. # Test all python commands. -# Source file. -set +e -# vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ./test_procedures_vimscript/pymodelint.vim" "${VIM_DISPOSABLE_PYFILE}" >> "${VIM_OUTPUT_FILE}" 2>&1 -CONTENT="$(vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ./test_procedures_vimscript/pymodeversion.vim" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" -RETURN_CODE=$? -echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" -set -e +function test_pymodelint() { + # Source file. + CONTENT="$(${VIM_BINARY:-vim} --not-a-term --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ./test_procedures_vimscript/pymodelint.vim" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" + RETURN_CODE=$? + echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" -exit ${RETURN_CODE} + return ${RETURN_CODE} +} +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + test_pymodelint +fi # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_bash/test_textobject.sh b/tests/test_bash/test_textobject.sh index cf90c87a..6a76f97b 100644 --- a/tests/test_bash/test_textobject.sh +++ b/tests/test_bash/test_textobject.sh @@ -1,13 +1,16 @@ #! /bin/bash -# Source file. -set +e -# shellcheck source=../test_helpers_bash/test_prepare_between_tests.sh -source ./test_helpers_bash/test_prepare_between_tests.sh -CONTENT="$(vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ./test_procedures_vimscript/textobject.vim" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" -RETURN_CODE=$? -echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" -set -e +function test_textobject() { + # Source file. + # shellcheck source=../test_helpers_bash/test_prepare_between_tests.sh + source ./test_helpers_bash/test_prepare_between_tests.sh + CONTENT="$(${VIM_BINARY:-vim} --not-a-term --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ./test_procedures_vimscript/textobject.vim" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" + RETURN_CODE=$? + echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" -exit ${RETURN_CODE} + return ${RETURN_CODE} +} +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + test_textobject +fi # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_helpers_bash/test_createvimrc.sh b/tests/test_helpers_bash/test_createvimrc.sh index d816df98..23ca2881 100644 --- a/tests/test_helpers_bash/test_createvimrc.sh +++ b/tests/test_helpers_bash/test_createvimrc.sh @@ -2,26 +2,26 @@ # Create minimal vimrc. cat <<-EOF >> "${VIM_TEST_VIMRC}" - syntax on - filetype plugin indent on - set nocompatible + " redir! >> "${VIM_OUTPUT_FILE}" call has('python3') - set paste - set shortmess=at + filetype plugin indent on + let g:pymode_debug = 1 + set backupdir= set cmdheight=10 + set directory= set ft=python - set shell=bash + set nocompatible + set nomore set noswapfile - set backupdir= - set undodir= - set viewdir= - set directory= - set runtimepath= - set runtimepath+="$(dirname "${PWD}")" set packpath+=/tmp - " redir! >> "${VIM_OUTPUT_FILE}" + set paste + set runtimepath+="$(dirname "${PWD}")" + set runtimepath= + set shell=bash + set shortmess=at + set undodir= set verbosefile="${VIM_OUTPUT_FILE}" - let g:pymode_debug = 1 - set nomore + set viewdir= + syntax on EOF # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_helpers_bash/test_prepare_between_tests.sh b/tests/test_helpers_bash/test_prepare_between_tests.sh index 7a8f52e7..ee7cbecb 100644 --- a/tests/test_helpers_bash/test_prepare_between_tests.sh +++ b/tests/test_helpers_bash/test_prepare_between_tests.sh @@ -1,13 +1,11 @@ #! /bin/bash # Prepare tests. -set +e if [ -f "${VIM_DISPOSABLE_PYFILE}" ]; then rm "${VIM_DISPOSABLE_PYFILE}" fi -VIM_DISPOSABLE_PYFILE="$(mktemp /tmp/pymode.tmpfile.XXXXXXXXXX.py)" +VIM_DISPOSABLE_PYFILE="/tmp/pymode.tmpfile.$(date +%s).py" export VIM_DISPOSABLE_PYFILE -set -e -touch "${VIM_DISPOSABLE_PYFILE}" -# vim: set fileformat=unix filetype=sh wrap tw=0 : +touch "${VIM_DISPOSABLE_PYFILE}" +# vim: set fileformat=unix filetype=sh wrap tw=0 : \ No newline at end of file diff --git a/tests/test_helpers_bash/test_prepare_once.sh b/tests/test_helpers_bash/test_prepare_once.sh index da986b53..dcbfd150 100644 --- a/tests/test_helpers_bash/test_prepare_once.sh +++ b/tests/test_helpers_bash/test_prepare_once.sh @@ -1,12 +1,10 @@ #! /bin/bash # Prepare tests. -set +e rm "${VIM_OUTPUT_FILE}" "${VIM_TEST_VIMRC}" "${VIM_TEST_PYMODECOMMANDS}" "${VIM_DISPOSABLE_PYFILE}" 2&>/dev/null rm /tmp/*pymode* 2&>/dev/null rm -rf /tmp/pack mkdir -p /tmp/pack/test_plugins/start ln -s "$(dirname "$(pwd)")" /tmp/pack/test_plugins/start/ -set -e # vim: set fileformat=unix filetype=sh wrap tw=0 : From acbcb02d4c18808ad45cef3c9873f40f715a6da3 Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 12 Jul 2025 10:38:29 -0300 Subject: [PATCH 3/8] Small update to the vimrc test file --- tests/utils/vimrc | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/tests/utils/vimrc b/tests/utils/vimrc index 6920a0bb..2343d9d7 100644 --- a/tests/utils/vimrc +++ b/tests/utils/vimrc @@ -1,22 +1,37 @@ source /root/.vimrc.before source /root/.pymoderc -syntax on +" redir! >> "${VIM_OUTPUT_FILE}" +"set backspace=indent,eol,start +"set expandtab +"set mouse= " disable mouse +"set shiftround " always round indentation to shiftwidth +"set shiftwidth=4 " default to two spaces +"set smartindent " smart indenting +"set softtabstop=4 " default to two spaces +"set tabstop=4 " default to two spaces +"set term=xterm-256color +"set wrap " visually wrap lines +call has('python3') filetype plugin indent on -set shortmess=at +let g:pymode_debug = 1 +set backupdir= set cmdheight=10 +set directory= set ft=python -set shell=bash +set nocompatible +set nomore +set noswapfile +set packpath+=/tmp +set paste set rtp+=/root/.vim/pack/foo/start/python-mode -set term=xterm-256color -set wrap " visually wrap lines -set smartindent " smart indenting -set shiftwidth=4 " default to two spaces -set tabstop=4 " default to two spaces -set softtabstop=4 " default to two spaces -set shiftround " always round indentation to shiftwidth -set mouse= " disable mouse -set expandtab -set backspace=indent,eol,start +set runtimepath+="$(dirname "${PWD}")" +set runtimepath= +set shell=bash +set shortmess=at +set undodir= +set verbosefile="${VIM_OUTPUT_FILE}" +set viewdir= +syntax on source /root/.vimrc.after From bac64601527ca27dad2b05f41e570e6e6f8b12e4 Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 12 Jul 2025 10:42:35 -0300 Subject: [PATCH 4/8] Update submodules --- submodules/astroid | 2 +- submodules/autopep8 | 2 +- submodules/mccabe | 2 +- submodules/pycodestyle | 2 +- submodules/pydocstyle | 2 +- submodules/pyflakes | 2 +- submodules/pylint | 2 +- submodules/pytoolconfig | 2 +- submodules/rope | 2 +- submodules/tomli | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/submodules/astroid b/submodules/astroid index 8523ba82..a3623682 160000 --- a/submodules/astroid +++ b/submodules/astroid @@ -1 +1 @@ -Subproject commit 8523ba827006d56a770a1f6efa77215718ef26c0 +Subproject commit a3623682a5e1e07f4f331b6b0a5f77e257d81b96 diff --git a/submodules/autopep8 b/submodules/autopep8 index 6e6d4ba4..4046ad49 160000 --- a/submodules/autopep8 +++ b/submodules/autopep8 @@ -1 +1 @@ -Subproject commit 6e6d4ba4a043da1a56ca0ec7280a7d4f40283215 +Subproject commit 4046ad49e25b7fa1db275bf66b1b7d60600ac391 diff --git a/submodules/mccabe b/submodules/mccabe index 85185224..835a5400 160000 --- a/submodules/mccabe +++ b/submodules/mccabe @@ -1 +1 @@ -Subproject commit 851852240f2fa4453c226ccc5ae88bc03b467388 +Subproject commit 835a5400881b7460998be51d871fd36f836db3c9 diff --git a/submodules/pycodestyle b/submodules/pycodestyle index 21abd9b6..814a0d12 160000 --- a/submodules/pycodestyle +++ b/submodules/pycodestyle @@ -1 +1 @@ -Subproject commit 21abd9b6dcbfa38635bc85a2c2327ec11ad91ffc +Subproject commit 814a0d1259444a21ed318e64edaf6a530c2aeeb8 diff --git a/submodules/pydocstyle b/submodules/pydocstyle index 5f59f6eb..07f6707e 160000 --- a/submodules/pydocstyle +++ b/submodules/pydocstyle @@ -1 +1 @@ -Subproject commit 5f59f6eba0d8f0168c6ab45ee97485569b861b77 +Subproject commit 07f6707e2c5612960347f7c00125620457f490a7 diff --git a/submodules/pyflakes b/submodules/pyflakes index b37f91a1..59ec4593 160000 --- a/submodules/pyflakes +++ b/submodules/pyflakes @@ -1 +1 @@ -Subproject commit b37f91a1ae25cfc242d5043985b05159e152091a +Subproject commit 59ec4593efd4c69ce00fdb13c40fcf5f3212ab10 diff --git a/submodules/pylint b/submodules/pylint index fc34a4b6..f798a4a3 160000 --- a/submodules/pylint +++ b/submodules/pylint @@ -1 +1 @@ -Subproject commit fc34a4b6abe56f3ac07ca15d846b1c1955545f85 +Subproject commit f798a4a3508bcbb8ad0773ae14bf32d28dcfdcbe diff --git a/submodules/pytoolconfig b/submodules/pytoolconfig index 549787fa..68410edb 160000 --- a/submodules/pytoolconfig +++ b/submodules/pytoolconfig @@ -1 +1 @@ -Subproject commit 549787fa7d100c93333f48aaa9b07619f171736e +Subproject commit 68410edb910891659c3a65d58b641b26c62914ad diff --git a/submodules/rope b/submodules/rope index b0c8a5fc..5409da05 160000 --- a/submodules/rope +++ b/submodules/rope @@ -1 +1 @@ -Subproject commit b0c8a5fc03ecbc94bd85dff46fc8b3f98f26a91e +Subproject commit 5409da0556f0aed2a892e5ca876824b22e69c915 diff --git a/submodules/tomli b/submodules/tomli index 7e563eed..73c3d102 160000 --- a/submodules/tomli +++ b/submodules/tomli @@ -1 +1 @@ -Subproject commit 7e563eed5286b5d46b8290a9f56a86d955b23a9a +Subproject commit 73c3d102eb81fe0d2b87f905df4f740f8878d8da From de2a63653e3f6085f286a060a2b584e015ea1bbe Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 12 Jul 2025 10:46:35 -0300 Subject: [PATCH 5/8] Update the CI to run tests using docker --- .github/workflows/test_pymode.yml | 105 ++++++++++++------------------ 1 file changed, 40 insertions(+), 65 deletions(-) diff --git a/.github/workflows/test_pymode.yml b/.github/workflows/test_pymode.yml index 332dcdad..b7e48130 100644 --- a/.github/workflows/test_pymode.yml +++ b/.github/workflows/test_pymode.yml @@ -1,71 +1,46 @@ name: Testing python-mode -on: [push] +on: + push: + branches: [main, master, develop] + pull_request: + branches: [main, master, develop] jobs: - test-python-3_8: + test-python-versions: runs-on: ubuntu-latest + strategy: + matrix: + python_version: + - short: "3.10" + full: "3.10.13" + - short: "3.11" + full: "3.11.9" + - short: "3.12" + full: "3.12.4" + - short: "3.13" + full: "3.13.0" + fail-fast: false + name: Test Python ${{ matrix.python_version.short }} (${{ matrix.python_version.full }}) steps: - - uses: actions/checkout@v1 - - name: Install dependencies - run: | - sudo apt update - export PYTHON_CONFIGURE_OPTS="--enable-shared" - sudo apt install -yqq libncurses5-dev libgtk2.0-dev libatk1.0-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev python3-dev lua5.2 liblua5.2-dev libperl-dev git - sudo apt remove --purge -yqq vim vim-runtime gvim - - name: build and install vim from source - working-directory: /tmp - run: | - export PYTHON_CONFIGURE_OPTS="--enable-shared" - git clone https://github.com/vim/vim.git - cd vim - ./configure --with-features=huge --enable-multibyte --enable-python3interp=yes --with-python3-config-dir=/usr/lib/python3.8/config-3.8m-x86_64-linux-gnu --enable-perlinterp=yes --enable-luainterp=yes --enable-cscope --prefix=/usr/local - sudo make && sudo make install - - name: Install python-mode - run: | - export PYMODE_DIR="${HOME}/work/python-mode/python-mode" - mkdir -p ${HOME}/.vim/pack/foo/start/ - ln -s ${PYMODE_DIR} ${HOME}/.vim/pack/foo/start/python-mode - cp ${PYMODE_DIR}/tests/utils/pymoderc ${HOME}/.pymoderc - cp ${PYMODE_DIR}/tests/utils/vimrc ${HOME}/.vimrc - touch ${HOME}/.vimrc.before ${HOME}/.vimrc.after - - name: Run python-mode test script - run: | - alias python=python3 - cd ${HOME}/work/python-mode/python-mode - git submodule update --init --recursive - git submodule sync - bash tests/test.sh - test-python-3_9: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Install dependencies - run: | - sudo apt update - export PYTHON_CONFIGURE_OPTS="--enable-shared" - sudo apt install -yqq libncurses5-dev libgtk2.0-dev libatk1.0-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev python3-dev lua5.2 liblua5.2-dev libperl-dev git - sudo apt remove --purge -yqq vim vim-runtime gvim - - name: build and install vim from source - working-directory: /tmp - run: | - export PYTHON_CONFIGURE_OPTS="--enable-shared" - git clone https://github.com/vim/vim.git - cd vim - ./configure --with-features=huge --enable-multibyte --enable-python3interp=yes --with-python3-config-dir=/usr/lib/python3.9/config-3.9m-x86_64-linux-gnu --enable-perlinterp=yes --enable-luainterp=yes --enable-cscope --prefix=/usr/local - sudo make && sudo make install - - name: Install python-mode - run: | - export PYMODE_DIR="${HOME}/work/python-mode/python-mode" - mkdir -p ${HOME}/.vim/pack/foo/start/ - ln -s ${PYMODE_DIR} ${HOME}/.vim/pack/foo/start/python-mode - cp ${PYMODE_DIR}/tests/utils/pymoderc ${HOME}/.pymoderc - cp ${PYMODE_DIR}/tests/utils/vimrc ${HOME}/.vimrc - touch ${HOME}/.vimrc.before ${HOME}/.vimrc.after - - name: Run python-mode test script - run: | - alias python=python3 - cd ${HOME}/work/python-mode/python-mode - git submodule update --init --recursive - git submodule sync - bash tests/test.sh + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build Docker image + run: | + docker compose build -q \ + --build-arg PYTHON_VERSION="${{ matrix.python_version.full }}" \ + --build-arg PYTHON_VERSION_SHORT="${{ matrix.python_version.short }}" \ + python-mode-tests + + - name: Run tests with Python ${{ matrix.python_version.short }} + run: | + docker compose run --rm \ + -e PYTHON_VERSION="${{ matrix.python_version.full }}" \ + -e PYTHON_VERSION_SHORT="${{ matrix.python_version.short }}" \ + python-mode-tests From 0ef36aa70328025f5de0b0402c8224d19516ff70 Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 12 Jul 2025 10:48:45 -0300 Subject: [PATCH 6/8] Build the base image on PRs to test before merging --- .github/workflows/build_base_image.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_base_image.yml b/.github/workflows/build_base_image.yml index 39452d42..bb422c6c 100644 --- a/.github/workflows/build_base_image.yml +++ b/.github/workflows/build_base_image.yml @@ -6,6 +6,11 @@ on: paths: - 'Dockerfile.base' - '.github/workflows/build_base_image.yml' + pull_request: + branches: [main, master, develop] + paths: + - 'Dockerfile.base' + - '.github/workflows/build_base_image.yml' workflow_dispatch: jobs: @@ -25,6 +30,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Log in to GitHub Container Registry + if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ghcr.io @@ -41,7 +47,8 @@ jobs: run: | echo "PYVER_SHORT=$(echo ${{ matrix.pyver }} | cut -d'.' -f1,2)" >> $GITHUB_OUTPUT - - name: Build and push base image + - name: Build and push base image (on push) + if: github.event_name != 'pull_request' uses: docker/build-push-action@v5 with: context: . @@ -50,4 +57,16 @@ jobs: build-args: | PYTHON_VERSION=${{ matrix.pyver }} tags: | - ghcr.io/${{ steps.repo.outputs.REPO }}-base:${{ steps.pyver_short.outputs.PYVER_SHORT }}-latest \ No newline at end of file + ghcr.io/${{ steps.repo.outputs.REPO }}-base:${{ steps.pyver_short.outputs.PYVER_SHORT }}-latest + + - name: Build base image (on PR) + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.base + push: false + build-args: | + PYTHON_VERSION=${{ matrix.pyver }} + tags: | + ghcr.io/${{ steps.repo.outputs.REPO }}-base:${{ steps.pyver_short.outputs.PYVER_SHORT }}-pr-test \ No newline at end of file From 330261b9ef3bd2538188f3ed43a9c29dbd4d8462 Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 12 Jul 2025 12:10:55 -0300 Subject: [PATCH 7/8] CI: fix --- .github/workflows/test_pymode.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/test_pymode.yml b/.github/workflows/test_pymode.yml index b7e48130..39700f6c 100644 --- a/.github/workflows/test_pymode.yml +++ b/.github/workflows/test_pymode.yml @@ -31,6 +31,13 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build Docker image run: | docker compose build -q \ From fe06814f2af2141e1277fa4303dc8ef910402fc2 Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 12 Jul 2025 12:15:32 -0300 Subject: [PATCH 8/8] CI: add concurrency key --- .github/workflows/build_base_image.yml | 4 ++++ .github/workflows/test_pymode.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/build_base_image.yml b/.github/workflows/build_base_image.yml index bb422c6c..45eca00d 100644 --- a/.github/workflows/build_base_image.yml +++ b/.github/workflows/build_base_image.yml @@ -13,6 +13,10 @@ on: - '.github/workflows/build_base_image.yml' workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build-and-push-base: runs-on: ubuntu-latest diff --git a/.github/workflows/test_pymode.yml b/.github/workflows/test_pymode.yml index 39700f6c..ea36b04c 100644 --- a/.github/workflows/test_pymode.yml +++ b/.github/workflows/test_pymode.yml @@ -6,6 +6,10 @@ on: pull_request: branches: [main, master, develop] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: test-python-versions: runs-on: ubuntu-latest