-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Upload code coverage reports from different jobs, other CI improvements #5257
Changes from 25 commits
2dd08e5
bcf6d14
0eff433
ce89f91
72c1480
3f4e494
153e808
aa4b9de
7172c25
397fb92
5dade5e
d302106
ff1567e
b70a6ed
6ce7db6
abade23
805ddf8
8a45209
c9a386e
d34b3bb
639e7df
686c015
dbb74f6
f020fc8
05f8be0
8d79df3
5dac90f
a54b023
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,45 +31,42 @@ jobs: | |
# file with notes on your contribution. | ||
git diff --name-only $(git merge-base origin/main HEAD) | grep '^CHANGELOG.md$' && echo "Thanks for helping keep our CHANGELOG up-to-date!" | ||
|
||
gpu_checks: | ||
name: GPU Checks | ||
if: github.repository == 'allenai/allennlp' # self-hosted runner only available on main repo | ||
timeout-minutes: 15 | ||
runs-on: [self-hosted, GPU] | ||
style: | ||
name: Style | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set Docker tag | ||
- name: Setup Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install requirements | ||
run: | | ||
if [[ $GITHUB_EVENT_NAME == 'release' ]]; then | ||
echo "DOCKER_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV; | ||
else | ||
echo "DOCKER_TAG=$GITHUB_SHA" >> $GITHUB_ENV; | ||
fi | ||
grep -E '^black' dev-requirements.txt | xargs pip install | ||
|
||
- name: Build test image | ||
- name: Debug info | ||
run: | | ||
make docker-test-image DOCKER_TAG=$DOCKER_TAG | ||
pip freeze | ||
|
||
- name: Run GPU tests | ||
- name: Run black | ||
if: '! cancelled()' | ||
run: | | ||
make docker-test-run DOCKER_TAG=$DOCKER_TAG ARGS='gpu-test' | ||
black --check . | ||
|
||
check_core: | ||
name: Check Core | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python: ['3.7', '3.8'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
python-version: 3.8 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
|
@@ -84,36 +81,65 @@ jobs: | |
run: | | ||
pip freeze | ||
|
||
- name: Format | ||
- name: Run flake8 | ||
if: '! cancelled()' | ||
run: | | ||
make format | ||
flake8 . | ||
|
||
- name: Lint | ||
- name: Run mypy | ||
if: '! cancelled()' | ||
run: | | ||
make lint | ||
mypy . --cache-dir=/dev/null | ||
|
||
- name: Type check | ||
if: '! cancelled()' | ||
gpu_tests: | ||
name: GPU Tests | ||
if: github.repository == 'allenai/allennlp' # self-hosted runner only available on main repo | ||
timeout-minutes: 15 | ||
runs-on: [self-hosted, GPU] | ||
env: | ||
# Required to use the setup-python action. | ||
AGENT_TOOLSDIRECTORY: '/opt/hostedtoolcache' | ||
# Our self-hosted runner currently is currently compatible with CUDA 11.*. | ||
TORCH_VERSION: 'torch==1.8.1+cu111 torchvision==0.9.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html' | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
env: | ||
# Log useful debugging information. | ||
ACTIONS_STEP_DEBUG: 'true' | ||
with: | ||
python-version: 3.8 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ runner.os }}-pydeps-${{ env.pythonLocation }}-${{ env.TORCH_VERSION }}-${{ hashFiles('setup.py') }}-${{ hashFiles('dev-requirements.txt') }} | ||
|
||
- name: Install requirements | ||
run: | | ||
make typecheck | ||
make install | ||
|
||
- name: Debug info | ||
run: | | ||
which python | ||
python --version | ||
pip freeze | ||
|
||
- name: Run tests | ||
if: '! cancelled()' | ||
run: | | ||
make test-with-cov | ||
make gpu-test | ||
mkdir coverage | ||
mv coverage.xml coverage/ | ||
|
||
- name: Upload coverage to Codecov | ||
if: matrix.python == '3.7' && github.repository == 'allenai/allennlp' && (github.event_name == 'push' || github.event_name == 'pull_request') | ||
uses: codecov/codecov-action@v1 | ||
- name: Save coverage report | ||
if: github.repository == 'allenai/allennlp' && (github.event_name == 'push' || github.event_name == 'pull_request') | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
file: ./coverage.xml | ||
# Ignore codecov failures as the codecov server is not | ||
# very reliable but we don't want to report a failure | ||
# in the github UI just because the coverage report failed to | ||
# be published. | ||
fail_ci_if_error: false | ||
name: gpu-tests-coverage | ||
path: ./coverage | ||
|
||
- name: Clean up | ||
if: always() | ||
|
@@ -122,8 +148,8 @@ jobs: | |
# See https://github.com/pypa/pip/issues/4537. | ||
pip uninstall --yes allennlp | ||
|
||
check_models: | ||
name: Check Models | ||
cpu_tests: | ||
name: CPU Tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
|
@@ -150,6 +176,52 @@ jobs: | |
run: | | ||
pip freeze | ||
|
||
- name: Run tests | ||
if: '! cancelled()' | ||
run: | | ||
make test | ||
mkdir coverage | ||
mv coverage.xml coverage/ | ||
|
||
- name: Save coverage report | ||
if: matrix.python == '3.7' && github.repository == 'allenai/allennlp' && (github.event_name == 'push' || github.event_name == 'pull_request') | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: cpu-tests-coverage | ||
path: ./coverage | ||
|
||
- name: Clean up | ||
if: always() | ||
run: | | ||
# Could run into issues with the cache if we don't uninstall the editable. | ||
# See https://github.com/pypa/pip/issues/4537. | ||
pip uninstall --yes allennlp | ||
|
||
model_tests: | ||
name: Model Tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.8 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ runner.os }}-pydeps-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('dev-requirements.txt') }} | ||
|
||
- name: Install requirements | ||
run: | | ||
make install | ||
|
||
- name: Debug info | ||
run: | | ||
pip freeze | ||
|
||
- name: Pull and install models repo | ||
env: | ||
ALLENNLP_VERSION_OVERRIDE: "" # Don't replace the core library. | ||
|
@@ -158,15 +230,70 @@ jobs: | |
cd allennlp-models | ||
pip install --upgrade --upgrade-strategy eager -e . -r dev-requirements.txt | ||
|
||
- name: Run models tests | ||
- name: Run tests | ||
run: | | ||
cd allennlp-models && make test | ||
cd allennlp-models | ||
make test-with-cov COV=allennlp | ||
mkdir coverage | ||
mv coverage.xml coverage/ | ||
|
||
- name: Save coverage report | ||
if: matrix.python == '3.7' && github.repository == 'allenai/allennlp' && (github.event_name == 'push' || github.event_name == 'pull_request') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we fix 3.7 here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, this was needed when these tests ran on multiple versions of Python, because we only needed one coverage report from this job. |
||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: model-tests-coverage | ||
path: allennlp-models/coverage | ||
|
||
- name: Clean up | ||
if: always() | ||
run: | | ||
pip uninstall --yes allennlp allennlp-models | ||
|
||
upload_coverage: | ||
name: Upload Coverage Report | ||
if: github.repository == 'allenai/allennlp' && (github.event_name == 'push' || github.event_name == 'pull_request') | ||
runs-on: ubuntu-latest | ||
needs: [cpu_tests, gpu_tests, model_tests] | ||
|
||
steps: | ||
# Need to checkout code to get the coverage config. | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Download coverage report from CPU tests | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: cpu-tests-coverage | ||
path: coverage/cpu_tests | ||
|
||
- name: Download coverage report from GPU Tests | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: gpu-tests-coverage | ||
path: coverage/gpu_tests | ||
|
||
- name: Download coverage report from model tests | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: model-tests-coverage | ||
path: coverage/model_tests | ||
|
||
- name: Debug info | ||
run: | | ||
ls -lh coverage | ||
ls -lh coverage/cpu_tests | ||
ls -lh coverage/gpu_tests | ||
ls -lh coverage/model_tests | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not, I'll take out. |
||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
files: coverage/cpu_tests/coverage.xml,coverage/gpu_tests/coverage.xml,coverage/model_tests/coverage.xml | ||
# Ignore codecov failures as the codecov server is not | ||
# very reliable but we don't want to report a failure | ||
# in the github UI just because the coverage report failed to | ||
# be published. | ||
fail_ci_if_error: false | ||
|
||
# Builds package distribution files for PyPI. | ||
build_package: | ||
name: Build Package | ||
|
@@ -481,7 +608,7 @@ jobs: | |
# Publish the core distribution files to PyPI. | ||
publish: | ||
name: PyPI | ||
needs: [check_core, check_models, gpu_checks, build_package, test_package, docker, docs] | ||
needs: [style, lint, cpu_tests, gpu_tests, model_tests, build_package, test_package, docker, docs] | ||
# Only publish to PyPI on releases and nightly builds to "allenai/allennlp" (not forks). | ||
if: github.repository == 'allenai/allennlp' && (github.event_name == 'release' || github.event_name == 'schedule') | ||
runs-on: ubuntu-latest | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this check necessary? Doesn't it always cancel all the checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed, it was only need when this check was in the other workflow that had a lot of different steps. And then it survived the copy-paste.