-
Notifications
You must be signed in to change notification settings - Fork 1
161 lines (141 loc) · 4.65 KB
/
test.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
name: Unit Testing
on:
workflow_call:
inputs:
environment_file:
description: filename of conda env file
required: false
type: string
default: environment.yml
python_versions:
description: string containing a JSON array of versions
required: false
type: string
default: '["3.9"]'
apt_packages:
description: string containing apt package names
required: false
type: string
default: ''
pip_install_args:
description: args to pass to pip install
required: false
type: string
default: ''
path:
type: string
description: Path of package, relative to the repo root
required: false
default: '.'
package_specification:
description: Specification of how to install the package, such as '.[tests]'
required: false
type: string
default: .[tests]
secrets:
WANDB_API_KEY:
required: false
DISCNGINE_API_KEY:
required: false
NOTION_API_TOKEN:
required: false
PERKIN_ELMER_SIGNALS_SANDBOX_BASE_URL:
required: false
PERKIN_ELMER_SIGNALS_SANDBOX_API_KEY:
required: false
GOSTAR_PASSWORD:
required: false
DATAGEN_STAGING_PASSWORD:
required: false
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 20
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJson(inputs.python_versions) }}
steps:
- uses: actions/checkout@v2
- name: Install apt packages
run: sudo apt-get install --yes ${{ inputs.apt_packages }}
- name: Generate RSA SSH keypair
run: ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N ""
- name: Create empty SSH config
run: touch ~/.ssh/config
- name: Install SSH
run: |
sudo apt-get install --yes openssh-server
echo "ListenAddress 127.0.0.1" | sudo tee -a /etc/ssh/sshd_config
sudo cat /etc/ssh/sshd_config
sudo systemctl restart ssh
sudo systemctl status ssh
- name: Add localhost to known_hosts
run: ssh-keyscan -H 127.0.0.1 >> ~/.ssh/known_hosts
- name: Add public key to authorized_keys
run: cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# Configure conda if an environment file is provided
- name: Set up micromamba
if: ${{ inputs.environment_file != '' }}
uses: mamba-org/provision-with-micromamba@v15
with:
cache-downloads: true
cache-downloads-key: "mamba-${{ hashFiles(inputs.environment_file) }}"
environment-file: ./${{ inputs.path }}/${{ inputs.environment_file }}
cache-env: true
environment-name: unit-testing
extra-specs: |
python=${{ matrix.python-version }}
# Configure conda if an environment file is not provided
- name: Set up micromamba
if: ${{ inputs.environment_file == '' }}
uses: mamba-org/provision-with-micromamba@v15
with:
environment-file: false
environment-name: unit-testing
channels: main
cache-env: true
extra-specs: |
python=${{ matrix.python-version }}
- name: Cache pip downloads
uses: actions/cache@v3
with:
path: "~/.cache/pip"
key: "pip-${{ hashFiles('setup.cfg') }}"
restore-keys: |
pip-${{ hashFiles('setup.cfg') }}
pip-
- name: Install package
working-directory: ./${{ inputs.path }}
run: |
python -m pip install ${{ inputs.pip_install_args }} ${{ inputs.package_specification }}
- name: Test with pytest
working-directory: ./${{ inputs.path }}
env:
WANDB_API_KEY: ${{ secrets.WANDB_API_KEY }}
DISCNGINE_API_KEY: ${{ secrets.DISCNGINE_API_KEY }}
NOTION_API_TOKEN: ${{ secrets.NOTION_API_TOKEN }}
PERKIN_ELMER_SIGNALS_BASE_URL: ${{ secrets.PERKIN_ELMER_SIGNALS_SANDBOX_BASE_URL }}
PERKIN_ELMER_SIGNALS_API_KEY: ${{ secrets.PERKIN_ELMER_SIGNALS_SANDBOX_API_KEY }}
GOSTAR_PASSWORD: ${{ secrets.GOSTAR_PASSWORD }}
DATAGEN_STAGING_PASSWORD: ${{ secrets.DATAGEN_STAGING_PASSWORD }}
run: |
python -m pytest --cov-report=xml
- name: Code Coverage
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: ./${{ inputs.path }}/coverage.xml
badge: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '80 100'
- uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage.xml