Skip to content

Commit c654e40

Browse files
committed
Initial commit
0 parents  commit c654e40

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1993
-0
lines changed

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/bin export-ignore
2+
/tests export-ignore
3+
/.github export-ignore
4+
/.gitattributes export-ignore
5+
/.gitignore export-ignore
6+
/phpunit.xml export-ignore

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: terminal42
2+
ko_fi: terminal42

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CI
2+
3+
on:
4+
push: ~
5+
pull_request: ~
6+
7+
permissions: read-all
8+
9+
jobs:
10+
ci:
11+
uses: 'terminal42/contao-build-tools/.github/workflows/build-tools.yml@main'
12+
13+
tests:
14+
name: Unit tests (PHP ${{ matrix.php }}
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
php: [ '8.1', '8.2', '8.3', '8.4' ]
20+
steps:
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
coverage: none
26+
27+
- name: Checkout
28+
uses: actions/checkout@v3
29+
30+
- name: Install the dependencies
31+
run: |
32+
composer install --no-interaction --no-progress
33+
34+
- name: Run phpunit
35+
run: composer unit

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.phpunit.cache
2+
/tests/Fixtures/**/var/restic
3+
/var
4+
/vendor
5+
composer.lock

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 terminal42 gmbh
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# terminal42/php-restic
2+
3+
> An opinionated PHP library that installs Restic and provides basic commands to work via PHP with it.
4+
> It is used for our own purposes and thus **not covered** by any API BC promises whatsoever.
5+
> Use at your own risk.
6+
7+
## License
8+
9+
This project is open-sourced under the [MIT License](LICENSE).

bin/bump-restic-version.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
declare(strict_types=1);
5+
6+
require __DIR__.'/../vendor/autoload.php';
7+
8+
use Symfony\Component\Console\Command\Command;
9+
use Symfony\Component\Console\Input\InputArgument;
10+
use Symfony\Component\Console\Input\InputInterface;
11+
use Symfony\Component\Console\Output\OutputInterface;
12+
use Symfony\Component\Console\SingleCommandApplication;
13+
use Symfony\Component\Console\Style\SymfonyStyle;
14+
use Terminal42\Restic\Restic;
15+
16+
(new SingleCommandApplication())
17+
->setName('Bump restic version.')
18+
->addArgument('version', InputArgument::REQUIRED, 'The desired version.')
19+
->setCode(
20+
static function (InputInterface $input, OutputInterface $output): int {
21+
$io = new SymfonyStyle($input, $output);
22+
$version = $input->getArgument('version');
23+
24+
// Read the file
25+
$resticClassPath = __DIR__.'/../src/Restic.php';
26+
$content = file_get_contents($resticClassPath);
27+
$pattern = "/public?\\s*const\\s+RESTIC_VERSION\\s*=\\s*'[^']*';/";
28+
$replacement = "public const RESTIC_VERSION = '{$version}';";
29+
$updatedContent = preg_replace($pattern, $replacement, $content);
30+
file_put_contents($resticClassPath, $updatedContent);
31+
32+
if (Restic::RESTIC_VERSION !== $version) {
33+
$io->error('Version could not be updated in Restic class.');
34+
35+
return Command::FAILURE;
36+
}
37+
38+
Restic::updateShaSumFile();
39+
40+
return Command::SUCCESS;
41+
},
42+
)
43+
->run()
44+
;

composer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "terminal42/php-restic",
3+
"description": "An opinionated helper library for Restic",
4+
"type": "library",
5+
"require": {
6+
"php": "^8.1",
7+
"ext-zip": "*",
8+
"ext-bz2": "*",
9+
"symfony/filesystem": "^6.4 || ^7.0",
10+
"symfony/finder": "^6.4 || ^7.0",
11+
"symfony/http-client": "^6.4 || ^7.0",
12+
"symfony/process": "^6.4 || ^7.0"
13+
},
14+
"license": "MIT",
15+
"autoload": {
16+
"psr-4": {
17+
"Terminal42\\Restic\\": "src/"
18+
}
19+
},
20+
"autoload-dev": {
21+
"psr-4": {
22+
"Terminal42\\Restic\\Test\\": "tests/"
23+
}
24+
},
25+
"authors": [
26+
{
27+
"name": "Yanick Witschi",
28+
"email": "[email protected]"
29+
}
30+
],
31+
"config": {
32+
"allow-plugins": {
33+
"terminal42/contao-build-tools": true
34+
}
35+
},
36+
"require-dev": {
37+
"phpunit/phpunit": "^11.5",
38+
"symfony/console": "^6.4 || ^7.0",
39+
"terminal42/contao-build-tools": "dev-main"
40+
}
41+
}

