chore: speed up the PR CI image build and job setup (#8478)
This commit is contained in:
1 parent
4275723746
commit
158098f465
9 files changed
+81
-47
No files matched your search
@@ -11,12 +11,18 @@ on:
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
build-frontend:
|
||||
name: Build frontend
|
||||
build-package:
|
||||
name: Build frontend and wheel
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout 🛎
|
||||
- name: Install Task
|
||||
uses: arduino/setup-task@v2
|
||||
with:
|
||||
version: 3.x
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
@@ -40,30 +46,6 @@ jobs:
|
||||
run: pnpm generate
|
||||
working-directory: "frontend"
|
||||
|
||||
- name: Archive built frontend
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: frontend-dist
|
||||
path: frontend/dist
|
||||
retention-days: 5
|
||||
|
||||
build-package:
|
||||
name: Build Python package
|
||||
needs: build-frontend
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Install Task
|
||||
uses: arduino/setup-task@v2
|
||||
with:
|
||||
version: 3.x
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
|
||||
- name: Set up python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
@@ -72,17 +54,16 @@ jobs:
|
||||
- name: Install uv
|
||||
run: pip install uv
|
||||
|
||||
- name: Retrieve built frontend
|
||||
uses: actions/download-artifact@v6
|
||||
with:
|
||||
name: frontend-dist
|
||||
path: mealie/frontend
|
||||
- name: Copy the frontend into the package
|
||||
run: |
|
||||
rm -rf mealie/frontend
|
||||
cp -a frontend/dist mealie/frontend
|
||||
|
||||
- name: Override __init__.py
|
||||
run: |
|
||||
echo "__version__ = \"${{ inputs.tag }}\"" > ./mealie/__init__.py
|
||||
|
||||
- name: Build package and requirements.txt
|
||||
- name: Build package and requirements files
|
||||
env:
|
||||
SKIP_PACKAGE_DEPS: true
|
||||
run: |
|
||||
|
||||
@@ -19,6 +19,15 @@ jobs:
|
||||
node-version: 24
|
||||
cache: "pnpm"
|
||||
cache-dependency-path: "**/pnpm-lock.yaml"
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
# This install takes about 50 seconds and needs nothing the image build
|
||||
# produces, so the two run at the same time.
|
||||
- name: Start Playwright browser install
|
||||
run: |
|
||||
rm -f /tmp/playwright-install.status
|
||||
nohup bash -c 'pnpm playwright install --with-deps; echo $? > /tmp/playwright-install.status' \
|
||||
> /tmp/playwright-install.log 2>&1 &
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Retrieve Python package
|
||||
@@ -39,12 +48,24 @@ jobs:
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
- name: Deploy E2E Test Environment
|
||||
run: docker compose up -d
|
||||
run: |
|
||||
docker compose up -d --wait
|
||||
# The mock OIDC server has no shell, so compose cannot health check it.
|
||||
for _ in $(seq 1 60); do
|
||||
curl -fsS http://localhost:8080/default/.well-known/openid-configuration > /dev/null && exit 0
|
||||
sleep 1
|
||||
done
|
||||
echo "the mock OIDC server did not answer"
|
||||
exit 1
|
||||
working-directory: ./tests/e2e/docker
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
- name: Install Playwright Browsers
|
||||
run: pnpm playwright install --with-deps
|
||||
- name: Finish Playwright browser install
|
||||
run: |
|
||||
for _ in $(seq 1 300); do
|
||||
[ -f /tmp/playwright-install.status ] && break
|
||||
sleep 1
|
||||
done
|
||||
cat /tmp/playwright-install.log
|
||||
exit "$(cat /tmp/playwright-install.status 2>/dev/null || echo 1)"
|
||||
- name: Check test environment
|
||||
run: docker ps
|
||||
- name: Run Playwright tests
|
||||
|
||||
@@ -13,9 +13,17 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Retrieve Python package
|
||||
uses: actions/download-artifact@v6
|
||||
with:
|
||||
name: backend-dist
|
||||
path: dist
|
||||
|
||||
# Scan the wheel that the release uses, and not a second copy that this
|
||||
# job builds.
|
||||
- name: Build Dockerfile
|
||||
run: |
|
||||
docker build -t mealie --file=./docker/Dockerfile .
|
||||
docker build -t mealie --file=./docker/Dockerfile --build-context packages=dist .
|
||||
|
||||
- name: Run Trivy vulnerability scanner
|
||||
uses: aquasecurity/trivy-action@master
|
||||
|
||||
@@ -32,6 +32,7 @@ jobs:
|
||||
container-scanning:
|
||||
name: "Trivy Container Scanning"
|
||||
if: github.event_name == 'pull_request'
|
||||
needs: build-package
|
||||
uses: ./.github/workflows/partial-trivy-container-scanning.yml
|
||||
|
||||
code-ql:
|
||||
|
||||
@@ -32,11 +32,12 @@ jobs:
|
||||
POSTGRES_USER: mealie
|
||||
POSTGRES_PASSWORD: mealie
|
||||
POSTGRES_DB: mealie
|
||||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
||||
options: --health-cmd pg_isready --health-interval 2s --health-timeout 5s --health-retries 15
|
||||
ports:
|
||||
- 5432:5432
|
||||
ldap:
|
||||
image: rroemhild/test-openldap
|
||||
options: --health-interval 2s --health-timeout 5s --health-retries 15
|
||||
ports:
|
||||
- 10389:10389
|
||||
- 10636:10636
|
||||
|
||||
+3
-1
@@ -156,7 +156,8 @@ tasks:
|
||||
internal: true
|
||||
cmds:
|
||||
- uv export --no-editable --no-emit-project --extra pgsql --format
|
||||
requirements-txt --output-file dist/requirements.txt
|
||||
requirements-txt --output-file dist/dependencies.txt
|
||||
- cp dist/dependencies.txt dist/requirements.txt
|
||||
# Include mealie in the requirements, hashing the package that was just built to ensure it's the one installed
|
||||
- echo "mealie[pgsql]=={{.MEALIE_VERSION}} \\" >> dist/requirements.txt
|
||||
- pip hash dist/mealie-{{.MEALIE_VERSION}}-py3-none-any.whl | tail -n1 |
|
||||
@@ -174,6 +175,7 @@ tasks:
|
||||
- dist/mealie-*.whl
|
||||
- dist/mealie-*.tar.gz
|
||||
generates:
|
||||
- dist/dependencies.txt
|
||||
- dist/requirements.txt
|
||||
|
||||
py:package:deps-parallel:
|
||||
|
||||
+11
-5
@@ -65,10 +65,11 @@ COPY --from=frontend-builder /frontend/dist ./mealie/frontend
|
||||
# Build the source and binary package
|
||||
RUN uv build --out-dir dist
|
||||
|
||||
# Create the requirements file, which is used to install the built package and
|
||||
# its pinned dependencies later. mealie is included to ensure the built one is
|
||||
# what's installed.
|
||||
RUN uv export --no-editable --no-emit-project --extra pgsql --format requirements-txt --output-file dist/requirements.txt \
|
||||
# dependencies.txt changes only when uv.lock does, so the venv build can cache
|
||||
# the install. requirements.txt adds the wheel that was just built, so an
|
||||
# install from it gets that exact one.
|
||||
RUN uv export --no-editable --no-emit-project --extra pgsql --format requirements-txt --output-file dist/dependencies.txt \
|
||||
&& cp dist/dependencies.txt dist/requirements.txt \
|
||||
&& MEALIE_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])") \
|
||||
&& echo "mealie[pgsql]==${MEALIE_VERSION} \\" >> dist/requirements.txt \
|
||||
&& pip hash dist/mealie-${MEALIE_VERSION}-py3-none-any.whl | tail -n1 | tr -d '\n' >> dist/requirements.txt \
|
||||
@@ -102,10 +103,15 @@ RUN python3 -m venv --upgrade-deps $VENV_PATH
|
||||
# Install the wheel and all dependencies into the venv
|
||||
FROM venv-builder-base AS venv-builder
|
||||
|
||||
# Cache key is dependencies.txt, so a mealie-only commit reuses this layer.
|
||||
COPY --from=packages dependencies.txt /dist/dependencies.txt
|
||||
RUN . $VENV_PATH/bin/activate \
|
||||
&& pip install --require-hashes -r /dist/dependencies.txt
|
||||
|
||||
# Copy built package (wheel) and its dependency requirements
|
||||
COPY --from=packages * /dist/
|
||||
|
||||
# Install the wheel with exact versions of dependencies into the venv
|
||||
# The dependencies are already in place, so pip only installs mealie itself.
|
||||
RUN . $VENV_PATH/bin/activate \
|
||||
&& pip install --require-hashes -r /dist/requirements.txt --find-links /dist
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ popd
|
||||
rm -r mealie/frontend
|
||||
cp -a frontend/dist mealie/frontend
|
||||
uv build --out-dir dist
|
||||
uv export --no-editable --no-emit-project --extra pgsql --format requirements-txt --output-file dist/requirements.txt
|
||||
uv export --no-editable --no-emit-project --extra pgsql --format requirements-txt --output-file dist/dependencies.txt
|
||||
cp dist/dependencies.txt dist/requirements.txt
|
||||
MEALIE_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
|
||||
echo "mealie[pgsql]==${MEALIE_VERSION} \\" >> dist/requirements.txt
|
||||
pip hash dist/mealie-${MEALIE_VERSION}-py3-none-any.whl | tail -n1 | tr -d '\n' >> dist/requirements.txt
|
||||
@@ -21,6 +22,8 @@ echo " \\" >> dist/requirements.txt
|
||||
pip hash dist/mealie-${MEALIE_VERSION}.tar.gz | tail -n1 >> dist/requirements.txt
|
||||
```
|
||||
|
||||
This writes two files. `dist/dependencies.txt` pins the dependencies alone, and `dist/requirements.txt` adds the package that was just built. The Docker image installs from both, so that a change to mealie's own code does not rebuild the dependencies.
|
||||
|
||||
The Python package can be installed with all of its dependencies pinned to the versions tested by the developers with:
|
||||
```sh
|
||||
pip3 install -r dist/requirements.txt --find-links dist
|
||||
|
||||
@@ -9,6 +9,11 @@ services:
|
||||
|
||||
ldap:
|
||||
image: rroemhild/test-openldap
|
||||
# shorten the image's default 30s health check interval
|
||||
healthcheck:
|
||||
interval: 2s
|
||||
timeout: 5s
|
||||
retries: 15
|
||||
ports:
|
||||
- 10389:10389
|
||||
|
||||
@@ -22,6 +27,12 @@ services:
|
||||
additional_contexts:
|
||||
packages: ../../../dist
|
||||
restart: always
|
||||
# shorten the image's default 30s health check interval
|
||||
healthcheck:
|
||||
interval: 2s
|
||||
timeout: 5s
|
||||
retries: 60
|
||||
start_period: 5s
|
||||
volumes:
|
||||
- mealie-data:/app/data/
|
||||
network_mode: host
|
||||
|
||||
Reference in new issue
Block a user