Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

EthicML CI

EthicML CI #1292

name: EthicML CI
on:
pull_request:
branches:
- main
paths-ignore:
- 'docs/**'
- 'examples/**'
- '**/*.md'
- .github/dependabot.yml
- .github/release.yml
- .github/workflows/docs.yml
- .github/workflows/dummy_ci.yml
- .github/workflows/dependabot_auto.yml
- .github/workflows/labeler.yml
- .gitignore
- CODEOWNERS
- LICENSE
- make_release.sh
- CITATION.cff
merge_group:
jobs:
lint_with_ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install ruff
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Lint with ruff
run: |
ruff check --format=github ethicml
- name: Lint with ruff
run: |
ruff check --format=github tests
format_with_black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install black
run: |
python -m pip install --upgrade pip
pip install 'black<=23'
- name: Format with black
run: |
python -m black --check -l 100 -t py38 -S ethicml/
python -m black --check -l 100 -t py38 -S tests/
check_docstrings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r docs/requirements.txt
- name: Install pandoc
run: sudo apt-get install -y pandoc
- name: Build with sphinx
run: |
sphinx-build -W -b html ./docs ./docs/_build
check_with_darglint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install darglint
run: |
python -m pip install --upgrade pip
pip install darglint
- name: Check with darglint
run: |
sh run_darglint.sh
test_minimal_dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dependencies
run: |
poetry env use 3.8
poetry install --no-interaction --no-root --without dev
- name: Test import
run: |
poetry run python -c "import ethicml"
test_full_dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: '3.8'
cache: 'poetry'
- name: Install dependencies
run: |
# keep the following in sync with `test_with_pytest`!
poetry env use 3.8
poetry install --no-interaction --no-root -E all --with ci --with torchcpu
- name: Test import
run: |
poetry run python -c "import ethicml"
test_with_pytest:
needs: [lint_with_ruff, format_with_black, check_docstrings, check_with_darglint, test_minimal_dependencies, test_full_dependencies]
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# --- check-out repo and set-up python ---
#----------------------------------------------
- uses: actions/checkout@v3
- name: Install poetry
if: ${{ github.event_name == 'merge_group' }}
run: pipx install poetry
- uses: actions/setup-python@v4
if: ${{ github.event_name == 'merge_group' }}
with:
python-version: '3.8'
cache: 'poetry'
#----------------------------------------------
# --------- install dependencies --------
#----------------------------------------------
- name: Install dependencies
if: ${{ github.event_name == 'merge_group' }}
run: |
# keep the following in sync with `test_full_dependencies`!
poetry env use 3.8
poetry install --no-interaction --no-root -E all --with ci --with torchcpu
#----------------------------------------------
# ----- Run MyPy -----
#----------------------------------------------
- name: Type check with mypy
if: ${{ github.event_name == 'merge_group' }}
run: |
poetry run mypy ethicml
poetry run mypy --warn-unused-ignores ethicml || true
#----------------------------------------------
# ----- Run MyPy on tests -----
#----------------------------------------------
- name: Type check tests with mypy
if: ${{ github.event_name == 'merge_group' }}
run: |
poetry run mypy tests
poetry run mypy --warn-unused-ignores tests || true
#----------------------------------------------
# ----- Run Tests -----
#----------------------------------------------
- name: Test with pytest
if: ${{ github.event_name == 'merge_group' }}
run: |
poetry run python -m pytest -vv -n 2 --dist loadgroup --cov=ethicml --cov-fail-under=80 tests/