Skip to content

Commit a907256

Browse files
authored
Merge pull request #16 from tcmal/main
Fix race condition in github actions (and speed it up), make document version more obvious in landing page
2 parents ef7bece + dbb28f2 commit a907256

File tree

7 files changed

+63
-53
lines changed

7 files changed

+63
-53
lines changed

.github/workflows/build-container.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,49 @@ env:
66
REGISTRY: ghcr.io
77
IMAGE_NAME: ${{ github.repository }}
88
jobs:
9+
docker-rebuild:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
17+
- uses: dorny/paths-filter@v3
18+
id: filter
19+
with:
20+
filters: |
21+
docker-rebuild:
22+
- '.github/workflows/**'
23+
- 'generator/**'
24+
25+
- name: Log in to the Container registry
26+
if: steps.filter.outputs.docker-rebuild == 'true'
27+
uses: docker/login-action@v3.4.0
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Extract metadata (tags, labels) for Docker
34+
if: steps.filter.outputs.docker-rebuild == 'true'
35+
id: meta
36+
uses: docker/metadata-action@v5.7.0
37+
with:
38+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
39+
40+
- name: Build and push
41+
if: steps.filter.outputs.docker-rebuild == 'true'
42+
uses: docker/build-push-action@v6
43+
with:
44+
context: "generator"
45+
push: true
46+
tags: ${{ steps.meta.outputs.tags }}
47+
labels: ${{ steps.meta.outputs.labels }}
48+
949
build:
1050
runs-on: ubuntu-latest
51+
needs: docker-rebuild
1152
steps:
1253
- uses: actions/checkout@v2
1354
with:

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ The training materials are generated from the markdown files in this repo, which
2020

2121
To preview your built changes locally, run `./scripts/open.sh` or ``./scripts/generate.sh` from the root of the repo. This requires docker to be working - if this is a problem consider using `shell.ehlab.uk`. You can also add a case insensitive filter to the end of the command to speed things up, ie `./scripts/generate.sh workshop`
2222

23-
If you're adding a new tool, run `./scripts/new-tool.sh <tool name> <tool location>`, ie `./scripts/new-tool.sh "CNC Mill" "Workshop"`
23+
If you're adding a new tool, run `./scripts/new-tool.sh <tool name> <tool location>`, ie `./scripts/new-tool.sh "CNC Mill" "Workshop"`.
2424

25-
If you want to mess with the code that does the generation, see [`generator/README.md`](./generator/README.md)
25+
If you want to mess with the code that does the generation, see [`generator/README.md`](./generator/README.md).
26+
27+
For more advice on what needs written, and how to write it, see [the `tooldocs`](https://wiki.ehlab.uk/tooldocs) wiki page.
2628

2729
### Common pitfalls
2830

generator/Dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
FROM python:3.12
22

3-
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
43
ENV DEBIAN_FRONTEND=noninteractive
5-
RUN apt update && apt install -y texlive-latex-base texlive-latex-extra texlive-fonts-extra
64

75
WORKDIR /app
86

7+
# LaTeX
8+
RUN apt update && apt install -y perl wget
9+
RUN wget -qO- "https://yihui.org/tinytex/install-bin-unix.sh" | sh
10+
ENV PATH="$PATH:/root/.TinyTeX/bin/x86_64-linux"
11+
RUN tlmgr install enumitem lastpage ltablex colortbl fancyhdr titlesec inter fontaxes ly1 textgreek cbfonts-fd
12+
13+
# Python dependencies
14+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
915
RUN --mount=type=cache,target=/root/.cache/uv \
1016
--mount=type=bind,source=uv.lock,target=uv.lock \
1117
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
1218
uv sync --locked --no-install-project
1319

20+
# Our app
1421
ADD training_generator /app/training_generator
1522
ADD templates /app/templates
1623
ADD assets /app/assets

generator/Dockerfile.dev

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM python:3.12
1+
FROM ghcr.io/edinburghhacklab/hacklab-training:main
22

3-
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
4-
ENV DEBIAN_FRONTEND=noninteractive
53
RUN wget -qO - 'https://proget.makedeb.org/debian-feeds/prebuilt-mpr.pub' | gpg --dearmor | tee /usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg 1> /dev/null && \
64
. /etc/os-release && \
75
echo "deb [arch=all,$(dpkg --print-architecture) signed-by=/usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg] https://proget.makedeb.org prebuilt-mpr $VERSION_CODENAME" | tee /etc/apt/sources.list.d/prebuilt-mpr.list
6+
RUN apt-get update && apt-get install -y just sudo
87

9-
RUN apt update && apt install -y texlive-latex-base texlive-latex-extra just texlive-fonts-extra
8+
RUN chmod 777 /root/.TinyTeX && chmod 711 /root
109
RUN mkdir -p /home/dev && chmod 777 /home/dev
10+
ENTRYPOINT /bin/bash

generator/Justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
run *FLAGS:
2-
uv run ./main.py {{ FLAGS }}
2+
uv run ./training_generator/main.py {{ FLAGS }}
33

44
lint:
55
uv run ruff check
@@ -11,7 +11,7 @@ fmt:
1111
build:
1212
docker build . -t ghcr.io/edinburghhacklab/hacklab-training:main -f Dockerfile
1313

14-
build-devcontainer:
14+
build-devcontainer: build
1515
docker build . -t hacklab-training-generator-dev -f Dockerfile.dev
1616

1717
devcontainer:

generator/templates/training-site.j2.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
}
1111
footer { text-align: center; padding: 1rem; }
1212
h3 { font-size: 1.5rem; padding: 0.2rem; border-bottom: 1px solid black; display: block; }
13-
h4 { margin: 0.1rem; font-size: 1.3rem; }
14-
h4 a, h4 a:visited, h4 a:hover { color: inherit !important; text-decoration: none; font-size: 0.5rem; }
13+
h4 { display: block; margin: 0.1rem; font-size: 1.3rem; }
14+
h4 a, h4 a:visited, h4 a:hover { color: inherit !important; text-decoration: none; font-size: 0.8rem; float: right; }
1515
li { margin: 0.5rem; }
1616
a { text-decoration: none; color: #0d47a1; }
1717
a:visited { color: #0d47a1; }
@@ -43,7 +43,7 @@ <h1>Edinburgh Hacklab Training Docs</h1>
4343
<h{{depth}}>
4444
{{ key }}
4545
{% if value.files %}
46-
<a aria-role="icon" aria-label="version info" href="https://github.com/edinburghhacklab/hacklab-training/commit/{{ value.version }}" title="Version: {{ value.version }} - {{ value.commit_date }}">&#9432;</a>
46+
<a href="https://github.com/edinburghhacklab/hacklab-training/commit/{{ value.version }}">Version: {{ value.version }} - {{ value.commit_date }}</a>
4747
{% endif %}
4848
</h{{depth}}>
4949

0 commit comments

Comments
 (0)