You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+59-14Lines changed: 59 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -192,29 +192,47 @@ Described here are both relevant aspects of the Updater itself as well as surrou
192
192
193
193
### Updater components
194
194
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.
196
198
197
199
Changes should be made to the following places in the `updater` repo:
- `/lib/Updater.php` <-- core of the Updater functionality for both Web and CLI modes is implemented here
207
205
* Aspects specific to the Web Updater:
208
206
- `/index.web.php`
209
-
- `/Makefile`
210
-
- `make index.php`
211
207
* Aspects specific to the CLI Updater:
212
208
- `/updater.php`
213
209
- `/buildVersionFile.php`
214
210
- `/lib/CommandApplication.php`
215
211
- `/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)
218
236
219
237
#### Server components
220
238
@@ -245,9 +263,29 @@ Keep in mind that for the update/upgrade process there are some additional compo
A working `composer` install is required both for dependency management and for building. See "Testing" below for version requirements.
269
+
248
270
#### Tests
249
271
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 |
|`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 |
251
289
252
290
### Build artifacts / What to check in
253
291
@@ -269,16 +307,23 @@ Plus whatever has been changed in the implementation in:
269
307
270
308
#### Transient
271
309
272
-
Used during the build process but not checked in:
310
+
Used during the build process but not checked in (gitignored):
273
311
274
312
* Specific to the CLI Updater:
275
-
-`/lib/Version.php`
313
+
-`/lib/Version.php` — auto-generated by `buildVersionFile.php`, deleted after `make updater.phar` completes
276
314
277
315
### Testing
278
316
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:
280
322
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).
0 commit comments