Skip to content

Commit b07d355

Browse files
authored
Create ci.yml
moving to github actions
1 parent 8bff265 commit b07d355

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

.github/workflows/ci.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
python_cache_macOS_path: |
11+
~/Library/Caches/pip
12+
python_cache_windows_path: |
13+
~\AppData\Local\pip\Cache
14+
python_cache_ubuntu_path: |
15+
~/.cache/pip
16+
jobs:
17+
build-and-test:
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [ubuntu-latest, macOS-latest, windows-latest]
22+
python-version: ["3.8", "3.9", "3.10"]
23+
go-module: [utils]
24+
multi-platform:
25+
- ${{ github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }}
26+
exclude:
27+
- os: macOS-latest
28+
multi-platform: false
29+
- os: windows-latest
30+
multi-platform: false
31+
name: Build and test
32+
runs-on: ${{ matrix.os }}
33+
steps:
34+
- uses: actions/checkout@v2
35+
- name: Set up Python ${{ matrix.python-version }}
36+
uses: actions/setup-python@v2
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
- name: Determine dependencies [OS:${{ matrix.os }}, Python:${{ matrix.python-version }}]
40+
# Note
41+
# The below code generates a pip requirements file from the pipenv development requirements (also obtaining the
42+
# normal dependencies from setup.py).
43+
# This code also forces the system to install latest tools as the ones present on the CI system may be too old
44+
# for the process to go through properly.
45+
run: |
46+
python -m pip install --upgrade pip wheel setuptools
47+
python -m pip install flake8 pipenv pytest
48+
python -m pipenv lock --dev -r --pre > dev-requirements.txt
49+
50+
- if: ${{ startsWith(matrix.os, 'macOS') }}
51+
run: echo "CACHE_PATH=${{ env.python_cache_macOS_path }}" >> $GITHUB_ENV
52+
- if: ${{ startsWith(matrix.os, 'windows') }}
53+
run: echo "CACHE_PATH=${{ env.python_cache_windows_path }}" >> $GITHUB_ENV
54+
- if: ${{ startsWith(matrix.os, 'ubuntu') }}
55+
run: echo "CACHE_PATH=${{ env.python_cache_ubuntu_path }}" >> $GITHUB_ENV
56+
- name: Load Python Dependencies from cache
57+
uses: actions/cache@v2
58+
with:
59+
path: |
60+
${{ env.CACHE_PATH }}
61+
~/go/pkg/mod
62+
key: ${{ matrix.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/dev-requirements.txt') }}
63+
restore-keys: |
64+
${{ matrix.os }}-pip-${{ matrix.python-version }}
65+
- name: Install dependencies
66+
# Note
67+
# As a virtual machine is already being used, pipenv
68+
# is superfluous and eliminating pipenv in CI reduces overhead and reduce complexity, while retaining a single
69+
# location for development dependencies.
70+
run: |
71+
python -m pip install -r dev-requirements.txt
72+
python -m pip list
73+
- name: Static Analysis - general (flake8)
74+
run: |
75+
flake8 --count --show-source --statistics
76+
- name: Test with pytest
77+
run: |
78+
pytest
79+
- name: Upload coverage reports to Codecov with GitHub Action
80+
uses: codecov/codecov-action@v2

0 commit comments

Comments
 (0)