diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8a7841786..5dce3e5a0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,6 +45,8 @@ jobs: steps: - uses: actions/checkout@v4 + # submodules: recursive + # fetch-depth: 0 - name: checkout submodules shell: bash @@ -53,46 +55,44 @@ jobs: git submodule init git submodule status | cut -d" " -f2 | xargs -n1 -P0 git submodule update - - name: setup Git - shell: bash + - name: warm up docker image run: | - git config --global user.email "elspeth@example.com" - git config --global user.name "Elspeth See-Eye" - git config --global init.defaultBranch main - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: 3.12 - - - name: Install apt stuff and other dependencies - shell: bash + docker run --rm \ + --mount type=volume,source=rootmount,target=/root \ + --mount type=bind,source=./,target=/app \ + -t hjwp/obeythetestinggoat-book-tester:latest \ + bash -c "echo hello world" + + - name: uv create virtualenv in mounted /app folder at .venv and install latest/upgraded deps + # todo, replace with make docker-venv? run: | - sudo add-apt-repository ppa:mozillateam/ppa - sudo apt update -y - sudo apt install -y \ - asciidoctor \ - language-pack-en \ - ruby-coderay \ - ruby-pygments.rb \ - firefox-esr \ - tree - pip install uv + docker run --rm \ + --mount type=volume,source=rootmount,target=/root \ + --mount type=bind,source=./,target=/app \ + -t hjwp/obeythetestinggoat-book-tester:latest \ + bash -c "uv venv && uv pip install --upgrade ." - - name: Install Python requirements.txt globally - shell: bash + - name: git mark dirs safe (due to volume mount perms issue) run: | - uv pip install --system . - - - name: Install Python requirements.txt into virtualenv - shell: bash - run: | - make .venv/bin - - - name: Run chapter test - shell: bash + docker run --rm \ + --mount type=volume,source=rootmount,target=/root \ + --mount type=bind,source=./,target=/app \ + -t hjwp/obeythetestinggoat-book-tester:latest \ + bash -c "git config --global --add safe.directory '*'" + docker run --rm \ + --mount type=volume,source=rootmount,target=/root \ + --mount type=bind,source=./,target=/app \ + -t hjwp/obeythetestinggoat-book-tester:latest \ + bash -c "cat ~/.gitconfig" + + - name: run chapter tests + # todo, replace with make docker_${{ matrix.test_chapter }} ? run: | - make ${{ matrix.test_chapter }} + docker run --rm \ + --mount type=volume,source=rootmount,target=/root \ + --mount type=bind,source=./,target=/app \ + -t hjwp/obeythetestinggoat-book-tester:latest \ + bash -c "make ${{ matrix.test_chapter }}" - name: Save tempdir path to an env var if: always() diff --git a/Dockerfile b/Dockerfile index e2644cf28..be543d924 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,40 +1,32 @@ FROM python:slim +# -- Dockerfile is intended mainly for use in CI -- + +RUN apt-get update -y && \ + apt-get install -y --no-install-recommends \ + asciidoctor \ + curl \ + firefox-esr \ + git \ + make \ + ruby-pygments.rb \ + tree \ + wget \ + && rm -rf /var/lib/apt/lists/* -# -- WIP -- -# this dockerfile is a work in progress, -# the vague intention is to use it for CI. - -# RUN add-apt-repository ppa:mozillateam/ppa && \ -RUN apt-get update -y - -RUN apt-get install -y \ - git \ - asciidoctor \ - # language-pack-en \ - ruby-pygments.rb \ - firefox-esr \ - tree \ - locales - -RUN apt-get install -y \ - make \ - curl - -RUN locale-gen en_GB.UTF-8 -# RUN pip install uv ADD --chmod=755 https://astral.sh/uv/install.sh /install.sh -RUN /install.sh && rm /install.sh -RUN ln -s $HOME/.cargo/bin/uv /usr/bin/uv +RUN /install.sh && rm /install.sh && \ + ln -s $HOME/.cargo/bin/uv /usr/bin/uv RUN git config --global user.email "elspeth@example.com" && \ git config --global user.name "Elspeth See-Eye" && \ git config --global init.defaultBranch main WORKDIR /app -RUN uv venv .venv - COPY pyproject.toml pyproject.toml -RUN uv pip install . +# install python deps into a venv at /app/.venv, +# as a form of cache. even when we mount over it with --volume, +# the content is copied in. +RUN uv venv .venv && uv pip install . CMD bash diff --git a/Makefile b/Makefile index a833923cd..9e9033507 100644 --- a/Makefile +++ b/Makefile @@ -167,3 +167,30 @@ unit-test: chapter_01.html $(VENV)/bin clean: rm -rf $(TMPDIR) rm -v $(HTML_PAGES) + +.PHONY: docker-build +docker-build: + docker build --platform=linux/amd64 -t hjwp/obeythetestinggoat-book-tester:latest . + +.PHONY: docker-push +docker-push: + docker push hjwp/obeythetestinggoat-book-tester:latest + +.PHONY: docker-venv +docker-venv: + docker run --rm \ + --mount type=volume,source=rootmount,target=/root \ + --mount type=bind,source=./,target=/app \ + --mount type=volume,source=venvmount,target=/app/.venv \ + -t hjwp/obeythetestinggoat-book-tester:latest \ + bash -c "uv venv .venv && uv pip install --upgrade ." + +.PHONY: docker-test_% +docker-test_%: docker-venv %.html $(TMPDIR) + docker run --rm \ + --mount type=volume,source=rootmount,target=/root \ + --mount type=bind,source=./,target=/app \ + --mount type=volume,source=venvmount,target=/app/.venv \ + -t hjwp/obeythetestinggoat-book-tester:latest \ + bash -c "make $(subst docker-,,$@)" + diff --git a/chapter_01.asciidoc b/chapter_01.asciidoc index 72e8c01f8..9c658d38e 100644 --- a/chapter_01.asciidoc +++ b/chapter_01.asciidoc @@ -298,7 +298,7 @@ $ *ls* db.sqlite3 functional_tests.py manage.py superlists $ *git init .* -Initialised empty Git repository in ...goat-book/.git/ +Initialized empty Git repository in ...goat-book/.git/ ---- // CSANAD: maybe we could mention that Git also provides hints about the default branch name diff --git a/chapter_08_prettification.asciidoc b/chapter_08_prettification.asciidoc index 1d82e1ab1..b75e2a953 100644 --- a/chapter_08_prettification.asciidoc +++ b/chapter_08_prettification.asciidoc @@ -1062,7 +1062,7 @@ static/ ├── [...] └── bootstrap.min.js.map -16 directories, 169 files +17 directories, 169 files ---- `collectstatic` has also picked up all the CSS for the admin site. diff --git a/chapter_16_javascript.asciidoc b/chapter_16_javascript.asciidoc index e6296e392..8892dfd3f 100644 --- a/chapter_16_javascript.asciidoc +++ b/chapter_16_javascript.asciidoc @@ -425,7 +425,7 @@ src/lists/static/tests ├── jasmine.js └── jasmine_favicon.png -2 directories, 9 files +3 directories, 9 files ---- We need to go edit the _SpecRunner.html_ file diff --git a/chapter_CI.asciidoc b/chapter_CI.asciidoc index c8357283a..9103f9988 100644 --- a/chapter_CI.asciidoc +++ b/chapter_CI.asciidoc @@ -676,7 +676,7 @@ lists/static/tests/ ├── runner.js └── tests.html -0 directories, 4 files +1 directories, 4 files ---- Let's try it out: diff --git a/tests/update_source_repo.py b/tests/update_source_repo.py index 09d92c3ab..2b4bf5780 100755 --- a/tests/update_source_repo.py +++ b/tests/update_source_repo.py @@ -49,7 +49,7 @@ def update_sources_for_chapter(chapter, previous_chapter=None): # make sure branch for previous chapter is available to start tests subprocess.check_output(["git", "checkout", previous_chapter], cwd=source_dir) subprocess.check_output( - ["git", "reset", "--hard", "{}/{}".format(REMOTE, previous_chapter)], + ["git", "reset", "--hard", f"{REMOTE}/{previous_chapter}"], cwd=source_dir, )