Skip to content

Commit 2f9cb04

Browse files
committed
ci: ran pull request tests on the itkdev image directly
The container ran as `deploy` (uid 1000) while the CI checkout belongs to the runner's uid, so composer could not create `vendor`. The compose user now comes from COMPOSE_USER, which the workflow sets to the checkout owner; the image carries a `runner` user at that uid, so it still has a writable home. Only `bin/create-release` needs the rsync the Dockerfile adds, so tests and linting run on itkdev/php8.3-fpm directly and no longer build an image. The built image moved to a `php-release` service, used by the release workflow alone.
1 parent 9337943 commit 2f9cb04

6 files changed

Lines changed: 37 additions & 17 deletions

File tree

‎.github/workflows/pr.yml‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ jobs:
2121
- name: Checkout
2222
uses: actions/checkout@v7
2323

24-
# Tests run in the project's own compose stack, so the PHP version comes
25-
# from the Dockerfile rather than being repeated here.
26-
- name: Build the php image
27-
run: docker compose build php
24+
# The checkout belongs to the runner's uid, so the container has to write
25+
# to the bind mount as that uid rather than as the image's `deploy` user.
26+
- name: Run the container as the checkout owner
27+
run: echo "COMPOSE_USER=$(id -u):$(id -g)" >> "$GITHUB_ENV"
2828

29+
# Tests run in the project's own compose stack, so the PHP version comes
30+
# from compose.yml rather than being repeated here.
2931
- name: Install dependencies
30-
run: docker compose run --rm --no-deps php composer install --no-interaction --prefer-dist --no-progress
32+
run: docker compose run --rm --no-deps phpfpm composer install --no-interaction --prefer-dist --no-progress
3133

3234
- name: Run tests
33-
run: docker compose run --rm --no-deps php vendor/bin/phpunit
35+
run: docker compose run --rm --no-deps phpfpm vendor/bin/phpunit

‎.github/workflows/release.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
release:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v7
1818

1919
- name: Build and create release
2020
env:
@@ -34,7 +34,7 @@ jobs:
3434
release_name="release-${tag_name}"
3535
fi
3636
37-
docker compose run --user root --rm php bin/create-release "$tag_name"
37+
docker compose run --user root --rm php-release bin/create-release "$tag_name"
3838
3939
# Delete release if it already exists.
4040
gh release view "$release_name" > /dev/null 2>&1 && gh release delete "$release_name" --yes

‎Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM itkdev/php8.3-fpm:latest
22

33
USER root
44

5-
# Add rsync
5+
# Add rsync, which `bin/create-release` needs and the base image does not carry.
66
RUN apt-get update && apt-get --yes install rsync
77

88
# Clean up

‎README.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ curl https://leantime.local.itkdev.dk/apidata/api/deleted
6565

6666
## Development
6767

68-
The plugin has no long-running stack, so everything runs in a one-off container
69-
built from the local `Dockerfile`. Install [Task](https://taskfile.dev), then:
68+
The plugin has no long-running stack, so everything runs in a one-off
69+
`itkdev/php8.3-fpm` container. Install [Task](https://taskfile.dev), then:
7070

7171
```shell
7272
task setup
@@ -76,6 +76,10 @@ task lint
7676

7777
Run `task --list-all` to see the remaining commands.
7878

79+
The `Dockerfile` exists only for releases: `bin/create-release` needs `rsync`,
80+
which the base image does not carry. It backs the `php-release` compose service
81+
and is not used for tests or linting.
82+
7983
Leantime core is not a Composer dependency of this plugin, so the development
8084
dependencies stand in for it. `illuminate/database` and `nesbot/carbon` are
8185
pinned to the exact versions the targeted Leantime release locks, so the tests

‎Taskfile.yml‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Run `task` (or `task --list-all`) to see all available commands.
33
#
44
# This plugin has no long-running stack, so everything runs in a one-off
5-
# container built from the local Dockerfile (itkdev/php8.3-fpm).
5+
# itkdev/php8.3-fpm container.
66

77
version: "3"
88

@@ -20,14 +20,14 @@ tasks:
2020
# -------------------------------------------------------------- Wrappers ---
2121

2222
compose:
23-
desc: "Run a docker compose command. Example: task compose -- build php."
23+
desc: "Run a docker compose command. Example: task compose -- config."
2424
cmds:
2525
- "{{ .DOCKER_COMPOSE }} {{ .CLI_ARGS }}"
2626

2727
php:
2828
desc: "Run a command in a one-off php container. Example: task php -- php --version."
2929
cmds:
30-
- task compose -- run --rm --no-deps php {{ .CLI_ARGS }}
30+
- task compose -- run --rm --no-deps phpfpm {{ .CLI_ARGS }}
3131
silent: true
3232

3333
composer:
@@ -39,9 +39,8 @@ tasks:
3939
# ------------------------------------------------------------ Lifecycle ---
4040

4141
setup:
42-
desc: Build the php image and install dev dependencies.
42+
desc: Install dev dependencies.
4343
cmds:
44-
- task compose -- build php
4544
- task composer -- install
4645

4746
# ------------------------------------------------------------ PHP tests ---

‎compose.yml‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
services:
2-
php:
2+
# Tests, linting and composer run straight on the itkdev image — nothing in
3+
# that path needs anything added to it.
4+
phpfpm:
5+
image: itkdev/php8.3-fpm:latest
6+
working_dir: /app
7+
# `deploy` is right locally, where Docker Desktop masks the ownership of the
8+
# bind mount. On a Linux CI runner the checkout belongs to the runner's own
9+
# uid, so CI sets COMPOSE_USER to it — otherwise composer cannot create
10+
# `vendor`. The image carries a `runner` user at uid 1001, so the overridden
11+
# uid still resolves to a writable home.
12+
user: ${COMPOSE_USER:-deploy}
13+
volumes:
14+
- .:/app
15+
16+
# Only `bin/create-release` needs the built image, for the rsync it adds.
17+
php-release:
318
build: .
419
working_dir: /app
520
volumes:

0 commit comments

Comments
 (0)