-
Notifications
You must be signed in to change notification settings - Fork 7
131 lines (113 loc) · 4.19 KB
/
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#.github/workflows/tests.yaml
name: Unit Tests
on:
pull_request:
branches:
- master
push:
branches:
- '**' # Every branch
env:
USER: "github_runner"
HOME: "/tmp"
jobs:
tests:
if: github.repository_owner == 'metno'
strategy:
fail-fast: true
matrix:
os: [ "ubuntu-latest" ]
env: [ "pytest" ]
python-version: [ "3.9" ]
name: "${{ matrix.os }}, python=${{ matrix.python-version }}"
runs-on: ${{ matrix.os }}
container:
image: python:${{ matrix.python-version }}-bullseye
env:
COVERAGE_FILE: ".coverage.${{ matrix.env }}.${{ matrix.python-version }}"
steps:
#----------------------------------------------
# check-out repo
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
#----------------------------------------------
# add matrix specifics
#----------------------------------------------
- name: Install system gdal libs
run: |
apt-get update
apt-get install -y gdal-bin libgdal-dev
- name: Install pygdal
run: |
pip install pygdal=="`gdal-config --version`.*"
- name: Install other pysurfex dependencies
run: |
apt-get update
apt-get install -y libeccodes-dev libproj-dev libudunits2-dev
#----------------------------------------------
# --- configure poetry & install project ----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv (if cache exists)
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
- name: Install dependencies (if venv cache is not found)
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SECRET_REPO_DEPLOY_KEY }}
run: poetry install --no-interaction --no-root --only main,test
- name: Install the project itself
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SECRET_REPO_DEPLOY_KEY }}
run: poetry install --no-interaction --only-root
#----------------------------------------------
# run test suite and report coverage
#----------------------------------------------
- name: Run tests
run: |
poetry run pytest
#- name: Upload test coverage report to Codecov
# uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# files: ./.coverage.xml
- name: Coveralls
if: ${{ matrix.python-version == 3.8 }}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
export COVERALLS_REPO_TOKEN=${{secrets.COVERALLS_REPO_TOKEN}}
poetry run coveralls
- name: Create documentation
if: ${{ matrix.python-version == 3.8 }}
run: |
poetry run sphinx-build . docs/build/html
- name: Commit documentation changes
if: ${{ matrix.python-version == 3.8 && github.event_name != 'pull_request' }}
run: |
git clone https://github.com/metno/pysurfex-experiment.git --branch gh-pages --single-branch gh-pages
cp -r docs/build/html/* gh-pages/
cd gh-pages
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Update documentation" -a || true
# The above command will fail if no changes were present, so we ignore
# the return code.
- name: Push changes
if: ${{ matrix.python-version == 3.8 && github.event_name != 'pull_request' }}
uses: ad-m/github-push-action@master
with:
branch: gh-pages
directory: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}