generated from sensein/python-package-template
-
Notifications
You must be signed in to change notification settings - Fork 3
149 lines (144 loc) · 4.7 KB
/
e2c-runner-tests-310.yaml
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
name: e2c-runner-tests-310
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
jobs:
start-runner:
if: github.event.pull_request.draft == false && contains(github.event.pull_request.labels.*.name, 'to-test-gpu')
name: start-runner
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
job-ran: ${{ steps.set-ran.outputs.ran }}
steps:
- id: set-ran
run: echo "::set-output name=ran::true"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_KEY_SECRET }}
aws-region: ${{ vars.AWS_REGION }}
- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.GH_TOKEN }}
ec2-image-id: ${{ vars.AWS_IMAGE_ID }}
ec2-instance-type: ${{ vars.AWS_INSTANCE_TYPE }}
subnet-id: ${{ vars.AWS_SUBNET }}
security-group-id: ${{ vars.AWS_SECURITY_GROUP }}
ubuntu-tests-310:
name: ubuntu-tests-310
needs: start-runner
runs-on: ${{ needs.start-runner.outputs.label }}
defaults:
run:
shell: bash
working-directory: ${{ vars.WORKING_DIR }}
strategy:
matrix:
python-version: ['3.10']
env:
WORKING_DIR: ${{ vars.WORKING_DIR }}
POETRY_CACHE_DIR: ${{ vars.WORKING_DIR }}
outputs:
job-ran: ${{ steps.set-ran.outputs.ran }}
steps:
- id: set-ran
run: echo "::set-output name=ran::true"
- uses: actions/checkout@v4
with:
fetch-depth: 1 # no need for the history
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install ffmpeg (Ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get update && sudo apt-get install -y ffmpeg
shell: bash
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1
virtualenvs-create: true
virtualenvs-in-project: true
- name: Check available space
run: |
df -h
shell: bash
- name: Echo python info
run: |
python --version
which python
shell: bash
- name: Copy senselab directory to current directory
run: |
cp -r /actions-runner/_work/senselab/senselab .
- name: Install dependencies with Poetry
run: |
cd senselab
poetry env use ${{ matrix.python-version }}
poetry run pip install iso-639
poetry install --with dev
shell: bash
- name: Check poetry info
run: |
cd senselab
poetry env info
poetry --version
shell: bash
- name: Check NVIDIA SMI details
run: |
cd senselab
poetry run nvidia-smi
poetry run nvidia-smi -L
poetry run nvidia-smi -q -d Memory
shell: bash
- name: Prepare cache folder for pytest
run: mkdir -p $WORKING_DIR/pytest/temp
shell: bash
- name: Run unit tests
id: run-tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: >
cd senselab && poetry run pytest \
--rootdir=$WORKING_DIR/pytest \
--basetemp=$WORKING_DIR/pytest/temp \
--junitxml=pytest.xml \
--cov-report=term-missing:skip-covered \
--cov-report=xml:coverage.xml \
--cov=src src/tests \
--log-level=DEBUG \
--verbose
shell: bash
stop-runner:
name: stop-runner
needs:
- start-runner # waits for the EC2 instance to be created
- ubuntu-tests-310 # waits for the actual job to finish
runs-on: ubuntu-latest
if: ${{ needs.start-runner.outputs.job-ran == 'true' && needs.ubuntu-tests-310.outputs.job-ran == 'true' || failure() }} # required to stop the runner even if an error occurred in previous jobs
steps:
- name: Check available space
run: |
df -h
shell: bash
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_KEY_SECRET }}
aws-region: ${{ vars.AWS_REGION }}
- name: Stop EC2 runner
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GH_TOKEN }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}