Skip to content

Commit 6db2f2b

Browse files
authored
Merge pull request #737 from nextcloud/jtr/docs-readme-dev-update
docs: fix and expand Development/Making Changes section in README
2 parents 53b0900 + 3881caf commit 6db2f2b

File tree

1 file changed

+59
-14
lines changed

1 file changed

+59
-14
lines changed

README.md

Lines changed: 59 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,29 +192,47 @@ Described here are both relevant aspects of the Updater itself as well as surrou
192192

193193
### Updater components
194194

195-
For each mode the Updater supports - Web and command line - a dedicated artifact is generated. However, all common operations are located in shared code. Since the code is not shared in all cases at runtime, it's important to understand where various changes should go during development so that they end up in the appropriate places at build or check-in time.
195+
For each mode the Updater supports - Web and command line - a dedicated artifact is generated. However, all common operations are located
196+
in shared code. Since the code is not shared in all cases at runtime, it's important to understand where various changes should go during
197+
development so that they end up in the appropriate places at build or check-in time.
196198

197199
Changes should be made to the following places in the `updater` repo:
198200

199201
* Shared aspects of the Updater:
200-
- `/Makefile`
201-
- `make updater.phar`
202-
- `make index.php`
203202
- `/lib/LogException.php`
204-
- `/lib/RecursiveDirectoryIteratorWithoutDate.php`
205203
- `/lib/UpdateException.php`
206204
- `/lib/Updater.php` <-- core of the Updater functionality for both Web and CLI modes is implemented here
207205
* Aspects specific to the Web Updater:
208206
- `/index.web.php`
209-
- `/Makefile`
210-
- `make index.php`
211207
* Aspects specific to the CLI Updater:
212208
- `/updater.php`
213209
- `/buildVersionFile.php`
214210
- `/lib/CommandApplication.php`
215211
- `/lib/UpdateCommand.php`
216-
- `/Makefile`
217-
- `make updater.phar`
212+
213+
#### Build system (`/Makefile`)
214+
215+
The Makefile contains targets for both modes. The relevant targets are:
216+
217+
* `make updater.phar` — builds the CLI Updater artifact
218+
* `make index.php` — builds the Web Updater artifact
219+
* `make check-same-code-base` — verifies that `index.php` contains the same shared library code as the individual files in `/lib/` <-- checked by CI
220+
221+
**How `index.php` is built:** The Web Updater runs as a single self-contained PHP file. `make index.php` produces it by *concatenating* `index.web.php`
222+
with the shared library files (`UpdateException.php`, `LogException.php`, `Updater.php`), stripping `namespace`/`use` statements and duplicate PHP
223+
opening tags via `awk`/`grep`. This means that after changing any shared `/lib/*.php` file or `index.web.php`, you must re-run `make index.php` and
224+
check in the resulting `/index.php`.
225+
226+
**How `updater.phar` is built:** `make updater.phar` generates a transient `/lib/Version.php` (via `buildVersionFile.php`), runs `composer dump-autoload`,
227+
then uses [box](https://github.com/box-project/box) (configured in `/box.json`) to package `/updater.php`, `/lib/*.php`, and `/vendor/*.php` into the
228+
phar. The transient `Version.php` is deleted after the build. After changing any CLI-specific or shared file, you must re-run `make updater.phar` and
229+
check in the resulting `/updater.phar`.
230+
231+
#### Build configuration files
232+
233+
* `/box.json` — Configures which files are packaged into `updater.phar` (the `lib/` directory, vendor PHP files, with `updater.php` as the main entry point)
234+
* `/composer.json` / `/composer.lock` — Manage PHP dependencies; the CLI Updater bootstraps via `vendor/autoload.php`
235+
* `/vendor/` — Checked in to the repo (used at runtime by the CLI Updater and during the phar build)
218236

219237
#### Server components
220238

@@ -245,9 +263,29 @@ Keep in mind that for the update/upgrade process there are some additional compo
245263

246264
Install box: https://github.com/box-project/box/blob/main/doc/installation.md#composer
247265

266+
#### Composer
267+
268+
A working `composer` install is required both for dependency management and for building. See "Testing" below for version requirements.
269+
248270
#### Tests
249271

250-
If you want to run the tests locally, you'll need to run them in an environment that has Nextcloud's required PHP modules installed. The various test scenarios are all available via the `make test*` (see Makefile for specifics).
272+
If you want to run the tests locally, you'll need to run them in an environment that has Nextcloud's required PHP modules installed.
273+
Tests use [Behat](https://docs.behat.org/) (a BDD framework); feature files live under `tests/features/`. Test data (gitignored) is
274+
generated under `tests/data/`.
275+
276+
The available test targets are:
277+
278+
| Target | Description |
279+
|---|---|
280+
| `make test` | Runs all Behat feature tests |
281+
| `make test-cli` | Runs only the CLI updater tests (`features/cli.feature`) |
282+
| `make test-stable26` | Tests update path for stable26 |
283+
| `make test-stable27` | Tests update path for stable27 |
284+
| `make test-stable28` | Tests update path for stable28 |
285+
| `make test-master` | Tests update path for master |
286+
| `make test-user.ini` | Tests `.user.ini` handling (`features/user.ini.feature`) |
287+
| `make check-same-code-base` | Verifies `/index.php` is in sync with `/lib/*.php` + `/index.web.php` |
288+
| `make build-and-local-test` | Builds the phar then runs a local updater smoke test |
251289

252290
### Build artifacts / What to check in
253291

@@ -269,16 +307,23 @@ Plus whatever has been changed in the implementation in:
269307

270308
#### Transient
271309

272-
Used during the build process but not checked in:
310+
Used during the build process but not checked in (gitignored):
273311

274312
* Specific to the CLI Updater:
275-
- `/lib/Version.php`
313+
- `/lib/Version.php` — auto-generated by `buildVersionFile.php`, deleted after `make updater.phar` completes
276314

277315
### Testing
278316

279-
#### Check same code base test keeps failing
317+
#### `check-same-code-base` test keeps failing
318+
319+
This test (`make check-same-code-base`) runs `tests/checkSameCodeBase.php`, which verifies that the contents of each shared library file in `/lib/`
320+
(excluding CLI-only files `CommandApplication.php` and `UpdateCommand.php`) are present verbatim inside the built `/index.php`. If it fails, it
321+
usually means:
280322

281-
If it keeps failing on your PR, confirm your local version of `composer` is the same version in-use in the workflow runner. You can check the details of the test run and find the version currently being used (and therefore required locally) under "Setup Tools". (Hint: distro versions are typically too outdated. Remove that version and see https://getcomposer.org/download/ to install your own version).
323+
1. **You changed a file in `/lib/` but didn't rebuild `index.php`.** Run `make index.php` and commit the result.
324+
2. **Your local `composer` version differs from CI.** Confirm your local version of `composer` is the same version in-use in the workflow runner.
325+
You can check the details of the test run and find the version currently being used (and therefore required locally) under "Setup Tools". (Hint:
326+
distro versions are typically too outdated. Remove that version and see https://getcomposer.org/download/ to install your own version).
282327

283328
#### CI
284329

0 commit comments

Comments
 (0)