Skip to content

Commit 5e843d0

Browse files
committed
try to run ci in docker
1 parent 739f2ef commit 5e843d0

File tree

4 files changed

+86
-58
lines changed

4 files changed

+86
-58
lines changed

.github/workflows/tests.yml

+71-49
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
pull_request:
99

1010
jobs:
11-
chapter-tests:
11+
chapter_tests:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
fail-fast: false
@@ -17,73 +17,95 @@ jobs:
1717
test_chapter_01,
1818
test_chapter_02_unittest,
1919
test_chapter_03_unit_test_first_view,
20-
test_chapter_04_philosophy_and_refactoring,
21-
test_chapter_05_post_and_database,
22-
test_chapter_06_explicit_waits_1,
23-
test_chapter_07_working_incrementally,
24-
test_chapter_08_prettification,
25-
# test_chapter_09_docker,
26-
# test_chapter_10_production_readiness,
27-
# test_chapter_11_ansible,
28-
test_chapter_12_organising_test_files,
29-
test_chapter_13_database_layer_validation,
30-
test_chapter_14_simple_form,
31-
# test_chapter_15_advanced_forms,
32-
test_chapter_16_javascript,
20+
# test_chapter_04_philosophy_and_refactoring,
21+
# test_chapter_05_post_and_database,
22+
# test_chapter_06_explicit_waits_1,
23+
# test_chapter_07_working_incrementally,
24+
# test_chapter_08_prettification,
25+
# # test_chapter_09_docker,
26+
# # test_chapter_10_production_readiness,
27+
# # test_chapter_11_ansible,
28+
# test_chapter_12_organising_test_files,
29+
# test_chapter_13_database_layer_validation,
30+
# test_chapter_14_simple_form,
31+
# # test_chapter_15_advanced_forms,
32+
# test_chapter_16_javascript,
3333
unit-test
3434
]
3535

3636
steps:
3737
- uses: actions/checkout@v4
38+
# submodules: recursive
39+
# fetch-depth: 0
3840

3941
- name: checkout submodules
4042
shell: bash
4143
run: |
4244
sed -i '[email protected]:_https://github.com/_' .gitmodules
4345
git submodule update --init --recursive
4446
45-
- name: setup Git
46-
shell: bash
47+
- name: pip install --upgrade to upgrade deps, system+venv
4748
run: |
48-
git config --global user.email "[email protected]"
49-
git config --global user.name "Elspeth See-Eye"
50-
git config --global init.defaultBranch main
51-
52-
- name: Set up Python 3.12
53-
uses: actions/setup-python@v5
54-
with:
55-
python-version: 3.12
49+
docker run --rm \
50+
--mount type=volume,source=rootmount,target=/root \
51+
--mount type=bind,source=./,target=/app \
52+
-t hjwp/obeythetestinggoat-book-tester:latest \
53+
bash -c "uv pip install --system --upgrade ."
54+
docker run --rm \
55+
--mount type=volume,source=rootmount,target=/root \
56+
--mount type=bind,source=./,target=/app \
57+
-t hjwp/obeythetestinggoat-book-tester:latest \
58+
bash -c "uv pip install --upgrade ."
5659
57-
- name: Install apt stuff and other dependencies
58-
shell: bash
60+
- name: git mark dirs safe (due to volume mount perms issue)
5961
run: |
60-
sudo add-apt-repository ppa:mozillateam/ppa
61-
sudo apt update -y
62-
sudo apt install -y \
63-
asciidoctor \
64-
language-pack-en \
65-
ruby-coderay \
66-
ruby-pygments.rb \
67-
firefox-esr \
68-
tree \
69-
locales
70-
sudo locale-gen en_GB.UTF-8
71-
pip install uv
62+
docker run --rm \
63+
--mount type=volume,source=rootmount,target=/root \
64+
--mount type=bind,source=./,target=/app \
65+
-t hjwp/obeythetestinggoat-book-tester:latest \
66+
bash -c "git config --global --add safe.directory '*'"
67+
docker run --rm \
68+
--mount type=volume,source=rootmount,target=/root \
69+
--mount type=bind,source=./,target=/app \
70+
-t hjwp/obeythetestinggoat-book-tester:latest \
71+
bash -c "cat ~/.gitconfig"
7272
73-
- name: Install Python requirements.txt globally
74-
shell: bash
75-
run: |
76-
uv pip install --system .
73+
# - name: fetch submodule branches
74+
# run: |
75+
# docker run --rm \
76+
# --mount type=volume,source=rootmount,target=/root \
77+
# --mount type=bind,source=./,target=/app \
78+
# -t hjwp/obeythetestinggoat-book-tester:latest \
79+
# git submodule foreach 'git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"'
80+
# docker run --rm \
81+
# --mount type=volume,source=rootmount,target=/root \
82+
# --mount type=bind,source=./,target=/app \
83+
# -t hjwp/obeythetestinggoat-book-tester:latest \
84+
# bash -c 'git submodule status | cut -d" " -f3 | xargs -P0 -I% bash -c "cd % && git fetch"'
7785

