Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #18 from allenai/ci-updates
Browse files Browse the repository at this point in the history
Some small improvements to CI
  • Loading branch information
epwalsh authored Apr 17, 2020
2 parents 8f24543 + 28fb219 commit f78e0e8
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 43 deletions.
40 changes: 30 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,61 @@
name: CI

on:
pull_request:
branches:
- master
push:
branches:
- master
schedule:
- cron: '17 10 * * *' # run at 10 AM UTC every day.

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.6', '3.7']

steps:
- uses: actions/checkout@v1

- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.7
python-version: ${{ matrix.python }}

- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: ${{ runner.os }}-pip-${{ matrix.python }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('dev-requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-pip-${{ matrix.python }}
- name: Install requirements
run: |
pip install -r requirements.txt
pip install pytest pytest-cov flake8 black mypy
pip install --upgrade git+https://github.com/allenai/allennlp.git@master
pip install --upgrade -r <(grep -Ev '^allennlp$' requirements.txt)
pip install --upgrade -r dev-requirements.txt
- name: Show pip freeze
run: |
pip freeze
- name: Lint
run: |
flake8 -v
black -v --check .
make lint
- name: Type check
run: |
mypy allennlp_models --ignore-missing-imports --no-strict-optional --no-site-packages
make typecheck
- name: Run tests
run: |
pytest --cov=allennlp_models/ --cov-report=xml
make test-with-cov
- name: Upload coverage to Codecov
if: matrix.python == '3.7'
uses: codecov/[email protected]
with:
token: da233513-af22-4b18-a7c4-e70467fc05e3
token: ${{ secrets.CODECOV_TOKEN }}
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: PyPI Release

on:
release:
types: [published]

jobs:
deploy:
needs: build
if: github.repository == 'allenai/allennlp-models'

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Install requirements
run: |
pip install -e .
pip install -r dev-requirements.txt
- name: Lint
run: |
make lint
- name: Type check
run: |
make typecheck
- name: Run tests
run: |
make test
- name: Build Package
run: |
python setup.py bdist_wheel sdist
- name: Upload to PyPI
env:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload -u $PYPI_USERNAME -p $PYPI_PASSWORD dist/*
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.PHONY : lint
lint :
flake8 -v
black -v --check .

.PHONY : typecheck
typecheck :
mypy allennlp_models --ignore-missing-imports --no-strict-optional --no-site-packages

.PHONY : test
test :
pytest -v --color=yes

.PHONY : test-with-cov
test-with-cov :
pytest -v --color=yes --cov=allennlp_models/ --cov-report=xml
17 changes: 2 additions & 15 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
flake8

# Static type checking
mypy==0.761
mypy==0.770

# Automatic code formatting
black

# For creating git precommit hooks
pre-commit==2.1.1
pre-commit==2.2.0

# Allows generation of coverage reports with pytest.
pytest-cov
Expand All @@ -19,19 +19,6 @@ pytest-cov
coverage
codecov

# Required to run sanic tests
aiohttp

#### DOC-RELATED PACKAGES ####

# YAML manipulation
ruamel.yaml

mathy_pydoc>=0.6.7,<0.7.0
markdown-include==0.5.1
# Package for the material theme for mkdocs
mkdocs-material==4.6.3

#### PACKAGE-UPLOAD PACKAGES ####

# Pypi uploads
Expand Down
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# To be changed to allennlp>=1.0 once that's released.
git+https://github.com/allenai/allennlp.git@6056f1a12110990ae21fe4b62bf106d388e5d149

allennlp
# For RC models
word2number>=1.1
py-rouge==1.1
Expand Down
17 changes: 2 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,9 @@
# cross-library integration testing.
with open("requirements.txt") as requirements_file:
install_requirements = requirements_file.readlines()
install_requirements = [
r for r in install_requirements if "git+https://github.com/allenai/allennlp" not in r
]
install_requirements = [r for r in install_requirements if r != "allennlp"]
if not os.environ.get("EXCLUDE_ALLENNLP_IN_SETUP"):
# Warning: This will not give you the desired version if you've already
# installed allennlp! See https://github.com/pypa/pip/issues/5898.
#
# There used to be an alternative to this using `dependency_links`
# (https://stackoverflow.com/questions/3472430), but pip decided to
# remove this in version 19 breaking numerous projects in the process.
# See https://github.com/pypa/pip/issues/6162.
#
# As a mitigation, run `pip uninstall allennlp` before installing this
# package.
sha = "6056f1a12110990ae21fe4b62bf106d388e5d149"
requirement = f"allennlp @ git+https://github.com/allenai/allennlp@{sha}#egg=allennlp"
requirement = f"allennlp=={VERSION['VERSION']}"
install_requirements.append(requirement)

# make pytest-runner a conditional requirement,
Expand Down

0 comments on commit f78e0e8

Please sign in to comment.