Skip to content

Commit 5e4e797

Browse files
junlandernisv
authored andcommitted
🔨 Improve Docker local tests support (MarlinFirmware#25583)
1 parent 1aa2b6f commit 5e4e797

File tree

6 files changed

+66
-66
lines changed

6 files changed

+66
-66
lines changed

.gitignore

+17-25
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,11 @@ mczip.h
2828
*.gen
2929
*.sublime-workspace
3030

31-
#
3231
# OS
33-
#
3432
applet/
3533
.DS_Store
3634

37-
#
38-
# Misc
39-
#
40-
*~
41-
*.orig
42-
*.rej
43-
*.bak
44-
*.idea
45-
*.i
46-
*.ii
47-
*.swp
48-
tags
49-
50-
#
51-
# C++
52-
#
53-
# Compiled Object files
35+
# Compiled C++ Object files
5436
*.slo
5537
*.lo
5638
*.o
@@ -81,10 +63,7 @@ tags
8163
*.out
8264
*.app
8365

84-
#
85-
# C
86-
#
87-
# Object files
66+
# Compiled C Object files
8867
*.o
8968
*.ko
9069
*.obj
@@ -144,13 +123,13 @@ vc-fileutils.settings
144123
.vscode/*
145124
!.vscode/extensions.json
146125

147-
#Simulation
126+
# Simulation files
148127
imgui.ini
149128
eeprom.dat
150129
spi_flash.bin
151130
fs.img
152131

153-
#cmake
132+
# CMake
154133
CMakeLists.txt
155134
src/CMakeLists.txt
156135
CMakeListsPrivate.txt
@@ -171,3 +150,16 @@ __pycache__
171150

172151
# IOLogger logs
173152
*_log.csv
153+
154+
# Misc.
155+
*~
156+
*.orig
157+
*.rej
158+
*.bak
159+
*.idea
160+
*.i
161+
*.ii
162+
*.swp
163+
tags
164+
*.logs
165+
*.bak

Makefile

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
SCRIPTS_DIR := buildroot/share/scripts
2+
CONTAINER_RT_BIN := docker
3+
CONTAINER_RT_OPTS := --rm -v $(PWD):/code -v platformio-cache:/root/.platformio
4+
CONTAINER_IMAGE := marlin-dev
5+
16
help:
27
@echo "Tasks for local development:"
38
@echo "* tests-single-ci: Run a single test from inside the CI"
49
@echo "* tests-single-local: Run a single test locally"
5-
@echo "* tests-single-local-docker: Run a single test locally, using docker-compose"
10+
@echo "* tests-single-local-docker: Run a single test locally, using docker"
611
@echo "* tests-all-local: Run all tests locally"
7-
@echo "* tests-all-local-docker: Run all tests locally, using docker-compose"
8-
@echo "* setup-local-docker: Setup local docker-compose"
12+
@echo "* tests-all-local-docker: Run all tests locally, using docker"
13+
@echo "* setup-local-docker: Build the local docker image"
914
@echo ""
1015
@echo "Options for testing:"
1116
@echo " TEST_TARGET Set when running tests-single-*, to select the"
@@ -34,19 +39,21 @@ tests-single-local:
3439

3540
tests-single-local-docker:
3641
@if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local-docker" ; return 1; fi
37-
docker-compose run --rm marlin $(MAKE) tests-single-local TEST_TARGET=$(TEST_TARGET) VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD) ONLY_TEST="$(ONLY_TEST)"
42+
@if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
43+
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) $(MAKE) tests-single-local TEST_TARGET=$(TEST_TARGET) VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD) ONLY_TEST="$(ONLY_TEST)"
3844
.PHONY: tests-single-local-docker
3945

4046
tests-all-local:
4147
export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \
4248
&& export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \
43-
&& for TEST_TARGET in $$(./get_test_targets.py) ; do echo "Running tests for $$TEST_TARGET" ; run_tests . $$TEST_TARGET ; done
49+
&& for TEST_TARGET in $$($(SCRIPTS_DIR)/get_test_targets.py) ; do echo "Running tests for $$TEST_TARGET" ; run_tests . $$TEST_TARGET ; done
4450
.PHONY: tests-all-local
4551

4652
tests-all-local-docker:
47-
docker-compose run --rm marlin $(MAKE) tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD)
53+
@if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
54+
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) $(MAKE) tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD)
4855
.PHONY: tests-all-local-docker
4956

5057
setup-local-docker:
51-
docker-compose build
58+
$(CONTAINER_RT_BIN) build -t $(CONTAINER_IMAGE) -f docker/Dockerfile .
5259
.PHONY: setup-local-docker
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
"""
3+
Extract the builds used in Github CI, so that we can run them locally
4+
"""
5+
import yaml
6+
7+
# Set the yaml file to parse
8+
yaml_file = '.github/workflows/test-builds.yml'
9+
10+
# Parse the yaml file, and load it into a dictionary (github_configuration)
11+
with open(yaml_file) as f:
12+
github_configuration = yaml.safe_load(f)
13+
14+
# Print out the test platforms
15+
print(' '.join(github_configuration['jobs']['test_builds']['strategy']['matrix']['test-platform']))

docker-compose.yml

-19
This file was deleted.

docker/Dockerfile

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
FROM python:3.9.0-buster
22

3-
RUN pip install -U platformio
3+
# Disable warnings about not having a TTY
4+
ARG DEBIAN_FRONTEND=noninteractive
5+
6+
# Disable debconf warnings
7+
ARG DEBCONF_NOWARNINGS="yes"
8+
9+
# Upgrade pip
10+
RUN pip install --upgrade pip
11+
12+
# Install platformio toolchain / framework and pyyaml
13+
RUN pip install -U platformio PyYaml
14+
15+
# Upgrade platformio using development version / branch
416
RUN pio upgrade --dev
5-
# To get the test platforms
6-
RUN pip install PyYaml
17+
18+
# Set working directory
19+
WORKDIR /code
20+
21+
# Set volumes / mount points that we are using
22+
VOLUME /code /root/.platformio
23+
724
#ENV PATH /code/buildroot/bin/:/code/buildroot/tests/:${PATH}

get_test_targets.py

-12
This file was deleted.

0 commit comments

Comments
 (0)