Skip to content

Commit 4eeade5

Browse files
per1234aentinger
authored andcommitted
Add GitHub Actions workflow to run Python unit tests
Run unit tests on every PR and push. I modified one of the unit tests to make it use the absolute path to the test data rather than the relative path. The reason is to avoid having to add an extra line to the workflow file to cd to the test folder.
1 parent 195103f commit 4eeade5

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: libraries/report-size-deltas workflow
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
13+
- name: Set up Python
14+
uses: actions/setup-python@v1
15+
with:
16+
python-version: '3.8.2'
17+
18+
- name: Run Python unit tests
19+
run: |
20+
export PYTHONPATH="$GITHUB_WORKSPACE/libraries/report-size-deltas"
21+
python -m unittest discover "$GITHUB_WORKSPACE/libraries/report-size-deltas/tests"

tests/test_reportsizedeltas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def test_generate_report(self):
196196

197197
artifact_folder_object = tempfile.TemporaryDirectory(prefix="test_reportsizedeltas-")
198198
try:
199-
distutils.dir_util.copy_tree(src="data/size-deltas-reports", dst=artifact_folder_object.name)
199+
distutils.dir_util.copy_tree(src=os.path.dirname(os.path.realpath(__file__)) + "/data/size-deltas-reports", dst=artifact_folder_object.name)
200200
except Exception:
201201
artifact_folder_object.cleanup()
202202
raise

0 commit comments

Comments
 (0)