-
Notifications
You must be signed in to change notification settings - Fork 6
162 lines (158 loc) · 5.62 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# run test suites
name: Tests
on:
- pull_request
- push
- release
- workflow_dispatch
jobs:
# see: https://github.com/fkirc/skip-duplicate-actions
skip_duplicate:
continue-on-error: true
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip && ! contains(github.ref, 'refs/tags') }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: "same_content"
skip_after_successful_duplicate: "true"
do_not_skip: '["pull_request", "workflow_dispatch", "schedule", "release"]'
# see: https://github.com/actions/setup-python
tests:
# FIXME: https://github.com/fkirc/skip-duplicate-actions/issues/90
# disable for now because the tests never run... somehow similar config works in Magpie...
# needs: skip_duplicate
# if: ${{ needs.skip_duplicate.outputs.should_skip != 'true' }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.allow-failure }}
env:
# override make command to install directly in active python
CONDA_CMD: ""
DOCKER_TEST_EXEC_ARGS: "-T"
services:
# Label used to access the service container
mongodb:
image: mongo:5.0 # DockerHub
ports:
- "27017:27017"
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.7", "3.8", "3.9", "3.10"]
allow-failure: [false]
test-case: [test-unit-only, test-func-only]
include:
# experimental python
- os: ubuntu-latest
python-version: "3.11"
allow-failure: true
test-case: test-unit-only
- os: ubuntu-latest
python-version: "3.11"
allow-failure: true
test-case: test-func-only
# linter tests
- os: ubuntu-latest
python-version: "3.10"
allow-failure: false
test-case: check-all
# documentation build
- os: ubuntu-latest
python-version: "3.10"
allow-failure: false
test-case: docs
# coverage test
- os: ubuntu-latest
python-version: "3.10"
allow-failure: false
test-case: test-coverage-only
# smoke test of Docker image
- os: ubuntu-latest
python-version: "3.10" # doesn't matter which one (in docker), but match default of repo
allow-failure: false
test-case: test-docker
# EMS end-2-end Workflow tests
- os: ubuntu-latest
python-version: "3.10"
allow-failure: true
test-case: test-workflow-only
steps:
- uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: Setup Python
# skip python setup if running with docker
if: ${{ matrix.test-case != 'test-docker' }}
uses: actions/setup-python@v2
with:
python-version: "${{ matrix.python-version }}"
- name: Parse Python Version
id: python-semver
run: |
echo "::set-output name=major:$(echo ${{ matrix.python-version }} | cut -d '.' -f 1)"
echo "::set-output name=minor:$(echo ${{ matrix.python-version }} | cut -d '.' -f 2)"
- uses: actions/cache@v3
name: Check Proj Lib Pre-Built in Cache
id: cache-proj
with:
# note: '22' is v8, '21' is v7
path: /tmp/proj-8.2.1/install
key: ${{ runner.os }}-python${{ matrix.python-version }}-proj
- name: Install Dependencies
# skip python setup if running with docker
if: ${{ matrix.test-case != 'test-docker' }}
# install package and dependencies directly,
# skip sys/conda setup to use active python
run: make install-sys install-pkg install-pip install-raw install-dev version
- name: Display Packages
# skip python setup if running with docker
if: ${{ matrix.test-case != 'test-docker' }}
run: pip freeze
#- name: Setup Environment Variables
# uses: c-py/action-dotenv-to-setenv@v2
# with:
# env-file: ./ci/weaver.env
- name: Display Environment Variables
run: |
hash -r
env | sort
- name: Run Tests
run: make stop ${{ matrix.test-case }}
- name: Upload coverage report
uses: codecov/codecov-action@v2
if: ${{ success() && matrix.test-case == 'test-coverage-only' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./reports/coverage.xml
fail_ci_if_error: true
verbose: true
deploy-docker:
needs: tests
if: ${{ success() && (contains(github.ref, 'refs/tags') || github.ref == 'refs/heads/master') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: Get Tag Version
id: version
shell: bash
run: |
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then
echo "::set-output name=TAG_VERSION::latest"
else
echo "::set-output name=TAG_VERSION::${GITHUB_REF##*/}"
fi
- name: Build Docker
run: |
make DOCKER_REPO=pavics/weaver APP_VERSION=${{ steps.version.outputs.TAG_VERSION }} docker-info docker-build
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push to DockerHub
run: |
make DOCKER_REPO=pavics/weaver APP_VERSION=${{ steps.version.outputs.TAG_VERSION }} docker-push