Skip to content

Commit 94c7ccc

Browse files
committed
Extend unit tests to cover more python versions
Also include a hack for python 3.5 on windows
1 parent 790a9cc commit 94c7ccc

File tree

4 files changed

+129
-33
lines changed

4 files changed

+129
-33
lines changed

.github/workflows/unittests.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Unit tests
2+
on: [pull_request]
3+
jobs:
4+
run:
5+
name: Run unit tests with codecov upload
6+
runs-on: ${{ matrix.os }}
7+
env:
8+
USING_COVERAGE: '3.7'
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest, macos-latest, windows-latest]
12+
python-version: [3.5, 3.6, 3.7]
13+
steps:
14+
- uses: actions/checkout@master
15+
16+
- name: Setup Python
17+
uses: actions/setup-python@master
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
21+
# https://github.com/actions/virtual-environments/issues/294
22+
- name: Configure path to rc.exe for Python 3.5
23+
run: |
24+
function Invoke-VSDevEnvironment {
25+
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
26+
$installationPath = & $vswhere -prerelease -legacy -latest -property installationPath
27+
$Command = Join-Path $installationPath "Common7\Tools\vsdevcmd.bat"
28+
& "${env:COMSPEC}" /s /c "`"$Command`" -no_logo && set" | Foreach-Object {
29+
if ($_ -match '^([^=]+)=(.*)') {
30+
[System.Environment]::SetEnvironmentVariable($matches[1], $matches[2])
31+
}
32+
}
33+
}
34+
Invoke-VSDevEnvironment
35+
Get-Command rc.exe | Format-Table -AutoSize
36+
if: matrix.os == 'windows-latest' && matrix.python-version == '3.5'
37+
38+
- name: Install dependencies
39+
run: |
40+
pip3 install --upgrade pip
41+
pip3 install --upgrade setuptools
42+
pip3 install --upgrade wheel
43+
pip3 install pyflakes
44+
pip3 install -r tests/test_requirements.txt
45+
pip3 install -e .
46+
47+
- name: Static code checking with pyflakes
48+
run: |
49+
pyflakes mkdocs_git_revision_date_localized_plugin
50+
51+
- name: Run unit tests
52+
run: |
53+
git config --global user.name "Github Action"
54+
git config --global user.email "githubaction@gmail.com"
55+
pytest --cov=mkdocs_git_revision_date_localized_plugin --cov-report=xml
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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

.github/workflows/workflow.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

mkdocs_git_revision_date_localized_plugin/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def get_revision_date_for_file(
9292
logging.warning(
9393
"Unable to read git logs of '%s'."
9494
" Is git log readable?"
95-
" Option 'fallback_to_build_date' enabled: so keep building..." % path
95+
" Option 'fallback_to_build_date' enabled: so keep building..."
96+
% path
9697
)
9798
else:
9899
logging.error(

0 commit comments

Comments
 (0)