Skip to content

Commit 26c3229

Browse files
committed
try to run ci in docker
1 parent b0e4cd7 commit 26c3229

File tree

4 files changed

+67
-62
lines changed

4 files changed

+67
-62
lines changed

.github/workflows/tests.yml

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ jobs:
3939

4040
steps:
4141
- uses: actions/checkout@v4
42+
# submodules: recursive
43+
# fetch-depth: 0
4244

4345
- name: checkout submodules
4446
shell: bash
@@ -47,48 +49,50 @@ jobs:
4749
git submodule init
4850
git submodule status | cut -d" " -f2 | xargs -n1 -P0 git submodule update
4951
50-
- name: setup Git
51-
shell: bash
52+
- name: warm up docker image
5253
run: |
53-
git config --global user.email "[email protected]"
54-
git config --global user.name "Elspeth See-Eye"
55-
git config --global init.defaultBranch main
56-
57-
- name: Set up Python 3.12
58-
uses: actions/setup-python@v5
59-
with:
60-
python-version: 3.12
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 "echo hello world"
6159
62-
- name: Install apt stuff and other dependencies
63-
shell: bash
60+
- name: uv pip install --upgrade systemwide
6461
run: |
65-
sudo add-apt-repository ppa:mozillateam/ppa
66-
sudo apt update -y
67-
sudo apt install -y \
68-
asciidoctor \
69-
language-pack-en \
70-
ruby-coderay \
71-
ruby-pygments.rb \
72-
firefox-esr \
73-
tree \
74-
locales
75-
sudo locale-gen en_GB.UTF-8
76-
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 "uv pip install --system --upgrade ."
7767
78-
- name: Install Python requirements.txt globally
79-
shell: bash
68+
- name: uv create virtualenv in mounted /app folder at .venv
8069
run: |
81-
uv pip install --system .
70+
docker run --rm \
71+
--mount type=volume,source=rootmount,target=/root \
72+
--mount type=bind,source=./,target=/app \
73+
-t hjwp/obeythetestinggoat-book-tester:latest \
74+
bash -c "uv venv && uv pip install --upgrade ."
8275
83-
- name: Install Python requirements.txt into virtualenv
84-
shell: bash
76+
- name: git mark dirs safe (due to volume mount perms issue)
8577
run: |
86-
make .venv/bin
87-
88-
- name: Run chapter test
89-
shell: bash
78+
docker run --rm \
79+
--mount type=volume,source=rootmount,target=/root \
80+
--mount type=bind,source=./,target=/app \
81+
-t hjwp/obeythetestinggoat-book-tester:latest \
82+
bash -c "git config --global --add safe.directory '*'"
83+
docker run --rm \
84+
--mount type=volume,source=rootmount,target=/root \
85+
--mount type=bind,source=./,target=/app \
86+
-t hjwp/obeythetestinggoat-book-tester:latest \
87+
bash -c "cat ~/.gitconfig"
88+
89+
- name: run chapter tests
9090
run: |
91-
make ${{ matrix.test_chapter }}
91+
docker run --rm \
92+
--mount type=volume,source=rootmount,target=/root \
93+
--mount type=bind,source=./,target=/app \
94+
-t hjwp/obeythetestinggoat-book-tester:latest \
95+
bash -c "make ${{ matrix.test_chapter }}"
9296
9397
- name: Save tempdir path to an env var
9498
if: always()

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
@@ -172,3 +172,7 @@ unit-test: chapter_01.html $(VENV)/bin
172172
clean:
173173
rm -rf $(TMPDIR)
174174
rm -v $(HTML_PAGES)
175+
176+
.PHONY: docker-build
177+
docker-build:
178+
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)