Skip to content

Commit 8a62ac2

Browse files
authored
👷 Improve cicd (#154)
* 🧪 Remove fetch_x5 test * 👷 Improve CI/CD
1 parent 45c38b3 commit 8a62ac2

File tree

2 files changed

+74
-46
lines changed

2 files changed

+74
-46
lines changed

.github/workflows/ci-test.yml

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,60 @@ jobs:
1010
name: Check tests
1111
runs-on: ${{ matrix.os }}
1212
env:
13+
# fix the python version and the operating system for codecoverage commentator
1314
USING_COVERAGE_PY: '3.8'
14-
USING_COVERAGE_OS: 'macos-latest'
15+
USING_COVERAGE_OS: 'ubuntu-latest'
16+
outputs:
17+
# fix the results of pytest for unix
18+
output1: ${{ steps.pytest.outputs.exit_code }}
1519

1620
strategy:
1721
matrix:
1822
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
1923
python-version: ['3.6', '3.7', '3.8', '3.9']
20-
platform: 'x64'
24+
# GitHub does not cancel all in-progress jobs if any matrix job fails
2125
fail-fast: false
2226

2327
steps:
24-
- uses: actions/checkout@v2
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v2
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
- name: Install dependencies and lints
30-
run: pip install . -r test_requirements.txt -r requirements.txt
31-
- name: Run PyTest
32-
run: pytest | tee pytest-coverage.txt
33-
- name: Comment coverage
34-
if: contains(env.USING_COVERAGE_PY, matrix.python-version) && contains(env.USING_COVERAGE_OS, matrix.os)
35-
uses: MishaKav/[email protected]
36-
with:
37-
pytest-coverage-path: ./pytest-coverage.txt
38-
junitxml-path: ./pytest.xml
28+
- uses: actions/checkout@v2
29+
# Install python
30+
- name: Set up Python ${{ matrix.python-version }}
31+
uses: actions/setup-python@v2
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
# Update pip and install dependencies
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
pip install . -r test_requirements.txt -r requirements.txt
39+
# Pytest in windows
40+
- name: Run PyTest windows
41+
if: ${{ matrix.os == 'windows-latest' }}
42+
run: |
43+
pytest | tee pytest-coverage.txt
44+
# Pytest in unix. Exit code of this run captures the exit status of tee and not of pytest
45+
# So, use $PIPESTATUS that holds the exit status of each command in pipeline
46+
- name: Run PyTest unix
47+
if: ${{ matrix.os != 'windows-latest' }}
48+
id: pytest
49+
run: |
50+
pytest | tee pytest-coverage.txt;
51+
exit_code=${PIPESTATUS[0]};
52+
echo "::set-output name=exit_code::$exit_code"
53+
# Сomment on the results of the test coverage
54+
- name: Comment coverage
55+
if: contains(env.USING_COVERAGE_PY, matrix.python-version) && contains(env.USING_COVERAGE_OS, matrix.os)
56+
uses: MishaKav/[email protected]
57+
with:
58+
pytest-coverage-path: ./pytest-coverage.txt
59+
junitxml-path: ./pytest.xml
60+
# For unix workflow should have failed if exit code of pytest were 1
61+
- name: Check fail of pytest unix
62+
if: ${{ matrix.os != 'windows-latest' && steps.pytest.outputs.exit_code == 1 }}
63+
uses: actions/github-script@v3
64+
with:
65+
script: |
66+
core.setFailed('Some tests failed!')
3967
4068
check_sphinx_build:
4169
name: Check Sphinx build for docs
@@ -44,15 +72,15 @@ jobs:
4472
matrix:
4573
python-version: [3.8]
4674
steps:
47-
- name: Checkout
48-
uses: actions/checkout@v2
49-
- name: Set up Python
50-
uses: actions/setup-python@v2
51-
with:
52-
python-version: ${{ matrix.python-version }}
53-
- name: Update pip
54-
run: python -m pip install --upgrade pip
55-
- name: Install dependencies
56-
run: pip install -r docs/requirements.txt -r requirements.txt
57-
- name: Run Sphinx
58-
run: sphinx-build -W -b html docs /tmp/_docs_build
75+
- name: Checkout
76+
uses: actions/checkout@v2
77+
- name: Set up Python
78+
uses: actions/setup-python@v2
79+
with:
80+
python-version: ${{ matrix.python-version }}
81+
- name: Update pip and install dependencies
82+
run: |
83+
python -m pip install --upgrade pip
84+
pip install -r docs/requirements.txt -r requirements.txt
85+
- name: Run Sphinx
86+
run: sphinx-build -W -b html docs /tmp/_docs_build

sklift/tests/test_datasets.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,23 @@ def test_fetch_lenta(lenta_dataset):
3535
assert data.treatment.shape == lenta_dataset['treatment.shape']
3636

3737

38-
@pytest.fixture
39-
def x5_dataset() -> dict:
40-
data = {'keys': ['data', 'target', 'treatment', 'DESCR', 'feature_names', 'target_name', 'treatment_name'],
41-
'data.keys': ['clients', 'train', 'purchases'], 'clients.shape': (400162, 5),
42-
'train.shape': (200039, 1), 'target.shape': (200039,), 'treatment.shape': (200039,)}
43-
return data
44-
45-
46-
def test_fetch_x5(x5_dataset):
47-
data = fetch_x5()
48-
assert isinstance(data, sklearn.utils.Bunch)
49-
assert set(data.keys()) == set(x5_dataset['keys'])
50-
assert set(data.data.keys()) == set(x5_dataset['data.keys'])
51-
assert data.data.clients.shape == x5_dataset['clients.shape']
52-
assert data.data.train.shape == x5_dataset['train.shape']
53-
assert data.target.shape == x5_dataset['target.shape']
54-
assert data.treatment.shape == x5_dataset['treatment.shape']
38+
# @pytest.fixture
39+
# def x5_dataset() -> dict:
40+
# data = {'keys': ['data', 'target', 'treatment', 'DESCR', 'feature_names', 'target_name', 'treatment_name'],
41+
# 'data.keys': ['clients', 'train', 'purchases'], 'clients.shape': (400162, 5),
42+
# 'train.shape': (200039, 1), 'target.shape': (200039,), 'treatment.shape': (200039,)}
43+
# return data
44+
#
45+
#
46+
# def test_fetch_x5(x5_dataset):
47+
# data = fetch_x5()
48+
# assert isinstance(data, sklearn.utils.Bunch)
49+
# assert set(data.keys()) == set(x5_dataset['keys'])
50+
# assert set(data.data.keys()) == set(x5_dataset['data.keys'])
51+
# assert data.data.clients.shape == x5_dataset['clients.shape']
52+
# assert data.data.train.shape == x5_dataset['train.shape']
53+
# assert data.target.shape == x5_dataset['target.shape']
54+
# assert data.treatment.shape == x5_dataset['treatment.shape']
5555

5656

5757
@pytest.fixture

0 commit comments

Comments
 (0)