Commit 94cba287 authored by baberabb's avatar baberabb
Browse files

Add CI setup

parent 0a48d7c5
# This workflow will install Python dependencies, run tests and lint with a single version of Python # This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Build #name: Build
#
on: #on:
push: # push:
pull_request: # pull_request:
workflow_dispatch: # workflow_dispatch:
#
jobs: #jobs:
build: # build:
runs-on: ubuntu-latest # runs-on: ubuntu-latest
strategy: # strategy:
matrix: # matrix:
python-version: ["3.8", "3.9", "3.10"] # python-version: ["3.8", "3.9", "3.10"]
steps: # steps:
- uses: actions/checkout@v3 # - uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} # - name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3 # uses: actions/setup-python@v3
with: # with:
python-version: ${{ matrix.python-version }} # python-version: ${{ matrix.python-version }}
- name: Install dependencies # - name: Install dependencies
run: | # run: |
python -m pip install --upgrade pip # python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov # pip install flake8 pytest pytest-cov
pip install -e .[dev,multilingual] # pip install -e .[dev,multilingual]
# Install optional git dependencies # # Install optional git dependencies
pip install bleurt@https://github.com/google-research/bleurt/archive/b610120347ef22b494b6d69b4316e303f5932516.zip#egg=bleurt # pip install bleurt@https://github.com/google-research/bleurt/archive/b610120347ef22b494b6d69b4316e303f5932516.zip#egg=bleurt
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi # if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8 # - name: Lint with flake8
run: | # run: |
# stop the build if there are Python syntax errors or undefined names # # stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide # # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest # - name: Test with pytest
run: |
pytest -vv tests/evaluator.py
# - name: Upload to codecov
# run: | # run: |
# bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN # pytest -vv tests/evaluator.py
## - name: Upload to codecov
## run: |
## bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python package name: Tests
on: on:
push: push:
...@@ -9,34 +9,49 @@ on: ...@@ -9,34 +9,49 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
build: linter:
name: Linters
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: timeout-minutes: 20
fail-fast: false
matrix:
python-version: ["3.9"]
steps: steps:
- uses: actions/checkout@v3 - name: Checkout Code
- name: Set up Python ${{ matrix.python-version }} uses: actions/checkout@v3
uses: actions/setup-python@v3 - name: Set up Python 3.8
uses: actions/setup-python@v4
with: with:
python-version: ${{ matrix.python-version }} python-version: 3.9
- name: Install dependencies - name: Install dependencies
run: | run: pip install -e '.[linting,testing]' --extra-index-url https://download.pytorch.org/whl/cpu
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov
pip install -e .[dev,multilingual]
# Install optional git dependencies
pip install bleurt@https://github.com/google-research/bleurt/archive/b610120347ef22b494b6d69b4316e303f5932516.zip#egg=bleurt
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8 - name: Lint with flake8
run: | run: |
# stop the build if there are Python syntax errors or undefined names # stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics flake8 . --count --select=F,E9,E71,E72,E501,E112,E113,W6 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest - name: Lint with pylint
run: python -m pylint --disable=all -e W0311 --jobs=0 --indent-string=' ' **/*.py
- name: Lint with mypy
run: mypy tinygrad/ --ignore-missing-imports --check-untyped-defs --explicit-package-bases --warn-unreachable
testcpu:
name: CPU Tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install dependencies
run: | run: |
pytest tests/test_evaluator.py python -m pip install --upgrade pip
pip -e '.[testing]' --extra-index-url https://download.pytorch.org/whl/cpu
# Install optional git dependencies
# pip install bleurt@https://github.com/google-research/bleurt/archive/b610120347ef22b494b6d69b4316e303f5932516.zip#egg=bleurt
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: python -m pytest -s -v -n=auto tests/test_evaluator.py
...@@ -50,6 +50,13 @@ setuptools.setup( ...@@ -50,6 +50,13 @@ setuptools.setup(
], ],
extras_require={ extras_require={
"dev": ["black", "flake8", "pre-commit", "pytest", "pytest-cov"], "dev": ["black", "flake8", "pre-commit", "pytest", "pytest-cov"],
"linting": [
"flake8",
"pylint",
"mypy",
"pre-commit",
],
"testing": ["pytest", "pytest-cov", "pytest-xdist"],
"multilingual": ["nagisa>=0.2.7", "jieba>=0.42.1"], "multilingual": ["nagisa>=0.2.7", "jieba>=0.42.1"],
"sentencepiece": ["sentencepiece>=0.1.98", "protobuf>=4.22.1"], "sentencepiece": ["sentencepiece>=0.1.98", "protobuf>=4.22.1"],
"promptsource": [ "promptsource": [
......
...@@ -16,7 +16,7 @@ import pytest ...@@ -16,7 +16,7 @@ import pytest
@pytest.mark.parametrize( @pytest.mark.parametrize(
("task_name,limit,model,model_args"), "task_name,limit,model,model_args",
[ [
( (
["arc_easy"], ["arc_easy"],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment