Skip to content

Commit

Permalink
refactor(ci): 👷 add small smoketest to build pipeline which veryfies …
Browse files Browse the repository at this point in the history
…that borg is working.
  • Loading branch information
AnotherStranger committed Jul 5, 2024
1 parent fd85f58 commit 758257a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 11 deletions.
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Run small selftest on build container image
run: docker run -v "./tests/selftest.sh:/selftest.sh" "ghcr.io/anotherstranger/borg-server:sha-${{ github.sha }}" ./selftest.sh

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
if: ${{ github.event_name != 'pull_request' }}
Expand Down
40 changes: 40 additions & 0 deletions tests/selftest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
set -euxo pipefail

# This file povides a simple smoketest for the build borg binary within the container image
# In this file, we first try to print the borg version, then we try to create a repo and verify its existence.
# In the last step we try to backup a single file.

# Error handling function
error_handler() {
echo "There was an error while performing the self test."
exit 1
}
trap 'error_handler' ERR


export BORG_REPO=/home/borg/backups/test-repo
export BORG_PASSPHRASE="test"

# Print version
borg version

# Initialize a BorgBackup repository
borg init --encryption repokey

# Check that the repository was created successfully
borg list

# backup single file and try to restore it.
echo "Hello, World!" > testfile.txt
borg create ::test ./testfile.txt

# restore backup
mkdir restored
cd restored
borg extract ::test

# Compare file with original
cmp -s ../testfile.txt ./testfile.txt || exit 1

echo "Selftest finished without errors."

0 comments on commit 758257a

Please sign in to comment.