Skip to content

Commit dd861b7

Browse files
committed
try to run ci in docker
1 parent 88a2682 commit dd861b7

File tree

4 files changed

+66
-61
lines changed

4 files changed

+66
-61
lines changed

.github/workflows/tests.yml

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ jobs:
3535

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

3941
- name: checkout submodules
4042
shell: bash
@@ -43,48 +45,50 @@ jobs:
4345
git submodule init
4446
git submodule status | cut -d" " -f2 | xargs -n1 -P0 git submodule update
4547
46-
- name: setup Git
47-
shell: bash
48+
- name: warm up docker image
4849
run: |
49-
git config --global user.email "[email protected]"
50-
git config --global user.name "Elspeth See-Eye"
51-
git config --global init.defaultBranch main
52-
53-
- name: Set up Python 3.12
54-
uses: actions/setup-python@v5
55-
with:
56-
python-version: 3.12
50+
docker run --rm \
51+
--mount type=volume,source=rootmount,target=/root \
52+
--mount type=bind,source=./,target=/app \
53+
-t hjwp/obeythetestinggoat-book-tester:latest \
54+
bash -c "echo hello world"
5755
58-
- name: Install apt stuff and other dependencies
59-
shell: bash
56+
- name: uv pip install --upgrade systemwide
6057
run: |
61-
sudo add-apt-repository ppa:mozillateam/ppa
62-
sudo apt update -y
63-
sudo apt install -y \
64-
asciidoctor \
65-
language-pack-en \
66-
ruby-coderay \
67-
ruby-pygments.rb \
68-
firefox-esr \
69-
tree \
70-
locales
71-
sudo locale-gen en_GB.UTF-8
72-
pip install uv
58+
docker run --rm \
59+
--mount type=volume,source=rootmount,target=/root \
60+
--mount type=bind,source=./,target=/app \
61+
-t hjwp/obeythetestinggoat-book-tester:latest \
62+
bash -c "uv pip install --system --upgrade ."
7363
74-
- name: Install Python requirements.txt globally
75-
shell: bash
64+
- name: uv create virtualenv in mounted /app folder at .venv
7665
run: |
77-
uv pip install --system .
66+
docker run --rm \
67+
--mount type=volume,source=rootmount,target=/root \
68+
--mount type=bind,source=./,target=/app \
69+
-t hjwp/obeythetestinggoat-book-tester:latest \
70+
bash -c "uv venv && uv pip install --upgrade ."
7871
79-
- name: Install Python requirements.txt into virtualenv
80-
shell: bash
72+
- name: git mark dirs safe (due to volume mount perms issue)
8173
run: |
82-
make .venv/bin
74+
docker run --rm \
75+
--mount type=volume,source=rootmount,target=/root \
76+
--mount type=bind,source=./,target=/app \
77+
-t hjwp/obeythetestinggoat-book-tester:latest \
78+
bash -c "git config --global --add safe.directory '*'"
79+
docker run --rm \
80+
--mount type=volume,source=rootmount,target=/root \
81+
--mount type=bind,source=./,target=/app \
82+
-t hjwp/obeythetestinggoat-book-tester:latest \
83+
bash -c "cat ~/.gitconfig"
8384
84-
- name: Run chapter test
85-
shell: bash
85+
- name: run chapter tests
8686
run: |
87-
make ${{ matrix.test_chapter }}
87+
docker run --rm \
88+
--mount type=volume,source=rootmount,target=/root \
89+
--mount type=bind,source=./,target=/app \
90+
-t hjwp/obeythetestinggoat-book-tester:latest \
91+
bash -c "make ${{ matrix.test_chapter }}"
8892
8993
- name: Archive the built html files
9094
uses: actions/upload-artifact@v4

Dockerfile

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,37 @@
11
FROM python:slim
2+
# -- Dockerfile is intended mainly for use in CI --
3+
4+
RUN apt-get update -y && \
5+
apt-get install -y \
6+
asciidoctor \
7+
curl \
8+
firefox-esr \
9+
git \
10+
locales \
11+
make \
12+
ruby-pygments.rb \
13+
tree \
14+
wget \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
ENV LC_ALL=en_GB.UTF-8 LANG=en_GB.UTF8 LANGUAGE=en_GB:en
18+
RUN echo "en_GB.UTF-8 UTF-8" > /etc/locale.gen
19+
RUN locale-gen
220

3-
# -- WIP --
4-
# this dockerfile is a work in progress,
5-
# the vague intention is to use it for CI.
6-
7-
# RUN add-apt-repository ppa:mozillateam/ppa && \
8-
RUN apt-get update -y
9-
10-
RUN apt-get install -y \
11-
git \
12-
asciidoctor \
13-
# language-pack-en \
14-
ruby-pygments.rb \
15-
firefox-esr \
16-
tree \
17-
locales
18-
19-
RUN apt-get install -y \
20-
make \
21-
curl
22-
23-
RUN locale-gen en_GB.UTF-8
24-
# RUN pip install uv
2521
ADD --chmod=755 https://astral.sh/uv/install.sh /install.sh
26-
RUN /install.sh && rm /install.sh
27-
RUN ln -s $HOME/.cargo/bin/uv /usr/bin/uv
22+
RUN /install.sh && rm /install.sh && \
23+
ln -s $HOME/.cargo/bin/uv /usr/bin/uv
2824

2925
RUN git config --global user.email "[email protected]" && \
3026
git config --global user.name "Elspeth See-Eye" && \
3127
git config --global init.defaultBranch main
3228

3329
WORKDIR /app
34-
RUN uv venv .venv
35-
3630
COPY pyproject.toml pyproject.toml
37-
RUN uv pip install .
3831

32+
# install python deps systemwide with uv
33+
ENV PIP_CACHE_DIR=/var/cache/pip
34+
35+
RUN uv pip install --system .
3936

4037
CMD bash

Makefile

Lines changed: 4 additions & 0 deletions
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:latest .

tests/update_source_repo.py

Lines changed: 1 addition & 1 deletion
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)