-
Notifications
You must be signed in to change notification settings - Fork 4
108 lines (105 loc) · 3.78 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
name: Tests
run-name: ${{ github.actor }} is testing the code
# Set the access for individual scopes, or use permissions: write-all
permissions:
pull-requests: write
repository-projects: write
on:
push:
branches: [ master ]
pull_request:
workflow_dispatch:
jobs:
lint:
name: lint and style checks
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Creating conda environment for python 3.12
run: |
conda create -n test -c conda-forge -y python=${{matrix.python-version}} ffmpeg pip cartopy make hdf5 pandoc tox
- name: Install dependencies
run: |
conda run -n test python3 -m pip install -U -e .[tests]
- name: Setup jupyter kernel
run: |
conda run -n test python3 -m ipykernel install --name tintx --display-name "tintX kernel" --env DATA_FILES ${PWD}/docs/source/_static/data --user
conda run -n test python3 -m bash_kernel.install
- name: Linting the code
env:
DATA_FILES: ./docs/source/_static/data
run: |
conda run -n test tox -p -e lint,docs
tests:
name: tintX tests
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
strategy:
max-parallel: 5
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Creating conda environment for python ${{ matrix.python-version }}
run: |
conda create -n test -c conda-forge -y python=${{matrix.python-version}} ffmpeg pip cartopy make hdf5 pandoc tox
- name: Install dependencies
run: |
conda run -n test python3 -m pip install -U -e .[tests]
- name: Setup jupyter kernel
run: |
conda run -n test python3 -m ipykernel install --name tintx --display-name "tintX kernel" --env DATA_FILES ${PWD}/docs/source/_static/data --user
conda run -n test python3 -m bash_kernel.install
- name: Test with pytest
env:
DATA_FILES: ./docs/source/_static/data
run: |
conda run -n test tox -e tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./report.xml
verbose: true
dependabot:
name: Merge PR by dependabot
runs-on: ubuntu-latest
needs: [tests, lint]
# Specifically check that dependabot (or another trusted party) created this pull-request, and that it has been labelled correctly.
if: github.event.pull_request.user.login == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'dependencies')
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve dependabot's PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.TOKEN}}
- name: Auto-merge for dependabot's PR
run: gh pr merge --merge --auto "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.TOKEN}}