mirror of
https://github.com/lobaro/restic-backup-docker.git
synced 2026-11-14 16:02:43 +00:00
test: add container test suites and run them in CI
The repository had no tests: CI only built the image, and the old container-structure-test setup was parked as config-broken.yml / docker-compose.test.broken.yml. This adds suites that actually run the image. - test/compat.sh: backup, restore, forget, check, hooks, failure handling and timezone behaviour against the default configuration. These describe what users depend on today, so a change that turns them red is a breaking change. - test/features.sh: optional features, each guarded by a detection check against the built image. Absent features are reported as SKIP, so open pull requests do not turn master red, and their feature tests start running by themselves once the pull request is rebased. Covers #109 (RESTIC_STREAM), #99 (docker cli, bash) and #84 (msmtp). - test/required-features.txt: once a feature is merged its gate is listed here and a missing feature becomes a failure instead of a skip. - test/structure.yml: revived image layout checks, falls back to the official container-structure-test image when the tool is not installed. - test/run.sh --sabotage: breaks the backup call on a throwaway copy of the tree and expects the suite to fail, so the tests cannot be watered down into always passing. CI runs this as its own step. - .github/workflows/test.yml: shellcheck plus all suites on every pull request. Also adds .gitattributes pinning shell scripts, the Dockerfile and YAML to LF. With a Windows checkout (core.autocrlf=true) the scripts were checked out with CRLF, and the resulting image failed to start with "exec /entry.sh: no such file or directory". No runtime file is touched, the image itself is unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Agent-Id: agent-7034f75b-1ddc-4aa1-a4ea-3a54b340e8d9
This commit is contained in:
1 parent
47d29529e9
commit
10b197f1f5
12 files changed
+890
-30
No files matched your search
@@ -26,6 +26,39 @@ Pull Requests to improve the image are always wellcome. Please create an issue a
|
||||
|
||||
When behaviour of the image changes (Features, Bugfixes, Changes in the API) please update the "Unreleased" section of the [CHANGELOG.md](https://github.com/lobaro/restic-backup-docker/blob/master/CHANGELOG.md)
|
||||
|
||||
## Tests
|
||||
|
||||
The test suites build the image and exercise it as a real container. They need
|
||||
`bash` and `docker`, nothing else:
|
||||
|
||||
```sh
|
||||
bash test/run.sh # build the image and run every suite
|
||||
bash test/run.sh --no-build # reuse an already built image
|
||||
bash test/run.sh --suite compat # run a single suite
|
||||
```
|
||||
|
||||
There are three suites:
|
||||
|
||||
* **compat** (`test/compat.sh`) - backup, restore, forget, check, hooks and
|
||||
failure handling against the default configuration. These tests describe the
|
||||
behaviour users rely on. A change that turns one of them red is a breaking
|
||||
change.
|
||||
* **features** (`test/features.sh`) - tests for optional features. Each block
|
||||
is guarded by a detection check against the built image, so a feature that is
|
||||
not part of the image is reported as `SKIP` instead of failing. Pull requests
|
||||
that add such a feature are therefore covered as soon as they are rebased,
|
||||
without the author having to write the basic tests. After merging a feature,
|
||||
add its gate name to `test/required-features.txt` so that a missing feature
|
||||
turns into a failure.
|
||||
* **structure** (`test/structure.yml`) - image layout checks via
|
||||
[container-structure-test](https://github.com/GoogleContainerTools/container-structure-test).
|
||||
When the tool is not installed, its official container image is used instead.
|
||||
|
||||
`bash test/run.sh --sabotage` is a self test: it breaks the backup call on a
|
||||
throwaway copy of the tree and expects the compat suite to fail. CI runs it so
|
||||
that the suites cannot be watered down into always passing.
|
||||
|
||||
When you add a feature, please add a block to `test/features.sh` for it.
|
||||
|
||||
## Hooks
|
||||
|
||||
|
||||
Reference in new issue
Block a user