-
Notifications
You must be signed in to change notification settings - Fork 51
98 lines (98 loc) · 3.3 KB
/
push_pull.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: CI
on:
workflow_dispatch:
push:
branches:
- '**'
tags-ignore:
- 'v*'
pull_request:
jobs:
linter:
name: Validate code formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check Files Using the Black Formatter
uses: rickstaa/action-black@v1
id: action_black
with:
black_args: "."
- name: Check files Using the Clang Formatter
uses: DoozyX/clang-format-lint-action@v0.12
id: action_clang
with:
source: "memtorch/cpp memtorch/cu"
extensions: "h,cpp,c,cu"
clangFormatVersion: 12
inplace: True
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'push' && github.event.push.head.repo.full_name == github.repository)
id: action_pull_request
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "Enforced Python/C++/CUDA Code Formatting with Black and Clang"
commit-message: ":art: Enforced Python/C++/CUDA Code Formatting with Black and Clang"
body: |
There appear to be some python formatting errors in ${{ github.sha }}. This automatically generated pull request uses the [psf/black](https://github.com/psf/black) and [clang](https://clang.llvm.org/docs/ClangFormat.html) formatters to fix these issues.
base: ${{ github.head_ref }}
branch: actions/lint
unit_test:
name: Run unit tests
needs: linter
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
git submodule update --init --recursive
python -m pip install --upgrade pip
python -m pip install black pytest
python -m pip install -r requirements.txt
python setup.py install
- name: pytest
run: |
pytest
codecov:
name: Determine code coverage
needs: unit_test
runs-on: ubuntu-latest
env:
OS: ${{ matrix.os }}
PYTHON: "3.7"
steps:
- uses: actions/checkout@master
- name: Setup Python 3.7
uses: actions/setup-python@master
with:
python-version: 3.7
- name: Generate Coverage Report
run: |
pip install pytest
pip install codecov
pip install pytest-cov
git submodule update --init --recursive
python -m pip install -r requirements.txt
python setup.py install
pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
files: coverage.xml
directory: ./coverage/reports/
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true
path_to_write_report: ./coverage/codecov_report.txt
verbose: true