From 5de41a04b00d2933c4935e2face7e60235913083 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 6 Oct 2023 14:33:15 +0200 Subject: [PATCH 01/32] Fix typos --- .vscode/settings.json | 7 +++++++ setup.py | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7fe4e68 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "cSpell.ignoreWords": [ + "aarch", + "cmdclass", + "outfiles" + ] +} diff --git a/setup.py b/setup.py index 7aabada..1c8ab3f 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- """ -This setup logic is highly ispired to the one used in `https://github.com/shellcheck-py/shellcheck-py`. +This setup logic is highly inspired to the one used in `https://github.com/shellcheck-py/shellcheck-py`. After `https://github.com/editorconfig-checker/editorconfig-checker.python/issues/15` was opened, we decided to move the wrapper logic directly in the setup phase. @@ -88,10 +88,10 @@ def download_tarball(url): def extract_tarball(url, data): with BytesIO(data) as bio: if '.tar.' in url: - with tarfile_open(fileobj=bio) as tarf: - for info in tarf.getmembers(): + with tarfile_open(fileobj=bio) as fp: + for info in fp.getmembers(): if info.isfile() and info.name.startswith('bin/ec-'): - return tarf.extractfile(info).read() + return fp.extractfile(info).read() raise AssertionError('unreachable `extract` function') From df583d49dd8b55380df4c387cbd92780bc32dfb4 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 6 Oct 2023 14:36:12 +0200 Subject: [PATCH 02/32] Update core version to 2.7.1 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 1c8ab3f..4a2909e 100644 --- a/setup.py +++ b/setup.py @@ -31,8 +31,8 @@ from urllib2 import urlopen -WRAPPER_VERSION = '2.7.2' -EDITORCONFIG_CHECKER_CORE_VERSION = '2.7.0' +WRAPPER_VERSION = '2.7.3' +EDITORCONFIG_CHECKER_CORE_VERSION = '2.7.1' EDITORCONFIG_CHECKER_EXE_NAME = 'ec' From a4e8ef7b6d738dd9e1583495572e2395420e510a Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 6 Oct 2023 15:32:44 +0200 Subject: [PATCH 03/32] Fix LICENSE --- LICENSE | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 907ccc0..7754bd9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,9 @@ -The MIT License (MIT) +Original "https://github.com/shellcheck-py/shellcheck-py" Project License +========================================================================= -Copyright (c) 2019 Marco M. +MIT License + +Copyright (c) 2019 Ryan Rhee Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From db93ef0eb9964c80b8c4ec3ebcc0cff5eb15b88a Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 6 Oct 2023 17:44:49 +0200 Subject: [PATCH 04/32] Refactor tests --- .gitignore | 2 + run-tests.sh | 87 +++++++++++++++++++++------------------ tests/Dockerfile.template | 8 ++-- 3 files changed, 52 insertions(+), 45 deletions(-) diff --git a/.gitignore b/.gitignore index bec120d..f59b051 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,6 @@ bin/ build/ dist/ examples/ +issues/ +misc/ venv/ diff --git a/run-tests.sh b/run-tests.sh index 502b91c..029e14e 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -2,57 +2,64 @@ set -e -PY_DOCKER_IMAGES=("2.7.16-slim" "3.7.4-slim") DOCKERFILE_TEMPLATE="tests/Dockerfile.template" -PACKAGES=() +PY_DOCKER_IMAGES=() +PY_DOCKER_IMAGES+=("2.7.16-slim") +PY_DOCKER_IMAGES+=("3.7.4-slim") +PY_DOCKER_IMAGES+=("3.8-slim") +PY_DOCKER_IMAGES+=("3.9-slim") +PY_DOCKER_IMAGES+=("3.10-slim") +PY_DOCKER_IMAGES+=("3.11-slim") -# Install packages from sources -PACKAGES+=(".") -# PyPI package -PACKAGES+=("editorconfig-checker") +create_docker_file() { + local package="$1" -echo -e "Running tests...\n\n" + # Generate a valid Dockerfile from a template file + local dockerfile="tests/Dockerfile-$py_docker_image-$package" + cp "$DOCKERFILE_TEMPLATE" "$dockerfile" -for py_docker_image in "${PY_DOCKER_IMAGES[@]}"; do - for package in "${PACKAGES[@]}"; do - is_local="0" - if [[ "$package" == "." ]]; then - package_pp="local" - is_local="1" - elif [[ "$package" == "editorconfig-checker" ]]; then - package_pp="pypi" - else - echo "Unknown package '$package'. Valid values are '.' and 'editorconfig-checker'." - exit 1 - fi + # Replace docker image + sed -i "s/\$IMAGE/$py_docker_image/g" "$dockerfile" - echo "docker image: $py_docker_image ~ package: $package ($package_pp)" + # Replace package name + if [[ "$package" == "local" ]]; then + package="." + fi + sed -i "s/\$PACKAGE/$package/g" "$dockerfile" - # Generate a valid Dockerfile from a template file - dockerfile="tests/Dockerfile-$py_docker_image-$package_pp" - cp "$DOCKERFILE_TEMPLATE" "$dockerfile" - sed -i "s/\$IMAGE/$py_docker_image/g" "$dockerfile" - sed -i "s/\$PACKAGE/$package/g" "$dockerfile" + echo "$dockerfile" +} - echo "Building docker image based on \"$dockerfile\". It could take some time..." +build_docker_image_and_run() { + local py_docker_image="$1" + local package="$2" + local dockerfile="$3" - # Build & run - docker_image="editorconfig-checker-$py_docker_image-$package_pp:latest" - docker build -t "$docker_image" -f "$dockerfile" --no-cache --quiet . - docker run --rm "$docker_image" + # Build + local docker_image="editorconfig-checker-$py_docker_image-$package:latest" + docker build -t "$docker_image" -f "$dockerfile" --no-cache --quiet . - # Run coding style tools - if [[ "$is_local" == "1" ]]; then - docker run --rm "$docker_image" make coding-style - fi + # Run `editorconfig-checker` + docker run --rm "$docker_image" ec -version +} - # Run `editorconfig-checker` - docker run --rm "$docker_image" ec -version +main() { + echo -e "Running tests...\n\n" - # Remove the created image - docker image rm "$docker_image" &> /dev/null + for py_docker_image in "${PY_DOCKER_IMAGES[@]}"; do + for package in local editorconfig-checker; do + local dockerfile=$(create_docker_file "$package") + echo "Dockerfile created at \"$dockerfile\" (\"$py_docker_image\" image and \"$package\" package)" - echo -e "\n" + echo "Building docker image. It could take some time..." + build_docker_image_and_run "$py_docker_image" "$package" "$dockerfile" + + # docker image rm "$docker_image" &> /dev/null + + echo -e "\n" + done done -done +} + +main diff --git a/tests/Dockerfile.template b/tests/Dockerfile.template index 3e18d77..92d8138 100644 --- a/tests/Dockerfile.template +++ b/tests/Dockerfile.template @@ -6,9 +6,7 @@ LABEL maintainer="Marco M. (mmicu) " COPY . /app WORKDIR /app -RUN set -x \ - && apt-get update \ - && apt-get install -y make \ - && python -m pip install --upgrade pip \ - && pip install -r tests/requirements.txt \ +RUN apt-get update \ + && apt-get install -y make \ + && python -m pip install --upgrade pip \ && pip install --no-cache-dir $PACKAGE From 4057bb155ee5863fac2f8c96c460b6a9c171f069 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 6 Oct 2023 17:45:49 +0200 Subject: [PATCH 05/32] Add .vscode params --- .vscode/settings.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 7fe4e68..7f44661 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,6 +2,10 @@ "cSpell.ignoreWords": [ "aarch", "cmdclass", - "outfiles" - ] + "outfiles", + "pypi" + ], + "files.trimFinalNewlines": true, + "files.insertFinalNewline": true, + "files.trimTrailingWhitespace": true } From 7a7586cbbb9ecc278cfcd3a9b0e294b2be4a29c9 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 6 Oct 2023 17:47:32 +0200 Subject: [PATCH 06/32] Fix build issue --- .gitignore | 3 ++- setup.py | 14 ++++++++++---- tests/requirements.txt | 1 - 3 files changed, 12 insertions(+), 6 deletions(-) delete mode 100644 tests/requirements.txt diff --git a/.gitignore b/.gitignore index f59b051..be73e67 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -.DS_Store _*.sh _*.txt +.DS_Store +.pre-commit-config.yaml *.bak *.egg-info *.pyc diff --git a/setup.py b/setup.py index 4a2909e..9d33c3f 100644 --- a/setup.py +++ b/setup.py @@ -13,15 +13,16 @@ Once the setup is complete, the `ec` executable should be available on your machine. """ -from io import BytesIO from distutils.command.build import build as orig_build from distutils.core import Command +from io import BytesIO from os import chmod, makedirs, path, stat from platform import architecture, machine, system +from stat import S_IXGRP, S_IXOTH, S_IXUSR +from tarfile import open as tarfile_open + from setuptools import setup from setuptools.command.install import install as orig_install -from stat import S_IXUSR, S_IXGRP, S_IXOTH -from tarfile import open as tarfile_open try: # Python 3 @@ -102,7 +103,12 @@ def save_executables(data, base_dir): exe += '.exe' output_path = path.join(base_dir, exe) - makedirs(base_dir) + try: + # Python 3 + makedirs(base_dir, exists=True) + except TypeError: + # Python 2.7 + makedirs(base_dir) with open(output_path, 'wb') as fp: fp.write(data) diff --git a/tests/requirements.txt b/tests/requirements.txt deleted file mode 100644 index 3930480..0000000 --- a/tests/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -flake8 From e83a750611d26b6652a349fc1f894a4bf83eacd9 Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 7 Oct 2023 16:25:30 +0200 Subject: [PATCH 07/32] Use exist_ok instead of exist --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9d33c3f..053c8fd 100644 --- a/setup.py +++ b/setup.py @@ -105,7 +105,7 @@ def save_executables(data, base_dir): output_path = path.join(base_dir, exe) try: # Python 3 - makedirs(base_dir, exists=True) + makedirs(base_dir, exist_ok=True) except TypeError: # Python 2.7 makedirs(base_dir) From 2b74735540f79457a50369e5c17a2c35d52c3298 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 11 Oct 2023 17:55:07 +0200 Subject: [PATCH 08/32] Update core version to 2.7.2 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 053c8fd..8015d46 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ WRAPPER_VERSION = '2.7.3' -EDITORCONFIG_CHECKER_CORE_VERSION = '2.7.1' +EDITORCONFIG_CHECKER_CORE_VERSION = '2.7.2' EDITORCONFIG_CHECKER_EXE_NAME = 'ec' From 73bba99c529e16e54f135d5ca2b7171caf21a14d Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 25 Aug 2024 19:57:18 +0200 Subject: [PATCH 09/32] Update core version to v3.0.3 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 8015d46..37bc7b6 100644 --- a/setup.py +++ b/setup.py @@ -32,8 +32,8 @@ from urllib2 import urlopen -WRAPPER_VERSION = '2.7.3' -EDITORCONFIG_CHECKER_CORE_VERSION = '2.7.2' +WRAPPER_VERSION = '3.0.3' +EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.0.3' EDITORCONFIG_CHECKER_EXE_NAME = 'ec' From 5bf7d37dcd9d34e0ff242924f0fa741e503f0a05 Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 19 Jan 2025 20:13:27 +0100 Subject: [PATCH 10/32] Fix sed command options --- run-tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index 029e14e..a76053b 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -20,13 +20,13 @@ create_docker_file() { cp "$DOCKERFILE_TEMPLATE" "$dockerfile" # Replace docker image - sed -i "s/\$IMAGE/$py_docker_image/g" "$dockerfile" + sed -i '' "s/\$IMAGE/$py_docker_image/g" "$dockerfile" # Replace package name if [[ "$package" == "local" ]]; then package="." fi - sed -i "s/\$PACKAGE/$package/g" "$dockerfile" + sed -i '' "s/\$PACKAGE/$package/g" "$dockerfile" echo "$dockerfile" } From cad26a2504ed93422a7891be2798906b82d100ce Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 19 Jan 2025 20:14:04 +0100 Subject: [PATCH 11/32] Update core version to v3.1.2 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 37bc7b6..da47343 100644 --- a/setup.py +++ b/setup.py @@ -32,8 +32,8 @@ from urllib2 import urlopen -WRAPPER_VERSION = '3.0.3' -EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.0.3' +WRAPPER_VERSION = '3.1.2' +EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.1.2' EDITORCONFIG_CHECKER_EXE_NAME = 'ec' From 081e43642dc9300e1f525f05552daa75186b7494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Wed, 22 Jan 2025 08:25:13 +0100 Subject: [PATCH 12/32] fix: since v3 we no longer have the extension in the archive name --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index da47343..c29e164 100644 --- a/setup.py +++ b/setup.py @@ -58,12 +58,12 @@ def get_ec_name_by_system(): # The core, from `2.7.0`, introduces the extension in the tarball name # (e.g. `ec-windows-386.exe.tar.gz`, `ec-windows-arm.exe.tar.gz`) - _ext = '.exe' if _system == 'Windows' else '' + # In `3.1.0` the windows extension was then again dropped from the + # archive name. - return 'ec-{}-{}{}'.format( + return 'ec-{}-{}'.format( _system.lower(), _architecture, - _ext, ) return 'https://github.com/editorconfig-checker/editorconfig-checker/releases/download/{}/{}.tar.gz'.format( From 4fa584df000010a08e86abc00ee61838f93d5767 Mon Sep 17 00:00:00 2001 From: Marco Date: Mon, 27 Jan 2025 19:54:11 +0100 Subject: [PATCH 13/32] Prepare new release --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c29e164..a3572b4 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ from urllib2 import urlopen -WRAPPER_VERSION = '3.1.2' +WRAPPER_VERSION = '3.1.3' EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.1.2' EDITORCONFIG_CHECKER_EXE_NAME = 'ec' From 413d86b56e952964c4a4a16fcc3dde2f0fd0c655 Mon Sep 17 00:00:00 2001 From: Marco Date: Mon, 27 Jan 2025 20:00:35 +0100 Subject: [PATCH 14/32] Add .venv/ in .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index be73e67..0bd230e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ _*.txt TODO __pycache__/ +.venv/ bin/ build/ dist/ From 79a8b37b67e491d5f2d5f751305e12c7c5b02839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Mon, 27 Jan 2025 20:29:03 +0100 Subject: [PATCH 15/32] upgrade core to v3.2.0 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index a3572b4..0fbdf2c 100644 --- a/setup.py +++ b/setup.py @@ -32,8 +32,8 @@ from urllib2 import urlopen -WRAPPER_VERSION = '3.1.3' -EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.1.2' +WRAPPER_VERSION = '3.2.0' +EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.2.0' EDITORCONFIG_CHECKER_EXE_NAME = 'ec' From eeb06cc9fc20260df896665ab6bd78b8cf7ee70f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Sat, 29 Mar 2025 22:18:36 +0100 Subject: [PATCH 16/32] upgrade core to v3.2.1 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 0fbdf2c..2c359df 100644 --- a/setup.py +++ b/setup.py @@ -32,8 +32,8 @@ from urllib2 import urlopen -WRAPPER_VERSION = '3.2.0' -EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.2.0' +WRAPPER_VERSION = '3.2.1' +EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.2.1' EDITORCONFIG_CHECKER_EXE_NAME = 'ec' From 76bc4bf3392c821b370a40fecf256237c75e6385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Tue, 28 Jan 2025 13:22:49 +0100 Subject: [PATCH 17/32] test: switch to using a singular Dockerfile with build args this avoids the need to replace content in the Dockerfile using sed and makes it possible to run a quick test using `make quicktest` (using the defaults for the build arguments specified in the Dockerfile) --- Dockerfile | 21 +++++++++++++++++++ Makefile | 8 +++++++- run-tests.sh | 43 +++++++++++++++------------------------ tests/.gitignore | 1 - tests/Dockerfile.template | 12 ----------- 5 files changed, 44 insertions(+), 41 deletions(-) create mode 100644 Dockerfile delete mode 100644 tests/.gitignore delete mode 100644 tests/Dockerfile.template diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..14a6808 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +# Dockerfile is run by `run-tests.sh` + +# used to define the python tag +ARG IMAGE=3.13-slim + + +FROM python:$IMAGE +LABEL maintainer="Marco M. (mmicu) " + +COPY . /app +WORKDIR /app + +# used to define which python package is installed with pip: +# - a value of `.` builds the images using the docker build context - aka the revision of the package which is currently checked out +# - using a value of `editorconfig-checker` will instead pull the image from PyPI +ARG PACKAGE=. + +RUN apt-get update \ + && apt-get install -y make \ + && python -m pip install --upgrade pip \ + && pip install --no-cache-dir $PACKAGE diff --git a/Makefile b/Makefile index 4948e11..c7b8776 100644 --- a/Makefile +++ b/Makefile @@ -6,13 +6,14 @@ help: @echo " - coding-style : Run coding style tools." @echo " - publish : Publish package to PyPI." @echo " - test : Run coding style tools and tests." + @echo " - quicktest : Run coding style tools and only the test for the latest python and the current git revision." .PHONY: all all: help .PHONY: clean clean: - @rm -rf build dist editorconfig_checker.egg-info editorconfig_checker/bin tests/Dockerfile-* + @rm -rf build dist editorconfig_checker.egg-info editorconfig_checker/bin .PHONY: coding-style coding-style: @@ -26,3 +27,8 @@ publish: clean test .PHONY: test test: coding-style @bash run-tests.sh + +.PHONY: quicktest +quicktest: coding-style + docker build -t quicktest . + docker run quicktest ec -version diff --git a/run-tests.sh b/run-tests.sh index a76053b..1a03a15 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -2,8 +2,6 @@ set -e -DOCKERFILE_TEMPLATE="tests/Dockerfile.template" - PY_DOCKER_IMAGES=() PY_DOCKER_IMAGES+=("2.7.16-slim") PY_DOCKER_IMAGES+=("3.7.4-slim") @@ -12,33 +10,27 @@ PY_DOCKER_IMAGES+=("3.9-slim") PY_DOCKER_IMAGES+=("3.10-slim") PY_DOCKER_IMAGES+=("3.11-slim") -create_docker_file() { - local package="$1" - - # Generate a valid Dockerfile from a template file - local dockerfile="tests/Dockerfile-$py_docker_image-$package" - cp "$DOCKERFILE_TEMPLATE" "$dockerfile" - - # Replace docker image - sed -i '' "s/\$IMAGE/$py_docker_image/g" "$dockerfile" - - # Replace package name - if [[ "$package" == "local" ]]; then - package="." - fi - sed -i '' "s/\$PACKAGE/$package/g" "$dockerfile" - - echo "$dockerfile" -} build_docker_image_and_run() { local py_docker_image="$1" local package="$2" - local dockerfile="$3" # Build local docker_image="editorconfig-checker-$py_docker_image-$package:latest" - docker build -t "$docker_image" -f "$dockerfile" --no-cache --quiet . + + docker_package="$package" + if [[ "$package" == "local" ]]; then + docker_package="." + fi + + docker build \ + -t "$docker_image" \ + -f "Dockerfile" \ + --no-cache \ + --quiet \ + --build-arg "IMAGE=$py_docker_image" \ + --build-arg "PACKAGE=$docker_package" \ + . # Run `editorconfig-checker` docker run --rm "$docker_image" ec -version @@ -49,11 +41,8 @@ main() { for py_docker_image in "${PY_DOCKER_IMAGES[@]}"; do for package in local editorconfig-checker; do - local dockerfile=$(create_docker_file "$package") - echo "Dockerfile created at \"$dockerfile\" (\"$py_docker_image\" image and \"$package\" package)" - - echo "Building docker image. It could take some time..." - build_docker_image_and_run "$py_docker_image" "$package" "$dockerfile" + echo "Building docker image with python version $py_docker_image and $package package. It could take some time..." + build_docker_image_and_run "$py_docker_image" "$package" # docker image rm "$docker_image" &> /dev/null diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100644 index 2527e80..0000000 --- a/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -Dockerfile-* diff --git a/tests/Dockerfile.template b/tests/Dockerfile.template deleted file mode 100644 index 92d8138..0000000 --- a/tests/Dockerfile.template +++ /dev/null @@ -1,12 +0,0 @@ -# Dockerfile used as a template. Placeholders "$IMAGE" and "$PACKAGE" are replaced -# with their actual value by `run-tests.sh` -FROM python:$IMAGE -LABEL maintainer="Marco M. (mmicu) " - -COPY . /app -WORKDIR /app - -RUN apt-get update \ - && apt-get install -y make \ - && python -m pip install --upgrade pip \ - && pip install --no-cache-dir $PACKAGE From 304f2f6ad4447a6918f9a91fde6faeed16e69281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Tue, 28 Jan 2025 23:25:23 +0100 Subject: [PATCH 18/32] test: also test the latest python versions --- run-tests.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run-tests.sh b/run-tests.sh index 1a03a15..6b26fa0 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -9,6 +9,8 @@ PY_DOCKER_IMAGES+=("3.8-slim") PY_DOCKER_IMAGES+=("3.9-slim") PY_DOCKER_IMAGES+=("3.10-slim") PY_DOCKER_IMAGES+=("3.11-slim") +PY_DOCKER_IMAGES+=("3.12-slim") +PY_DOCKER_IMAGES+=("3.13-slim") build_docker_image_and_run() { From d39feeef79b8bfb3d8c874a7d810b8ae6d06a0b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Fri, 31 Jan 2025 08:52:46 +0100 Subject: [PATCH 19/32] test: allow caching the static portion This reduces the test runtime from about 5min to 3min on my machine. --- Dockerfile | 13 ++++++++----- run-tests.sh | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 14a6808..cd98c11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,13 @@ ARG IMAGE=3.13-slim -FROM python:$IMAGE +FROM python:$IMAGE AS pybase +RUN apt-get update \ + && apt-get install -y make \ + && python -m pip install --upgrade pip + +# separate the obtaining of the requirements from the actual test, so we can use build caching for the first step +FROM pybase as tester LABEL maintainer="Marco M. (mmicu) " COPY . /app @@ -15,7 +21,4 @@ WORKDIR /app # - using a value of `editorconfig-checker` will instead pull the image from PyPI ARG PACKAGE=. -RUN apt-get update \ - && apt-get install -y make \ - && python -m pip install --upgrade pip \ - && pip install --no-cache-dir $PACKAGE +RUN pip install --no-cache-dir $PACKAGE diff --git a/run-tests.sh b/run-tests.sh index 6b26fa0..54f2815 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -28,7 +28,7 @@ build_docker_image_and_run() { docker build \ -t "$docker_image" \ -f "Dockerfile" \ - --no-cache \ + --no-cache-filter tester \ --quiet \ --build-arg "IMAGE=$py_docker_image" \ --build-arg "PACKAGE=$docker_package" \ From a84754ea8acdceaf9b36cd0640b93cc7b53f866f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Fri, 31 Jan 2025 09:12:02 +0100 Subject: [PATCH 20/32] test: also turn packages into an array to allow changing it --- run-tests.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/run-tests.sh b/run-tests.sh index 54f2815..2c5f1de 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -12,6 +12,10 @@ PY_DOCKER_IMAGES+=("3.11-slim") PY_DOCKER_IMAGES+=("3.12-slim") PY_DOCKER_IMAGES+=("3.13-slim") +PY_PACKAGES=() +PY_PACKAGES+=("local") +PY_PACKAGES+=("editorconfig-checker") + build_docker_image_and_run() { local py_docker_image="$1" @@ -42,7 +46,7 @@ main() { echo -e "Running tests...\n\n" for py_docker_image in "${PY_DOCKER_IMAGES[@]}"; do - for package in local editorconfig-checker; do + for package in "${PY_PACKAGES[@]}"; do echo "Building docker image with python version $py_docker_image and $package package. It could take some time..." build_docker_image_and_run "$py_docker_image" "$package" From c5346b9def4b5b7aff339cf3bcf8b179dad6956b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Fri, 31 Jan 2025 09:26:11 +0100 Subject: [PATCH 21/32] test: allow external control of the test matrix with $TEST_PY_VERSION and $TEST_LOCAL_PKG/$TEST_PYPI_PKG --- run-tests.sh | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index 2c5f1de..7cac84e 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -3,18 +3,26 @@ set -e PY_DOCKER_IMAGES=() -PY_DOCKER_IMAGES+=("2.7.16-slim") -PY_DOCKER_IMAGES+=("3.7.4-slim") -PY_DOCKER_IMAGES+=("3.8-slim") -PY_DOCKER_IMAGES+=("3.9-slim") -PY_DOCKER_IMAGES+=("3.10-slim") -PY_DOCKER_IMAGES+=("3.11-slim") -PY_DOCKER_IMAGES+=("3.12-slim") -PY_DOCKER_IMAGES+=("3.13-slim") +if [ -n "$TEST_PY_VERSION" ]; then + PY_DOCKER_IMAGES+=("$TEST_PY_VERSION") +else + PY_DOCKER_IMAGES+=("2.7.16-slim") + PY_DOCKER_IMAGES+=("3.7.4-slim") + PY_DOCKER_IMAGES+=("3.8-slim") + PY_DOCKER_IMAGES+=("3.9-slim") + PY_DOCKER_IMAGES+=("3.10-slim") + PY_DOCKER_IMAGES+=("3.11-slim") + PY_DOCKER_IMAGES+=("3.12-slim") + PY_DOCKER_IMAGES+=("3.13-slim") +fi PY_PACKAGES=() -PY_PACKAGES+=("local") -PY_PACKAGES+=("editorconfig-checker") +if [ -z "$TEST_LOCAL_PKG" ] || [ "$TEST_LOCAL_PKG" = "true" ]; then + PY_PACKAGES+=("local") +fi +if [ -z "$TEST_PYPI_PKG" ] || [ "$TEST_PYPI_PKG" = "true" ]; then + PY_PACKAGES+=("editorconfig-checker") +fi build_docker_image_and_run() { From e7fdf4cb46bb751f4de350b6e3bcb2fcce800e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Fri, 31 Jan 2025 20:17:52 +0100 Subject: [PATCH 22/32] test: refactor to specify which image variant we want only once --- run-tests.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index 7cac84e..31b5080 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -4,16 +4,16 @@ set -e PY_DOCKER_IMAGES=() if [ -n "$TEST_PY_VERSION" ]; then - PY_DOCKER_IMAGES+=("$TEST_PY_VERSION") + PY_VERSIONS+=("$TEST_PY_VERSION") else - PY_DOCKER_IMAGES+=("2.7.16-slim") - PY_DOCKER_IMAGES+=("3.7.4-slim") - PY_DOCKER_IMAGES+=("3.8-slim") - PY_DOCKER_IMAGES+=("3.9-slim") - PY_DOCKER_IMAGES+=("3.10-slim") - PY_DOCKER_IMAGES+=("3.11-slim") - PY_DOCKER_IMAGES+=("3.12-slim") - PY_DOCKER_IMAGES+=("3.13-slim") + PY_VERSIONS+=("2.7.16") + PY_VERSIONS+=("3.7.4") + PY_VERSIONS+=("3.8") + PY_VERSIONS+=("3.9") + PY_VERSIONS+=("3.10") + PY_VERSIONS+=("3.11") + PY_VERSIONS+=("3.12") + PY_VERSIONS+=("3.13") fi PY_PACKAGES=() @@ -53,10 +53,10 @@ build_docker_image_and_run() { main() { echo -e "Running tests...\n\n" - for py_docker_image in "${PY_DOCKER_IMAGES[@]}"; do + for py_version in "${PY_VERSIONS[@]}"; do for package in "${PY_PACKAGES[@]}"; do - echo "Building docker image with python version $py_docker_image and $package package. It could take some time..." - build_docker_image_and_run "$py_docker_image" "$package" + echo "Building docker image with python version $py_version and $package package. It could take some time..." + build_docker_image_and_run "$py_version-slim" "$package" # docker image rm "$docker_image" &> /dev/null From 74be5db5e3afbb6bd2d93a9c9d401f7535538923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Fri, 31 Jan 2025 20:23:24 +0100 Subject: [PATCH 23/32] ci: build CI to ensure the local package always works this tests in two ways: - install the package locally in each major os/architecture combination supported by GitHub Actions, then run `editorconfig-checker --version` like `run-tests.sh` does - running `run-tests.sh` once in an ubuntu machines The workflow is triggered both by pushes to any of the branches and for each pull request. --- .github/workflows/ci.yaml | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..c6792e1 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,52 @@ +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +permissions: read-all + +jobs: + test-architectures: + name: test OS/arch combinations + strategy: + fail-fast: false + matrix: + os: + - 'ubuntu-24.04' + - 'ubuntu-24.04-arm' + - 'macos-13' # the last intel mac + - 'macos-15' # arm64 mac + - 'windows-2025' + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: install local package + run: | + python -m pip install . + + - name: test that editorconfig-checker works by letting it output it's version + run: | + ec --version + + + test-python-versions: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + + - name: install flake8 + run: | + python -m pip install flake8 + + - name: run testsuite verifying against all python versions + shell: bash + run: | + # only test the local package, since we assume that we only + # upload to PyPI once we are certain that the local package is fine + export TEST_LOCAL_PKG=true + export TEST_PYPI_PKG=false + + make test From 684bb409b0417f5bd18af5ba0af369b18631f3ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Sat, 1 Feb 2025 16:12:25 +0100 Subject: [PATCH 24/32] test: run against latest python patch version in each series --- run-tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index 31b5080..28a3a0d 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -6,8 +6,8 @@ PY_DOCKER_IMAGES=() if [ -n "$TEST_PY_VERSION" ]; then PY_VERSIONS+=("$TEST_PY_VERSION") else - PY_VERSIONS+=("2.7.16") - PY_VERSIONS+=("3.7.4") + PY_VERSIONS+=("2.7") + PY_VERSIONS+=("3.7") PY_VERSIONS+=("3.8") PY_VERSIONS+=("3.9") PY_VERSIONS+=("3.10") From b7973ebc565af03221d8bccab0b7eebd892e4847 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 14 Aug 2025 22:15:28 +0200 Subject: [PATCH 25/32] refactor: streamline CI configuration and Docker image build process --- .github/workflows/ci.yaml | 12 ++++++--- Dockerfile | 4 +-- Makefile | 12 ++++----- run-tests.sh | 54 +++++++++++++++++---------------------- 4 files changed, 39 insertions(+), 43 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c6792e1..76df8c2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -31,7 +31,6 @@ jobs: run: | ec --version - test-python-versions: runs-on: ubuntu-24.04 steps: @@ -44,9 +43,14 @@ jobs: - name: run testsuite verifying against all python versions shell: bash run: | - # only test the local package, since we assume that we only - # upload to PyPI once we are certain that the local package is fine + # Only test the local package, since we assume that we only + # upload to PyPI once we are certain that the local package is fine. export TEST_LOCAL_PKG=true export TEST_PYPI_PKG=false - make test + # The same commands are defined in the `Makefile` and used for local development. + # We added them here to simplify the building process of the Docker + # image that points to `python:2.7-slim`. + # For such image, `apt-get` was not working as expected. + flake8 --ignore E501 setup.py + bash run-tests.sh diff --git a/Dockerfile b/Dockerfile index cd98c11..d4f8286 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,9 +5,7 @@ ARG IMAGE=3.13-slim FROM python:$IMAGE AS pybase -RUN apt-get update \ - && apt-get install -y make \ - && python -m pip install --upgrade pip +RUN python -m pip install --upgrade pip # separate the obtaining of the requirements from the actual test, so we can use build caching for the first step FROM pybase as tester diff --git a/Makefile b/Makefile index c7b8776..c297ac5 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,8 @@ help: @echo " - clean : Remove generated files." @echo " - coding-style : Run coding style tools." @echo " - publish : Publish package to PyPI." + @echo " - quick-test : Run coding style tools and only the test for the latest python and the current git revision." @echo " - test : Run coding style tools and tests." - @echo " - quicktest : Run coding style tools and only the test for the latest python and the current git revision." .PHONY: all all: help @@ -24,11 +24,11 @@ publish: clean test @python3 setup.py sdist @twine upload dist/* +.PHONY: quick-test +quick-test: coding-style + docker build -t ec-quick-test . + docker run ec-quick-test ec -version + .PHONY: test test: coding-style @bash run-tests.sh - -.PHONY: quicktest -quicktest: coding-style - docker build -t quicktest . - docker run quicktest ec -version diff --git a/run-tests.sh b/run-tests.sh index 28a3a0d..16b382c 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -2,34 +2,10 @@ set -e -PY_DOCKER_IMAGES=() -if [ -n "$TEST_PY_VERSION" ]; then - PY_VERSIONS+=("$TEST_PY_VERSION") -else - PY_VERSIONS+=("2.7") - PY_VERSIONS+=("3.7") - PY_VERSIONS+=("3.8") - PY_VERSIONS+=("3.9") - PY_VERSIONS+=("3.10") - PY_VERSIONS+=("3.11") - PY_VERSIONS+=("3.12") - PY_VERSIONS+=("3.13") -fi - -PY_PACKAGES=() -if [ -z "$TEST_LOCAL_PKG" ] || [ "$TEST_LOCAL_PKG" = "true" ]; then - PY_PACKAGES+=("local") -fi -if [ -z "$TEST_PYPI_PKG" ] || [ "$TEST_PYPI_PKG" = "true" ]; then - PY_PACKAGES+=("editorconfig-checker") -fi - - build_docker_image_and_run() { local py_docker_image="$1" local package="$2" - # Build local docker_image="editorconfig-checker-$py_docker_image-$package:latest" docker_package="$package" @@ -46,20 +22,38 @@ build_docker_image_and_run() { --build-arg "PACKAGE=$docker_package" \ . - # Run `editorconfig-checker` docker run --rm "$docker_image" ec -version } main() { echo -e "Running tests...\n\n" - for py_version in "${PY_VERSIONS[@]}"; do - for package in "${PY_PACKAGES[@]}"; do - echo "Building docker image with python version $py_version and $package package. It could take some time..." - build_docker_image_and_run "$py_version-slim" "$package" + local py_versions=() + if [ -n "$TEST_PY_VERSION" ]; then + py_versions+=("$TEST_PY_VERSION") + else + py_versions+=("2.7") + py_versions+=("3.7") + py_versions+=("3.8") + py_versions+=("3.9") + py_versions+=("3.10") + py_versions+=("3.11") + py_versions+=("3.12") + py_versions+=("3.13") + fi - # docker image rm "$docker_image" &> /dev/null + local py_packages=() + if [ -z "$TEST_LOCAL_PKG" ] || [ "$TEST_LOCAL_PKG" = "true" ]; then + py_packages+=("local") + fi + if [ -z "$TEST_PYPI_PKG" ] || [ "$TEST_PYPI_PKG" = "true" ]; then + py_packages+=("editorconfig-checker") + fi + for py_version in "${py_versions[@]}"; do + for package in "${py_packages[@]}"; do + echo "Building docker image with Python version $py_version and $package package. It could take some time..." + build_docker_image_and_run "$py_version-slim" "$package" echo -e "\n" done done From 931d3ef0d66d12c1c08334803c19605c0f3d239b Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 14 Aug 2025 22:48:40 +0200 Subject: [PATCH 26/32] chore(release): bump core package to 3.3.0 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 2c359df..1205b98 100644 --- a/setup.py +++ b/setup.py @@ -32,8 +32,8 @@ from urllib2 import urlopen -WRAPPER_VERSION = '3.2.1' -EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.2.1' +WRAPPER_VERSION = '3.3.0' +EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.3.0' EDITORCONFIG_CHECKER_EXE_NAME = 'ec' From 8ab9de62dc45812efae2d86f0cea5ada6f18323a Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 14 Aug 2025 23:24:33 +0200 Subject: [PATCH 27/32] chore(release): bump core package to 3.4.0 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 1205b98..46762ba 100644 --- a/setup.py +++ b/setup.py @@ -32,8 +32,8 @@ from urllib2 import urlopen -WRAPPER_VERSION = '3.3.0' -EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.3.0' +WRAPPER_VERSION = '3.4.0' +EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.4.0' EDITORCONFIG_CHECKER_EXE_NAME = 'ec' From f9066017a0789dd51fa058889d02725fb8cc1d69 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 29 Oct 2025 22:32:10 +0100 Subject: [PATCH 28/32] chore(release): bump core package to 3.4.1 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 46762ba..263006c 100644 --- a/setup.py +++ b/setup.py @@ -32,8 +32,8 @@ from urllib2 import urlopen -WRAPPER_VERSION = '3.4.0' -EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.4.0' +WRAPPER_VERSION = '3.4.1' +EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.4.1' EDITORCONFIG_CHECKER_EXE_NAME = 'ec' From 80942e82555dbb6410aeb6ec6deaab108009fd82 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 29 Oct 2025 22:54:58 +0100 Subject: [PATCH 29/32] Normalize package name --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 1a0a484..3b1027e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [metadata] -name = editorconfig-checker +name = editorconfig_checker description = Python wrapper around invoking editorconfig-checker (https://github.com/editorconfig-checker/editorconfig-checker) long_description = file: README.md long_description_content_type = text/markdown From bf8475b6b0afb2cf3516aad1289cc824b697f2da Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 22 Nov 2025 15:08:11 +0100 Subject: [PATCH 30/32] chore(release): bump core package to 3.5.0 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 263006c..6831f67 100644 --- a/setup.py +++ b/setup.py @@ -32,8 +32,8 @@ from urllib2 import urlopen -WRAPPER_VERSION = '3.4.1' -EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.4.1' +WRAPPER_VERSION = '3.5.0' +EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.5.0' EDITORCONFIG_CHECKER_EXE_NAME = 'ec' From bd03425a7c5e6fc55e979ecc15b20feabf4faa6d Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 30 Nov 2025 15:31:16 +0100 Subject: [PATCH 31/32] chore(release): bump core package to 3.6.0 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 6831f67..4eb7d9b 100644 --- a/setup.py +++ b/setup.py @@ -32,8 +32,8 @@ from urllib2 import urlopen -WRAPPER_VERSION = '3.5.0' -EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.5.0' +WRAPPER_VERSION = '3.6.0' +EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.6.0' EDITORCONFIG_CHECKER_EXE_NAME = 'ec' From 89b1648b73988876a30882c8c61be677e30532e1 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 4 Mar 2026 21:00:08 +0100 Subject: [PATCH 32/32] chore(release): bump core package to 3.6.1 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 4eb7d9b..0524c1b 100644 --- a/setup.py +++ b/setup.py @@ -32,8 +32,8 @@ from urllib2 import urlopen -WRAPPER_VERSION = '3.6.0' -EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.6.0' +WRAPPER_VERSION = '3.6.1' +EDITORCONFIG_CHECKER_CORE_VERSION = 'v3.6.1' EDITORCONFIG_CHECKER_EXE_NAME = 'ec'