-
Notifications
You must be signed in to change notification settings - Fork 11
102 lines (92 loc) · 2.81 KB
/
run-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
# This workflow will install Python dependencies, run tests, lint, and perform static code analysis
# All unit tests found in the tests/ directory are run.
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Run tests
on: push
jobs:
linting-flake8:
name: Lint Python with flake8
runs-on: ubuntu-latest
steps:
- name: Checkout github repo
uses: actions/checkout@v2
- name: Install flake8
run: |
python -m pip install flake8==7.1.0 flake8-docstrings==1.7.0 flake8-annotations==3.1.1
- name: Run lint with flake8
run: |
flake8 src floodresilience
linting-pylint:
name: Lint Python with pylint
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout github repo
uses: actions/checkout@v2
- name: Install package dependencies
uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment.yml
# only cache environment
cache-environment: true
cache-downloads: false
- run: |
conda info
conda list
conda config --show-sources
conda config --show
- name: Install pylint
run: |
python -m pip install pylint==3.2.6
- name: Run lint with pylint
run: |
pylint src floodresilience
unit-tests:
name: Run unit tests with pytest
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout github repo including lfs files
uses: actions/checkout@v2
with:
lfs: true
- name: Install package dependencies
uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment.yml
# only cache environment
cache-environment: true
cache-downloads: false
- run: |
conda info
conda list
conda config --show-sources
conda config --show
- name: Create .env file with API keys
env:
ENV_BASE64: ${{ secrets.ENV_BASE64 }}
run: |
echo import .env file from secrets and regenerate the file
echo $ENV_BASE64 | base64 -d > .env
- name: Run tests with pytest
env:
TEST_DATABASE_INTEGRATION: "false"
run: |
pytest
sonarcloud:
name: Run static-code analysis on SonarCloud
runs-on: ubuntu-latest
steps:
- name: Checkout github repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}