mirror of
https://github.com/lobaro/restic-backup-docker.git
synced 2026-11-14 07:52:44 +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
@@ -0,0 +1,54 @@
|
||||
name: Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
branches: [ "master" ]
|
||||
|
||||
jobs:
|
||||
shellcheck:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install shellcheck
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y -qq shellcheck
|
||||
|
||||
# The test scripts are new, so they are held to a clean bill of health.
|
||||
- name: Run shellcheck on the test scripts
|
||||
run: shellcheck --severity=warning test/*.sh
|
||||
|
||||
# The image scripts declare #!/bin/sh but use a few bash constructs that
|
||||
# busybox ash happens to accept. Cleaning that up is a separate change,
|
||||
# so this step reports but does not block.
|
||||
- name: Run shellcheck on the image scripts
|
||||
run: |
|
||||
shellcheck --severity=warning backup.sh check.sh entry.sh build.sh run.sh \
|
||||
|| echo "::warning::shellcheck reported findings in the image scripts, see the log above"
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build test image
|
||||
run: docker build -t restic-backup-docker:test .
|
||||
|
||||
- name: Install container-structure-test
|
||||
run: |
|
||||
curl -fsSL -o /usr/local/bin/container-structure-test \
|
||||
https://storage.googleapis.com/container-structure-test/v1.19.3/container-structure-test-linux-amd64
|
||||
chmod +x /usr/local/bin/container-structure-test
|
||||
|
||||
- name: Run test suites
|
||||
run: bash test/run.sh --no-build
|
||||
|
||||
# Guards the guard: if someone waters the suites down until a broken
|
||||
# backup no longer fails them, this step turns red.
|
||||
- name: Verify the suite detects a broken backup
|
||||
run: bash test/run.sh --sabotage
|
||||
Reference in new issue
Block a user