Skip to content

CI

CI #3915

Workflow file for this run

name: CI
on:
push:
branches: [master]
tags: [v*]
pull_request:
branches: [master]
pull_request_target:
branches: [master]
schedule:
- cron: 0 4 * * *
concurrency:
group: ci-${{ github.head_ref }}
cancel-in-progress: true
jobs:
lint:
name: Linter
runs-on: ubuntu-latest
# 5 mins for the linter run, possibly 10 min for pre-commit env reinitialization
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Cache pre-commit hooks
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|py3.9|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Cache PyPI
uses: actions/cache@v3
with:
key: pip-lint-${{ hashFiles('requirements/*.txt') }}
path: ~/.cache/pip
restore-keys: |
pip-lint-
- name: Install dependencies
uses: py-actions/py-dependency-install@v4
with:
path: requirements/ci.txt
- name: Run linters
run: |
make lint
env:
CI_LINT_RUN: 1
# https://github.com/neuro-inc/neuro-cli/issues/2904
#- name: Install spell checker
# run: |
# # sudo apt install libenchant-dev
# pip install -r requirements/doc.txt
#- name: Run docs spelling
# run: |
# make api-doc-spelling
unit:
name: Unit
needs: lint
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu, macos, windows]
cmd: [sdk, cli]
exclude:
- python-version: '3.9'
os: macos
- python-version: '3.9'
os: windows
- python-version: '3.10'
os: macos
- python-version: '3.10'
os: ubuntu
fail-fast: false
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)" # - name: Cache
- name: Cache PyPI
uses: actions/cache@v3
with:
key: pip-ci-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt')
}}
path: ${{ steps.pip-cache.outputs.dir }}
restore-keys: |
pip-ci-${{ runner.os }}-${{ matrix.python-version }}-
- name: Install dependencies
uses: py-actions/py-dependency-install@v4
with:
path: requirements/ci.txt
- name: Run unittests
env:
COLOR: yes
run: |
make .test-${{ matrix.cmd }} PYTEST_ARGS=-vvv
- name: Upload coverage artifact
uses: aio-libs/prepare-coverage@v22.1.2
if: matrix.os == 'ubuntu'
e2e:
name: E2E
needs: unit
if: |
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') ||
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]')
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu, macos, windows]
exclude:
- python-version: '3.9'
os: macos
- python-version: '3.9'
os: windows
- python-version: '3.10'
os: macos
- python-version: '3.10'
os: ubuntu
fail-fast: false
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 90
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)" # - name: Cache
- name: Cache PyPI
uses: actions/cache@v3
with:
key: pip-ci-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt')
}}
path: ${{ steps.pip-cache.outputs.dir }}
restore-keys: |
pip-ci-${{ runner.os }}-${{ matrix.python-version }}-
- name: Install dependencies
uses: py-actions/py-dependency-install@v4
with:
path: requirements/ci.txt
- name: Run E2E tests
timeout-minutes: 75
env:
E2E_TOKEN: ${{ secrets.E2E_TOKEN }}
E2E_USER_TOKEN: ${{ secrets.E2E_USER_TOKEN }}
PYTEST_XDIST_NUM_THREADS: 16
COLOR: yes
run: |
make .e2e
- name: Upload coverage artifact
uses: neuro-inc/prepare-coverage@v22.1.2
if: matrix.os == 'ubuntu'
upload-cov:
name: Upload coverage
needs: [unit, e2e]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.sha }}
- name: Upload coverage
uses: aio-libs/upload-coverage@v22.1.4
deploy:
name: Deploy
# TODO y.s. 23.02.20: change back to e2e after tests fix
needs: unit
runs-on: ubuntu-latest
# Run only on pushing a tag
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install dependencies
run: |
make setup
python -m pip install twine build
- name: Make SDK dists
run: |
cd neuro-sdk
python -m build
- name: Make CLI dists
run: |
cd neuro-cli
python -m build
- name: PyPI upload SDK
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN_SDK }}
TWINE_NON_INTERACTIVE: 1
run: |
twine upload neuro-sdk/dist/*
- name: PyPI upload CLI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN_CLI }}
TWINE_NON_INTERACTIVE: 1
run: |
twine upload neuro-cli/dist/*
- name: Merge dists for GitHub Release
run: |
mkdir dist
cp neuro-sdk/dist/* dist/
cp neuro-cli/dist/* dist/
- name: GitHub Release
uses: aio-libs/create-release@v1.6.6
with:
changes_file: CHANGELOG.md
name: Neuro SDK/CLI
github_token: ${{ secrets.GITHUB_TOKEN }}
pypi_token: ""
version_file: neuro-sdk/src/neuro_sdk/__init__.py # CLI has the same version
start_line: "[comment]: # (towncrier release notes start)"
head_line: "Neuro SDK/CLI {version}\\s+\\({date}\\)\n====+\n?"
fix_issue_regex: "\\(\\[#(\\d+)\\]\\(https://github.com/neuro-inc/platform-client-python/issues/\\\
1\\)\\)"
fix_issue_repl: "(#\\1)"