Skip to content

Commit 1e56638

Browse files
committed
ci: making test suite runnable as github action
1 parent d2fb18d commit 1e56638

6 files changed

Lines changed: 94 additions & 3 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# ┌───────────────────────────────────────────────────────────────┐
2+
# │ Contents of from_commit_to_build_test.yml │
3+
# ├───────────────────────────────────────────────────────────────┘
4+
#
5+
# ├──┐From commit
6+
# │ └── Build and test
7+
#
8+
# └───────────────────────────────────────────────────────────────
9+
10+
# ################################################################ From commit
11+
12+
name: Run tests on pushed commits
13+
14+
# Run on all branches except master
15+
on:
16+
push:
17+
branches:
18+
- '**'
19+
pull_request:
20+
branches:
21+
- master
22+
23+
permissions:
24+
contents: read
25+
26+
concurrency:
27+
group: ${{ github.workflow }}
28+
cancel-in-progress: true
29+
30+
jobs:
31+
32+
# ################################ Build and test
33+
34+
test:
35+
name: Test package
36+
timeout-minutes: 10
37+
runs-on: ubuntu-latest
38+
env:
39+
RUSTIC_VERSION: "0.10.0"
40+
steps:
41+
42+
- name: Install Act dependencies
43+
if: ${{ env.ACT }}
44+
run: apt-get update && apt-get install sudo -y
45+
46+
- name: Access source code
47+
uses: actions/checkout@v4
48+
49+
- name: Install uv
50+
uses: astral-sh/setup-uv@v5
51+
52+
- name: Install RClone
53+
run: |
54+
curl -sL https://rclone.org/install.sh | bash
55+
which rclone
56+
rclone --version
57+
58+
- name: Install rustic
59+
run: |
60+
curl -sL "https://github.com/rustic-rs/rustic/releases/download/v${RUSTIC_VERSION}/rustic-v${RUSTIC_VERSION}-x86_64-unknown-linux-musl.tar.gz" |
61+
sudo tar -xz -C /usr/bin --strip-components=0 rustic
62+
which rustic
63+
rustic --version
64+
65+
- name: Install package and python dependencies
66+
run: uv sync --group full
67+
68+
- name: Run tests
69+
run: uv run bash tests/tests.sh
70+
71+
- name: Upload coverage reports
72+
uses: actions/upload-artifact@v4
73+
if: ${{ env.ACTIONS_RUNTIME_TOKEN }}
74+
with:
75+
name: coverage-reports
76+
path: /root/rusticlone-tests/coverage/
77+
retention-days: 30

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ lint:
1717
test:
1818
uv run bash tests/tests.sh
1919

20+
ci:
21+
act --workflows ".github/workflows/test.yml"
22+
2023
toc:
2124
find * -type f ! -name 'CHANGELOG.md' -exec toc -f {} \;
2225

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// │ │ │ ├── From the local Rustic repo
1313
// │ │ │ └── From the RClone remote
1414
// │ │ ├── Individual commands
15+
// │ │ ├── Push notifications
1516
// │ │ ├── Parallel processing
1617
// │ │ ├── Exclude profiles
1718
// │ │ ├── Custom log file

rusticlone/helpers/rclone.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
# typing
1717
from typing import Any
1818

19+
# environment variables like $PATH
20+
from os import environ
21+
1922
# launch binaries
2023
import subprocess
2124

@@ -56,7 +59,9 @@ def __init__(self, **kwargs):
5659
"destination": None,
5760
}
5861
kwargs = default_kwargs | kwargs
59-
self.env = kwargs["env"]
62+
# Copy current environment and override with passed env variables
63+
self.env = environ.copy()
64+
self.env.update(kwargs["env"])
6065
self.check_return_code = kwargs["check_return_code"]
6166
self.action = kwargs["action"]
6267
self.origin = kwargs["origin"]

rusticlone/helpers/rustic.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
# typing
1717
from typing import Any
1818

19+
# environment variables like $PATH
20+
from os import environ
21+
1922
# launch binaries
2023
import subprocess
2124

@@ -31,7 +34,9 @@ def __init__(self, profile: str, action: str, *args: str, **kwargs):
3134
"env": {},
3235
}
3336
kwargs = default_kwargs | kwargs
34-
self.env = kwargs["env"]
37+
# Copy current environment and override with passed env variables
38+
self.env = environ.copy()
39+
self.env.update(kwargs["env"])
3540
self.flags = ["--no-progress"]
3641
self.command = [
3742
"rustic",

tests/tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ sources = [
9090

9191
[global.env]
9292
RCLONE_CONFIG = "$RUSTIC_PROFILES_DIR/rclone-encrypted.conf"
93-
RCLONE_PASSWORD_COMMAND = "/usr/bin/python -c \"print('YYYYYY')\""
93+
RCLONE_PASSWORD_COMMAND = "python -c \"print('YYYYYY')\""
9494
CONTENT
9595

9696
mapfile -d '' profileCommonContent << CONTENT

0 commit comments

Comments
 (0)