forked from ansys/pyaedt
-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (94 loc) · 3.46 KB
/
unit_tests.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
99
100
101
102
103
104
105
106
107
108
109
# This is a basic workflow to help you get started with Actions
name: CI
env:
python.version: 3.8
python.venv: 'testvenv'
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
tags:
- 'v*'
- v*
pull_request:
branches: [ main ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: Windows
strategy:
matrix:
python-version: [3.8]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: 'Create virtual env'
run: |
python -m venv testenv
testenv\Scripts\Activate.ps1
python -m pip install pip -U
python -m pip install wheel setuptools -U
python -c "import sys; print(sys.executable)"
- name: 'Install pyaedt'
run: |
testenv\Scripts\Activate.ps1
pip install . --use-feature=in-tree-build
pip install -r requirements_test.txt
pip install pytest-azurepipelines
Copy-Item -Path "C:\actions-runner\opengl32.dll" -Destination "testenv\Lib\site-packages\vtkmodules" -Force
mkdir tmp
cd tmp
python -c "import pyaedt; print('Imported pyaedt')"
- name: 'Unit testing'
run: |
testenv\Scripts\Activate.ps1
pytest -v --cov=pyaedt --cov=_unittest --cov-config=.coveragerc -cov-report=xml --cov-report=html --junitxml=junit/test-results.xml _unittest -p no:faulthandler
- name: 'Print Coverage'
run: |
testenv\Scripts\Activate.ps1
coverage xml
- uses: codecov/codecov-action@v2
if: matrix.python-version == '3.8'
name: 'Upload coverage to Codecov'
- name: Upload pytest test results
uses: actions/upload-artifact@v2
with:
name: pytest-results
path: junit/test-results.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- name: Upload pytest coverage results
uses: actions/upload-artifact@v2
with:
name: coverage-results
path: coverage.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
#- name: Publish Unit Test Results
# uses: EnricoMi/publish-unit-test-result-action@v1.19
# if: always()
# with:
# files: junit/test-results.xml
- name: 'Build and validate source distribution'
run: |
testenv\Scripts\Activate.ps1
python setup.py sdist
python -m pip install twine
python -m twine check dist/*
- name: "Builds and uploads to PyPI"
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
run: |
testenv\Scripts\Activate.ps1
python setup.py sdist
python -m pip install twine
python -m twine upload --skip-existing dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}