Skip to content

Commit 13691c5

Browse files
authored
Add Github Actions CI (#1)
1 parent 72bfffe commit 13691c5

File tree

3 files changed

+142
-0
lines changed

3 files changed

+142
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- "*"
6+
pull_request:
7+
branches:
8+
- "*"
9+
10+
jobs:
11+
build:
12+
name: Build (${{ matrix.python-version }}, ${{ matrix.os }})
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: ["ubuntu-latest"]
18+
python-version: ["3.6", "3.7", "3.8"]
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Cache conda
22+
uses: actions/cache@v1
23+
env:
24+
# Increase this value to reset cache if ci/environment.yml has not changed
25+
CACHE_NUMBER: 0
26+
with:
27+
path: ~/conda_pkgs_dir
28+
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('ci/environment.yml') }}
29+
- uses: goanpeca/setup-miniconda@v1
30+
with:
31+
activate-environment: cf_xarray_test # Defined in ci/environment.yml
32+
auto-update-conda: false
33+
python-version: ${{ matrix.python-version }}
34+
environment-file: ci/environment.yml
35+
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
36+
- name: Set up conda environment
37+
shell: bash -l {0}
38+
run: |
39+
python -m pip install -e .
40+
conda list
41+
42+
- name: Run Tests
43+
shell: bash -l {0}
44+
run: |
45+
pytest --cov=./ --cov-report=xml
46+
47+
- name: Upload code coverage to Codecov
48+
uses: codecov/codecov-action@v1
49+
with:
50+
file: ./coverage.xml
51+
flags: unittests
52+
env_vars: OS,PYTHON
53+
name: codecov-umbrella
54+
fail_ci_if_error: false

.github/workflows/linting.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: code-style
2+
3+
on:
4+
push:
5+
branches: "*"
6+
pull_request:
7+
branches: master
8+
9+
10+
11+
jobs:
12+
13+
lint-black:
14+
name: black-formatter
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v1
19+
- name: Set up Python 3.8
20+
uses: actions/setup-python@v1
21+
with:
22+
python-version: 3.8
23+
- name: Install Black
24+
run: |
25+
python -m pip install black
26+
- name: Black Code Formatter
27+
run: |
28+
black --check --line-length 100 --skip-string-normalization .
29+
30+
lint-flake8:
31+
name: flake8
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v1
36+
- name: Set up Python 3.8
37+
uses: actions/setup-python@v1
38+
with:
39+
python-version: 3.8
40+
- name: Install Flake8
41+
run: |
42+
python -m pip install flake8
43+
- name: Flake8 check
44+
run: |
45+
flake8 .
46+
47+
lint-isort:
48+
name: isort
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v1
53+
- name: Set up Python 3.8
54+
uses: actions/setup-python@v1
55+
with:
56+
python-version: 3.8
57+
- name: Install isort
58+
run: |
59+
python -m pip install isort
60+
- name: isort check
61+
run: |
62+
isort --recursive --check-only .

.github/workflows/pypi.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Upload Package to PyPI
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v1
12+
- name: Set up Python
13+
uses: actions/setup-python@v1
14+
with:
15+
python-version: '3.x'
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install setuptools setuptools-scm wheel twine
20+
- name: Build and publish
21+
env:
22+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
23+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
24+
run: |
25+
python setup.py sdist bdist_wheel
26+
twine upload dist/*

0 commit comments

Comments
 (0)