aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/testsuite.yml
blob: b8c01c60c678723f7176917eb895d55ef5e6425a (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Testsuite

on:
  [push, pull_request]

jobs:
  pytype:
    runs-on: ubuntu-latest
    steps:
    - name: Check out repository
      uses: actions/checkout@v4
    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: "3.10"
    - name: install pytype
      run: pip install setuptools pytype pytest scandir pathlib2 pandas xlrd django pyarrow
    - name: Run pytype
      run: |
        pytype pyfakefs --keep-going --exclude pyfakefs/tests/* --exclude pyfakefs/pytest_tests/*

  tests:
    runs-on: ${{ matrix.os }}
    env:
      PYTHONWARNDEFAULTENCODING: true
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macOS-latest, windows-latest]
        python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"]
        include:
          - python-version: "pypy-3.7"
            os: ubuntu-latest
          - python-version: "pypy-3.9"
            os: ubuntu-latest
          - python-version: "pypy-3.10"
            os: ubuntu-latest
        exclude:
          - python-version: 3.7
            os: macOS-latest

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

    - name: Get pip cache dir
      id: pip-cache
      run: |
        python -m pip install --upgrade pip
        echo "::set-output name=dir::$(pip cache dir)"

    - name: Cache dependencies
      id: cache-dep
      uses: actions/cache@v4
      with:
        path: ${{ steps.pip-cache.outputs.dir }}
        key: ${{ matrix.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/extra_requirements.txt') }}-${{ hashFiles('**/legacy_requirements.txt') }}
        restore-keys: |
          ${{ matrix.os }}-${{ matrix.python-version }}-pip-

    - name: Install dependencies
      run: |
        pip install setuptools wheel
        pip install -r requirements.txt
    - name: Run unit tests without extra packages as non-root user
      run: |
        export TEST_REAL_FS=1
        python -bb -m pyfakefs.tests.all_tests_without_extra_packages
      shell: bash
    - name: Run setup.py test (uses pytest)
      run: |
        python setup.py test
      shell: bash
    - name: Run unit tests without extra packages as root
      run: |
        if [[ '${{ matrix.os  }}' != 'windows-latest' ]]; then
          # provide the same path as non-root to get the correct virtualenv
          sudo env "PATH=$PATH" python -m pyfakefs.tests.all_tests_without_extra_packages
        fi
      shell: bash
    - name: Install extra dependencies
      if: ${{ matrix.python-version != 'pypy-3.10' }}
      run: |
        pip install -r extra_requirements.txt
        pip install -r legacy_requirements.txt
        pip install zstandard cffi  # needed to test #910
      shell: bash
    - name: Run unit tests with extra packages as non-root user
      if: ${{ matrix.python-version != 'pypy-3.10' }}
      run: |
        export PYTHON_ZSTANDARD_IMPORT_POLICY=cffi  # needed to test #910
        python -m pyfakefs.tests.all_tests
      shell: bash
    - name: Run performance tests
      run: |
        if [[ '${{ matrix.os  }}' != 'macOS-latest' ]]; then
          export TEST_PERFORMANCE=1
          python -m pyfakefs.tests.performance_test
        fi
      shell: bash

  pytest-test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macOS-latest, windows-latest]
        python-version: ["3.9"]
        pytest-version: [3.0.0, 3.5.1, 4.0.2, 4.5.0, 5.0.1, 5.4.3, 6.0.2, 6.2.5, 7.0.1, 7.1.3, 7.2.0, 7.3.1, 7.4.0]
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies
        run: |
          pip install -r requirements.txt
          pip install -U pytest==${{ matrix.pytest-version }}
          pip install opentimelineio pandas parquet pyarrow
          pip install -e .
          if [[ '${{ matrix.pytest-version }}' == '4.0.2' ]]; then
             pip install -U attrs==19.1.0
          fi
        shell: bash
      - name: Run pytest tests
        run: |
          echo "$(python -m pytest pyfakefs/pytest_tests/pytest_plugin_failing_helper.py)" > ./testresult.txt
          python -m pytest pyfakefs/pytest_tests
          if [[ '${{ matrix.pytest-version }}' > '3.0.0' ]]; then
            cd pyfakefs/pytest_tests/ns_package
            python -m pytest --log-cli-level=INFO test
          fi
        shell: bash

  dependency-check:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
        python-version:  ["3.10"]
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies
        run: |
          pip install -r requirements.txt
          pip install -r extra_requirements.txt
          pip install -r legacy_requirements.txt
          pip install pytest-find-dependencies
      - name: Check dependencies
        run: python -m pytest --find-dependencies pyfakefs/tests
        shell: bash