78-
- name: Install Python requirements.txt into virtualenv
79-
shell: bash
80-
run: |
81-
make .venv/bin
86+
# - name: check submodule branches
87+
# run: |
88+
# docker run --rm \
89+
# --mount type=volume,source=rootmount,target=/root \
90+
# --mount type=bind,source=./,target=/app \
91+
# -t hjwp/obeythetestinggoat-book-tester:latest \
92+
# bash -c "cd /app/source/chapter_01/superlists && git status && git branch -a"
8293

83-
- name: Run chapter test
84-
shell: bash
94+
# - name: test chapter 1
95+
# run: |
96+
# docker run --rm \
97+
# --mount type=volume,source=rootmount,target=/root \
98+
# --mount type=bind,source=./,target=/app \
99+
# -t hjwp/obeythetestinggoat-book-tester:latest \
100+
# bash -c "make test_chapter_01"
101+
102+
- name: run chapter tests
85103
run: |
86-
make ${{ matrix.test_chapter }}
104+
docker run --rm \
105+
--mount type=volume,source=rootmount,target=/root \
106+
--mount type=bind,source=./,target=/app \
107+
-t hjwp/obeythetestinggoat-book-tester:latest \
108+
bash -c "make ${{ matrix.test_chapter }}"
87109
88110
- name: Archive the built html files
89111
uses: actions/upload-artifact@v4

Dockerfile

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
FROM python:slim
22

3-
# -- WIP --
4-
# this dockerfile is a work in progress,
5-
# the vague intention is to use it for CI.
3+
# -- Dockerfile is mainly for use in CI --
64

7-
# RUN add-apt-repository ppa:mozillateam/ppa && \
85
RUN apt-get update -y
96

107
RUN apt-get install -y \
118
git \
129
asciidoctor \
13-
# language-pack-en \
1410
ruby-pygments.rb \
1511
firefox-esr \
1612
tree \
@@ -20,8 +16,10 @@ RUN apt-get install -y \
2016
make \
2117
curl
2218

23-
RUN locale-gen en_GB.UTF-8
24-
# RUN pip install uv
19+
RUN echo "en_GB.UTF-8 UTF-8" > /etc/locale.gen
20+
ENV LC_ALL=en_GB.UTF-8 LANG=en_GB.UTF8 LANGUAGE=en_GB:en
21+
RUN locale-gen
22+
2523
ADD --chmod=755 https://astral.sh/uv/install.sh /install.sh
2624
RUN /install.sh && rm /install.sh
2725
RUN ln -s $HOME/.cargo/bin/uv /usr/bin/uv
@@ -31,10 +29,14 @@ RUN git config --global user.email "[email protected]" && \
3129
git config --global init.defaultBranch main
3230

3331
WORKDIR /app
34-
RUN uv venv .venv
32+
RUN uv venv /venv
33+
ENV VIRTUAL_ENV=/venv
34+
ENV VENV=/venv
3535

3636
COPY pyproject.toml pyproject.toml
3737
RUN uv pip install .
3838

39+
ENV PATH="/venv/bin:${PATH}"
40+
3941

4042
CMD bash

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,7 @@ unit-test: chapter_01.html $(VENV)/bin
170170
clean:
171171
rm -rf $(TMPDIR)
172172
rm -v $(HTML_PAGES)
173+
174+
.PHONY: docker-build
175+
docker-build:
176+
docker build --platform=linux/amd64 -t hjwp/obeythetestinggoat-book-tester:v2 .

tests/update_source_repo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def update_sources_for_chapter(chapter, previous_chapter=None):
4848
# make sure branch for previous chapter is available to start tests
4949
subprocess.check_output(["git", "checkout", previous_chapter], cwd=source_dir)
5050
subprocess.check_output(
51-
["git", "reset", "--hard", "{}/{}".format(REMOTE, previous_chapter)],
51+
["git", "reset", "--hard", f"{REMOTE}/{previous_chapter}"],
5252
cwd=source_dir,
5353
)
5454

0 commit comments

Comments
 (0)