Compare commits
1 commit
a99944e2d2
...
2849ae1a97
Author | SHA1 | Date | |
---|---|---|---|
|
2849ae1a97 |
4 changed files with 89 additions and 7 deletions
87
.github/workflows/test.yml
vendored
87
.github/workflows/test.yml
vendored
|
@ -1,13 +1,92 @@
|
|||
---
|
||||
name: Tests
|
||||
|
||||
on: # yamllint disable-line rule:truthy
|
||||
- push
|
||||
- pull_request
|
||||
- workflow_dispatch
|
||||
|
||||
env:
|
||||
SC_VER: "0.9.0"
|
||||
ESH_VER: "0.3.2"
|
||||
|
||||
jobs:
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-24.04
|
||||
- macos-13
|
||||
python-version:
|
||||
- "3.11"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Tests
|
||||
run: make test
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies on Linux
|
||||
if: ${{ runner.os == 'Linux' }}
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y expect
|
||||
- name: Install dependencies on macOS
|
||||
if: ${{ runner.os == 'macOS' }}
|
||||
run: |
|
||||
brew install expect
|
||||
|
||||
- name: Prepare tools directory
|
||||
run: |
|
||||
mkdir "$RUNNER_TEMP/tools"
|
||||
echo "$RUNNER_TEMP/tools" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Install shellcheck
|
||||
run: |
|
||||
if [ "$RUNNER_OS" = "macOS" ]; then
|
||||
OS=darwin
|
||||
else
|
||||
OS=linux
|
||||
fi
|
||||
|
||||
if [ "$RUNNER_ARCH" = "ARM64" ]; then
|
||||
ARCH=aarch64
|
||||
else
|
||||
ARCH=x86_64
|
||||
fi
|
||||
|
||||
cd "$RUNNER_TEMP"
|
||||
|
||||
BASE_URL="https://github.com/koalaman/shellcheck/releases/download"
|
||||
SC="v$SC_VER/shellcheck-v$SC_VER.$OS.$ARCH.tar.xz"
|
||||
curl -L "$BASE_URL/$SC" | tar Jx shellcheck-v$SC_VER/shellcheck
|
||||
mv shellcheck-v$SC_VER/shellcheck tools
|
||||
|
||||
- name: Install esh
|
||||
run: |
|
||||
cd "$RUNNER_TEMP/tools"
|
||||
|
||||
BASE_URL="https://github.com/jirutka/esh/raw/refs/tags"
|
||||
curl -L -o esh "$BASE_URL/v$ESH_VER/esh"
|
||||
chmod +x esh
|
||||
|
||||
- name: Add old yadm versions # to test upgrades
|
||||
run: |
|
||||
for version in 1.12.0 2.5.0; do
|
||||
git fetch origin $version:refs/tags/$version
|
||||
git cat-file blob $version:yadm > "$RUNNER_TEMP/tools/yadm-$version"
|
||||
chmod +x "$RUNNER_TEMP/tools/yadm-$version"
|
||||
done
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install Python dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install -r test/requirements.txt
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
sudo git config --system user.email test@yadm.io
|
||||
sudo git config --system user.name "Yadm Test"
|
||||
pytest -v --color=yes
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,3 +5,4 @@
|
|||
.testyadm
|
||||
_site
|
||||
testenv
|
||||
__pycache__/
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Syntax checks"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -77,7 +78,8 @@ def test_yamllint(pytestconfig, runner, yamllint_version):
|
|||
|
||||
def test_man(runner):
|
||||
"""Check for warnings from man"""
|
||||
run = runner(command=["man.REAL", "--warnings", "./yadm.1"])
|
||||
man = "man" if shutil.which("man.REAL") is None else "man.REAL"
|
||||
run = runner(command=[man, "--warnings", "./yadm.1"])
|
||||
assert run.success
|
||||
assert run.err == ""
|
||||
assert "yadm - Yet Another Dotfiles Manager" in run.out
|
||||
|
|
|
@ -19,7 +19,7 @@ import pytest
|
|||
],
|
||||
)
|
||||
@pytest.mark.parametrize("submodule", [False, True], ids=["no submodule", "with submodules"])
|
||||
def test_upgrade(tmpdir, runner, versions, submodule):
|
||||
def test_upgrade(tmpdir, runner, paths, versions, submodule):
|
||||
"""Upgrade tests"""
|
||||
# pylint: disable=too-many-statements
|
||||
home = tmpdir.mkdir("HOME")
|
||||
|
@ -39,7 +39,7 @@ def test_upgrade(tmpdir, runner, versions, submodule):
|
|||
os.environ.pop("XDG_DATA_HOME", None)
|
||||
|
||||
def run_version(version, *args, check_stderr=True):
|
||||
yadm = f"yadm-{version}" if version else "/yadm/yadm"
|
||||
yadm = f"yadm-{version}" if version else paths.pgm
|
||||
run = runner([yadm, *args], shell=True, cwd=str(home), env=env)
|
||||
assert run.success
|
||||
if check_stderr:
|
||||
|
|
Loading…
Reference in a new issue