|
1 | 1 | --- |
2 | 2 | name: Tests |
| 3 | + |
3 | 4 | on: # yamllint disable-line rule:truthy |
4 | 5 | - push |
5 | 6 | - pull_request |
6 | 7 | - workflow_dispatch |
| 8 | + |
| 9 | +env: |
| 10 | + SC_VER: "0.10.0" |
| 11 | + ESH_VER: "0.3.2" |
| 12 | + |
7 | 13 | jobs: |
8 | 14 | Tests: |
9 | | - runs-on: ubuntu-latest |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + os: |
| 20 | + - ubuntu-20.04 |
| 21 | + - ubuntu-24.04 |
| 22 | + - macos-13 |
| 23 | + - macos-15 |
| 24 | + - windows-2022 |
| 25 | + |
| 26 | + defaults: |
| 27 | + run: |
| 28 | + shell: bash |
| 29 | + |
10 | 30 | steps: |
11 | | - - uses: actions/checkout@v2 |
12 | | - - name: Tests |
13 | | - run: make test |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - uses: Vampire/setup-wsl@v4 |
| 34 | + if: ${{ runner.os == 'Windows' }} |
| 35 | + |
| 36 | + - name: Install dependencies on Linux |
| 37 | + if: ${{ runner.os == 'Linux' }} |
| 38 | + run: | |
| 39 | + sudo apt-get update |
| 40 | + sudo apt-get install -y \ |
| 41 | + expect \ |
| 42 | + ${{ matrix.os != 'ubuntu-20.04' && 'j2cli' || '' }} |
| 43 | +
|
| 44 | + - name: Install dependencies on macOS |
| 45 | + if: ${{ runner.os == 'macOS' }} |
| 46 | + run: | |
| 47 | + command -v expect || brew install expect |
| 48 | +
|
| 49 | + - name: Install dependencies on Windows (WSL) |
| 50 | + if: ${{ runner.os == 'Windows' }} |
| 51 | + shell: wsl-bash {0} |
| 52 | + run: | |
| 53 | + apt-get update |
| 54 | + apt-get install -y --no-install-recommends \ |
| 55 | + dos2unix \ |
| 56 | + expect \ |
| 57 | + gettext-base \ |
| 58 | + git \ |
| 59 | + gnupg \ |
| 60 | + j2cli \ |
| 61 | + lsb-release \ |
| 62 | + man \ |
| 63 | + python3-pip |
| 64 | +
|
| 65 | + - name: Prepare tools directory |
| 66 | + run: | |
| 67 | + mkdir "${{ runner.temp }}/tools" |
| 68 | + echo "${{ runner.temp }}/tools" >> "${{ github.path }}" |
| 69 | +
|
| 70 | + - name: Install shellcheck |
| 71 | + run: | |
| 72 | + cd "${{ runner.temp }}" |
| 73 | +
|
| 74 | + OS=${{ runner.os == 'macOS' && 'darwin' || 'linux' }} |
| 75 | + ARCH=${{ runner.arch == 'ARM64' && 'aarch64' || 'x86_64' }} |
| 76 | +
|
| 77 | + BASE_URL="https://github.com/koalaman/shellcheck/releases/download" |
| 78 | + SC="v$SC_VER/shellcheck-v$SC_VER.$OS.$ARCH.tar.xz" |
| 79 | +
|
| 80 | + curl -L "$BASE_URL/$SC" | tar Jx shellcheck-v$SC_VER/shellcheck |
| 81 | + mv shellcheck-v$SC_VER/shellcheck tools |
| 82 | +
|
| 83 | + - name: Install esh |
| 84 | + run: | |
| 85 | + cd "${{ runner.temp }}/tools" |
| 86 | +
|
| 87 | + BASE_URL="https://github.com/jirutka/esh/raw/refs/tags" |
| 88 | + curl -L -o esh "$BASE_URL/v$ESH_VER/esh" |
| 89 | + chmod +x esh |
| 90 | +
|
| 91 | + - name: Add old yadm versions # to test upgrades |
| 92 | + run: | |
| 93 | + for version in 1.12.0 2.5.0; do |
| 94 | + git fetch origin $version:refs/tags/$version |
| 95 | + git cat-file blob $version:yadm \ |
| 96 | + > "${{ runner.temp }}/tools/yadm-$version" |
| 97 | + chmod +x "${{ runner.temp }}/tools/yadm-$version" |
| 98 | + done |
| 99 | +
|
| 100 | + - name: Set up Python 3.11 |
| 101 | + if: ${{ runner.os == 'macOS' || matrix.os == 'ubuntu-20.04' }} |
| 102 | + uses: actions/setup-python@v5 |
| 103 | + with: |
| 104 | + python-version: 3.11 |
| 105 | + |
| 106 | + - name: Install dependencies and run tests (Linux/macOS) |
| 107 | + if: ${{ runner.os != 'Windows' }} |
| 108 | + run: | |
| 109 | + git config --global user.email test@yadm.io |
| 110 | + git config --global user.name "Yadm Test" |
| 111 | +
|
| 112 | + python3 -m pip install --upgrade pip |
| 113 | + python3 -m pip install -r test/requirements.txt |
| 114 | + pytest -v --color=yes --basetemp="${{ runner.temp }}/pytest" |
| 115 | +
|
| 116 | + - name: Install dependencies and run tests (WSL) |
| 117 | + if: ${{ runner.os == 'Windows' }} |
| 118 | + shell: wsl-bash {0} |
| 119 | + run: | |
| 120 | + git config --global user.email test@yadm.io |
| 121 | + git config --global user.name "Yadm Test" |
| 122 | + git config --global protocol.file.allow always |
| 123 | +
|
| 124 | + dos2unix yadm.1 .github/workflows/*.yml test/pinentry-mock |
| 125 | + chmod +x test/pinentry-mock |
| 126 | +
|
| 127 | + python3 -m pip install --upgrade pip |
| 128 | + python3 -m pip install -r test/requirements.txt |
| 129 | + pytest -v --color=yes |
0 commit comments