Skip to content

Commit b7973eb

Browse files
committed
refactor: streamline CI configuration and Docker image build process
1 parent 684bb40 commit b7973eb

File tree

4 files changed

+39
-43
lines changed

4 files changed

+39
-43
lines changed

.github/workflows/ci.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ jobs:
3131
run: |
3232
ec --version
3333
34-
3534
test-python-versions:
3635
runs-on: ubuntu-24.04
3736
steps:
@@ -44,9 +43,14 @@ jobs:
4443
- name: run testsuite verifying against all python versions
4544
shell: bash
4645
run: |
47-
# only test the local package, since we assume that we only
48-
# upload to PyPI once we are certain that the local package is fine
46+
# Only test the local package, since we assume that we only
47+
# upload to PyPI once we are certain that the local package is fine.
4948
export TEST_LOCAL_PKG=true
5049
export TEST_PYPI_PKG=false
5150
52-
make test
51+
# The same commands are defined in the `Makefile` and used for local development.
52+
# We added them here to simplify the building process of the Docker
53+
# image that points to `python:2.7-slim`.
54+
# For such image, `apt-get` was not working as expected.
55+
flake8 --ignore E501 setup.py
56+
bash run-tests.sh

Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ ARG IMAGE=3.13-slim
55

66

77
FROM python:$IMAGE AS pybase
8-
RUN apt-get update \
9-
&& apt-get install -y make \
10-
&& python -m pip install --upgrade pip
8+
RUN python -m pip install --upgrade pip
119

1210
# separate the obtaining of the requirements from the actual test, so we can use build caching for the first step
1311
FROM pybase as tester

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ help:
55
@echo " - clean : Remove generated files."
66
@echo " - coding-style : Run coding style tools."
77
@echo " - publish : Publish package to PyPI."
8+
@echo " - quick-test : Run coding style tools and only the test for the latest python and the current git revision."
89
@echo " - test : Run coding style tools and tests."
9-
@echo " - quicktest : Run coding style tools and only the test for the latest python and the current git revision."
1010

1111
.PHONY: all
1212
all: help
@@ -24,11 +24,11 @@ publish: clean test
2424
@python3 setup.py sdist
2525
@twine upload dist/*
2626

27+
.PHONY: quick-test
28+
quick-test: coding-style
29+
docker build -t ec-quick-test .
30+
docker run ec-quick-test ec -version
31+
2732
.PHONY: test
2833
test: coding-style
2934
@bash run-tests.sh
30-
31-
.PHONY: quicktest
32-
quicktest: coding-style
33-
docker build -t quicktest .
34-
docker run quicktest ec -version

run-tests.sh

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,10 @@
22

33
set -e
44

5-
PY_DOCKER_IMAGES=()
6-
if [ -n "$TEST_PY_VERSION" ]; then
7-
PY_VERSIONS+=("$TEST_PY_VERSION")
8-
else
9-
PY_VERSIONS+=("2.7")
10-
PY_VERSIONS+=("3.7")
11-
PY_VERSIONS+=("3.8")
12-
PY_VERSIONS+=("3.9")
13-
PY_VERSIONS+=("3.10")
14-
PY_VERSIONS+=("3.11")
15-
PY_VERSIONS+=("3.12")
16-
PY_VERSIONS+=("3.13")
17-
fi
18-
19-
PY_PACKAGES=()
20-
if [ -z "$TEST_LOCAL_PKG" ] || [ "$TEST_LOCAL_PKG" = "true" ]; then
21-
PY_PACKAGES+=("local")
22-
fi
23-
if [ -z "$TEST_PYPI_PKG" ] || [ "$TEST_PYPI_PKG" = "true" ]; then
24-
PY_PACKAGES+=("editorconfig-checker")
25-
fi
26-
27-
285
build_docker_image_and_run() {
296
local py_docker_image="$1"
307
local package="$2"
318

32-
# Build
339
local docker_image="editorconfig-checker-$py_docker_image-$package:latest"
3410

3511
docker_package="$package"
@@ -46,20 +22,38 @@ build_docker_image_and_run() {
4622
--build-arg "PACKAGE=$docker_package" \
4723
.
4824

49-
# Run `editorconfig-checker`
5025
docker run --rm "$docker_image" ec -version
5126
}
5227

5328
main() {
5429
echo -e "Running tests...\n\n"
5530

56-
for py_version in "${PY_VERSIONS[@]}"; do
57-
for package in "${PY_PACKAGES[@]}"; do
58-
echo "Building docker image with python version $py_version and $package package. It could take some time..."
59-
build_docker_image_and_run "$py_version-slim" "$package"
31+
local py_versions=()
32+
if [ -n "$TEST_PY_VERSION" ]; then
33+
py_versions+=("$TEST_PY_VERSION")
34+
else
35+
py_versions+=("2.7")
36+
py_versions+=("3.7")
37+
py_versions+=("3.8")
38+
py_versions+=("3.9")
39+
py_versions+=("3.10")
40+
py_versions+=("3.11")
41+
py_versions+=("3.12")
42+
py_versions+=("3.13")
43+
fi
6044

61-
# docker image rm "$docker_image" &> /dev/null
45+
local py_packages=()
46+
if [ -z "$TEST_LOCAL_PKG" ] || [ "$TEST_LOCAL_PKG" = "true" ]; then
47+
py_packages+=("local")
48+
fi
49+
if [ -z "$TEST_PYPI_PKG" ] || [ "$TEST_PYPI_PKG" = "true" ]; then
50+
py_packages+=("editorconfig-checker")
51+
fi
6252

53+
for py_version in "${py_versions[@]}"; do
54+
for package in "${py_packages[@]}"; do
55+
echo "Building docker image with Python version $py_version and $package package. It could take some time..."
56+
build_docker_image_and_run "$py_version-slim" "$package"
6357
echo -e "\n"
6458
done
6559
done

0 commit comments

Comments
 (0)