Skip to content

Commit f6441b9

Browse files
committed
Test running tests directly on action runner
To be able to test on different systems.
1 parent d74a41b commit f6441b9

File tree

3 files changed

+86
-5
lines changed

3 files changed

+86
-5
lines changed

.github/workflows/test.yml

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,92 @@
11
---
22
name: Tests
3+
34
on: # yamllint disable-line rule:truthy
45
- push
56
- pull_request
67
- workflow_dispatch
8+
9+
env:
10+
SC_VER: "0.9.0"
11+
ESH_VER: "0.3.2"
12+
713
jobs:
814
Tests:
9-
runs-on: ubuntu-latest
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os:
20+
- ubuntu-24.04
21+
- macos-13
22+
python-version:
23+
- "3.11"
1024
steps:
11-
- uses: actions/checkout@v2
12-
- name: Tests
13-
run: make test
25+
- uses: actions/checkout@v4
26+
27+
- name: Install dependencies on Linux
28+
if: ${{ runner.os == 'Linux' }}
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y expect
32+
- name: Install dependencies on macOS
33+
if: ${{ runner.os == 'macOS' }}
34+
run: |
35+
brew install expect
36+
37+
- name: Prepare tools directory
38+
run: |
39+
mkdir "$RUNNER_TEMP/tools"
40+
echo "$RUNNER_TEMP/tools" >> "$GITHUB_PATH"
41+
42+
- name: Install shellcheck
43+
run: |
44+
if [ "$RUNNER_OS" = "macOS" ]; then
45+
OS=darwin
46+
else
47+
OS=linux
48+
fi
49+
50+
if [ "$RUNNER_ARCH" = "ARM64" ]; then
51+
ARCH=aarch64
52+
else
53+
ARCH=x86_64
54+
fi
55+
56+
cd "$RUNNER_TEMP"
57+
58+
BASE_URL="https://github.com/koalaman/shellcheck/releases/download"
59+
SC="v$SC_VER/shellcheck-v$SC_VER.$OS.$ARCH.tar.xz"
60+
curl -L "$BASE_URL/$SC" | tar Jx shellcheck-v$SC_VER/shellcheck
61+
mv shellcheck-v$SC_VER/shellcheck tools
62+
63+
- name: Install esh
64+
run: |
65+
cd "$RUNNER_TEMP/tools"
66+
67+
BASE_URL="https://github.com/jirutka/esh/raw/refs/tags"
68+
curl -L -o esh "$BASE_URL/v$ESH_VER/esh"
69+
chmod +x esh
70+
71+
- name: Add old yadm versions # to test upgrades
72+
run: |
73+
for version in 1.12.0 2.5.0; do
74+
git fetch origin $version:refs/tags/$version
75+
git cat-file blob $version:yadm > "$RUNNER_TEMP/tools/yadm-$version"
76+
chmod +x "$RUNNER_TEMP/tools/yadm-$version"
77+
done
78+
79+
- name: Set up Python ${{ matrix.python-version }}
80+
uses: actions/setup-python@v5
81+
with:
82+
python-version: ${{ matrix.python-version }}
83+
- name: Install Python dependencies
84+
run: |
85+
python -m pip install --upgrade pip
86+
python -m pip install -r test/requirements.txt
87+
88+
- name: Run tests
89+
run: |
90+
git config --global user.email [email protected]
91+
git config --global user.name "Yadm Test"
92+
pytest -v --color=yes

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
.testyadm
66
_site
77
testenv
8+
__pycache__/

test/test_syntax.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ def test_yamllint(pytestconfig, runner, yamllint_version):
7777

7878
def test_man(runner):
7979
"""Check for warnings from man"""
80-
run = runner(command=["man.REAL", "--warnings", "./yadm.1"])
80+
man = "man.REAL" if runner(command=["man.REAL", "-V"]).success else "man"
81+
run = runner(command=[man, "--warnings", "./yadm.1"])
8182
assert run.success
8283
assert run.err == ""
8384
assert "yadm - Yet Another Dotfiles Manager" in run.out

0 commit comments

Comments
 (0)