summaryrefslogtreecommitdiff
path: root/.github/workflows/tests.yml
blob: fcf2ce7c4fcf75484ca5905825a93af3c8bf3f5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Test

on: [push, pull_request]

jobs:
  tests:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        python: ["3.6", "3.7", "3.8", "3.9", "3.10"]
        os: [ubuntu-latest, ubuntu-18.04, macos-latest, windows-latest]

    steps:
      - name: Check out the repository
        uses: actions/checkout@v3

      # Clean poisoned cache
      # - name: Ubuntu cache
      #   uses: actions/cache@v2
      #   if: startsWith(matrix.os, 'ubuntu')
      #   with:
      #     path: ~/.cache/pip
      #     key:
      #       ${{ matrix.os }}-${{ matrix.python }}-${{ hashFiles('**/pyproject.toml') }}
      #     restore-keys: |
      #       ${{ matrix.os }}-${{ matrix.python }}-

      # - name: macOS cache
      #   uses: actions/cache@v2
      #   if: startsWith(matrix.os, 'macOS')
      #   with:
      #     path: ~/Library/Caches/pip
      #     key:
      #       ${{ matrix.os }}-${{ matrix.python }}-${{ hashFiles('**/pyproject.toml') }}
      #     restore-keys: |
      #       ${{ matrix.os }}-${{ matrix.python }}-

      # - name: Windows cache
      #   uses: actions/cache@v2
      #   if: startsWith(matrix.os, 'windows')
      #   with:
      #     path: c:\users\runneradmin\appdata\local\pip\cache
      #     key:
      #       ${{ matrix.os }}-${{ matrix.python }}-${{ hashFiles('**/pyproject.toml') }}
      #     restore-keys: |
      #       ${{ matrix.os }}-${{ matrix.python }}-

      - name: Set up Python ${{ matrix.python }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python }}

      - name: Upgrade pip
        run: |
          pip install --constraint=.github/workflows/constraints.txt pip
          pip --version

      - name: Install Poetry
        run: |
          pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
          poetry --version

      - name: Install dependencies
        run: poetry install

      - name: Test
        shell: bash
        run: |
          poetry run pytest tests/unit/ -s --cov=isort/ --cov-report=term-missing ${@-}
          poetry run coverage xml

      - name: Report Coverage
        if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9'
        uses: codecov/codecov-action@v1