1+ name : pytest
2+ on :
3+ # Trigger the workflow on push or pull request,
4+ # but only for the master branch
5+ push :
6+ branches :
7+ - master
8+ pull_request :
9+ branches :
10+ - master
11+ jobs :
12+ run :
13+ name : Run unit tests with codecov upload
14+ runs-on : ${{ matrix.os }}
15+ env :
16+ USING_COVERAGE : ' 3.7'
17+ strategy :
18+ matrix :
19+ os : [ubuntu-latest, macos-latest, windows-latest]
20+ python-version : [3.5, 3.6, 3.7]
21+ steps :
22+ - uses : actions/checkout@master
23+
24+ - name : Setup Python
25+ uses : actions/setup-python@master
26+ with :
27+ python-version : ${{ matrix.python-version }}
28+
29+ # https://github.com/actions/virtual-environments/issues/294
30+ - name : Configure path to rc.exe for Python 3.5
31+ run : |
32+ function Invoke-VSDevEnvironment {
33+ $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
34+ $installationPath = & $vswhere -prerelease -legacy -latest -property installationPath
35+ $Command = Join-Path $installationPath "Common7\Tools\vsdevcmd.bat"
36+ & "${env:COMSPEC}" /s /c "`"$Command`" -no_logo && set" | Foreach-Object {
37+ if ($_ -match '^([^=]+)=(.*)') {
38+ [System.Environment]::SetEnvironmentVariable($matches[1], $matches[2])
39+ }
40+ }
41+ }
42+ Invoke-VSDevEnvironment
43+ Get-Command rc.exe | Format-Table -AutoSize
44+ if : matrix.os == 'windows-latest' && matrix.python-version == '3.5'
45+
46+ - name : Install dependencies
47+ run : |
48+ pip3 install --upgrade pip
49+ pip3 install --upgrade setuptools
50+ pip3 install --upgrade wheel
51+ pip3 install pyflakes
52+ pip3 install -r tests/test_requirements.txt
53+ pip3 install -e .
54+
55+ - name : Static code checking with pyflakes
56+ run : |
57+ pyflakes mkdocs_git_revision_date_localized_plugin
58+
59+ - name : Generate coverage report
60+ run : |
61+ git config --global user.name "Github Action"
62+ git config --global user.email "githubaction@gmail.com"
63+ pytest --cov=mkdocs_git_revision_date_localized_plugin --cov-report=xml
64+
65+ - name : Upload coverage to Codecov
66+ if : " contains(env.USING_COVERAGE, matrix.python-version)"
67+ uses : codecov/codecov-action@v1
68+ with :
69+ token : ${{ secrets.CODECOV_TOKEN }}
70+ file : ./coverage.xml
71+ flags : unittests
72+ fail_ci_if_error : true
0 commit comments