config/restic_sha256sums.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
fc068d7fdd80dd6a968b57128d736b8c6147aa23bcba584c925eb73832f6523e restic-0.18.0.tar.gz
2+
0ff4e5315bb083c30eb688b957f1ff12148876bb398c8dcb58acd21a0c6683c8 restic_0.18.0_aix_ppc64.bz2
3+
10796285a653c51fe63419009423ebeb0c2d8c1ee4b6fdb2dd0d6fe1cc5a229e restic_0.18.0_darwin_amd64.bz2
4+
dd7d64a9bc0c1f8342e8f9693d5b198e9f04022f78b07f15d17ef9b801d4489d restic_0.18.0_darwin_arm64.bz2
5+
96c87adc9ce025c261ece50918988e784a181a7577517081542d49d7029bb60c restic_0.18.0_dragonfly_amd64.bz2
6+
2af5388ece52906962b37c1dbadee2b39131cc686dd9e83dfa65d2b642f6cdb2 restic_0.18.0_freebsd_386.bz2
7+
38895925bf9f262deb7b2986578112ea8bfb17dcb1cac9b8ed07f4d3eaedc904 restic_0.18.0_freebsd_amd64.bz2
8+
100e3c4dcf0c59188dc9fd0b0fd8cc7760af5536133e1ab9df0d5a9c61e9bef5 restic_0.18.0_freebsd_arm.bz2
9+
c171b288885830863fa290a3bcdc4e50c0425758f3fff7ce7fef27741b0cf374 restic_0.18.0_linux_386.bz2
10+
98f6dd8bf5b59058d04bfd8dab58e196cc2a680666ccee90275a3b722374438e restic_0.18.0_linux_amd64.bz2
11+
a202b58cb23c7b40e2562d9b0804492f77278bd0d0bf043f5e02951f89c83eb5 restic_0.18.0_linux_arm.bz2
12+
ce18179c25dc5f2e33e3c233ba1e580f9de1a4566d2977e8d9600210363ec209 restic_0.18.0_linux_arm64.bz2
13+
5255c343b9eaeae4b41414bfbceaf6c33d110efd3220fc921e1ff6cd32081a13 restic_0.18.0_linux_mips.bz2
14+
ca36a1ab775a37b08e26847e459e1dff6cdcd5c45d142fe0ac5568dfd3834752 restic_0.18.0_linux_mips64.bz2
15+
b4b266c353da4d3676fef52dfef5dfe66627c5310994a2eef4aa67ae8b1f0db5 restic_0.18.0_linux_mips64le.bz2
16+
fc98872d58863a660da4bbc0a6456fc4314ba9f537dc2e1a09cd0065da00c346 restic_0.18.0_linux_mipsle.bz2
17+
cc381e69b7a495770e87f6a289994de1382f93739079e072f666b133729104da restic_0.18.0_linux_ppc64le.bz2
18+
855a27d8f7d1ce7deec3beaea03a348f88449c69922cc3d65c34d8be645ee3a5 restic_0.18.0_linux_riscv64.bz2
19+
309068f6ae532e2fe260f70195133bf26cf454abb19079fc59708056e31f1318 restic_0.18.0_linux_s390x.bz2
20+
1e35a34babb4548245efd4d16a2b6f3a0270715ac7822d47ed2db9793f0209cf restic_0.18.0_netbsd_386.bz2
21+
13c09edce29ebea1dc2057c73c3d21b23eb147f1f8d8349013c4a02541d1c94b restic_0.18.0_netbsd_amd64.bz2
22+
0f6cabda7c204d893103207aeeab532ba177108d4e09fbe0e602f62402bc3597 restic_0.18.0_openbsd_386.bz2
23+
9eabcfb809599d912e0590b7a89c9cb837347b79805f29438ebfc08a3e7900bb restic_0.18.0_openbsd_amd64.bz2
24+
2f05d56f66dd539b2054f975ad96b41f43984adc6e364bc76b8d5dbba8762c3e restic_0.18.0_solaris_amd64.bz2
25+
057da51accf774ea551d680239fa55c61613584be0e960a2a5d0ab9018f6f585 restic_0.18.0_windows_386.zip
26+
c90cfcd577fe3d60d2529021e76bd5637bdcd19d7fa84840a40fcbbf995902de restic_0.18.0_windows_amd64.zip

phpunit.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheDirectory=".phpunit.cache"
6+
executionOrder="depends,defects"
7+
shortenArraysForExportThreshold="10"
8+
requireCoverageMetadata="false"
9+
beStrictAboutCoverageMetadata="true"
10+
beStrictAboutOutputDuringTests="true"
11+
displayDetailsOnPhpunitDeprecations="true"
12+
failOnPhpunitDeprecation="true"
13+
failOnRisky="true"
14+
failOnWarning="true">
15+
<testsuites>
16+
<testsuite name="functional">
17+
<directory>tests/Functional</directory>
18+
</testsuite>
19+
<testsuite name="unit">
20+
<directory>tests/Unit</directory>
21+
</testsuite>
22+
</testsuites>
23+
24+
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
25+
<include>
26+
<directory>src</directory>
27+
</include>
28+
</source>
29+
</phpunit>

0 commit comments

Comments
 (0)