-
Notifications
You must be signed in to change notification settings - Fork 62
175 lines (174 loc) · 7.8 KB
/
pytest.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
163
164
165
166
167
168
169
170
171
172
173
174
175
name: pytest
on:
push:
branches: [ main ]
# Publish semver tags as releases.
tags: [ '*.*.*' ]
pull_request:
pull_request_target:
types: [labeled]
env:
SKYPLANE_USAGE_STATS_ENABLED: 0
jobs:
black-pytype:
# do not run on pull_request_target since it should be triggered by pull_request
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install poetry
run: pipx install poetry
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "poetry"
- name: Set Poetry config
run: |
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs
- name: Install Dependencies
run: |
poetry install -E gateway -E solver -E aws -E azure -E gcp -E ibm
poetry run pip install -r requirements-dev.txt
if: steps.cache.outputs.cache-hit != 'true'
- name: black
run: poetry run black . --check --line-length=140
- name: pytype
run: poetry run pytype --config .pytype.cfg -j 2
test-unit:
# do not run on pull_request_target since it should be triggered by pull_request
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request')
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v1
- name: Install poetry
run: pipx install poetry
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "poetry"
- name: Set Poetry config
run: |
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs
- name: Install Dependencies
run: |
poetry install -E gateway -E solver -E aws -E azure -E gcp -E ibm
poetry run pip install -r requirements-dev.txt
if: steps.cache.outputs.cache-hit != 'true'
- name: Run unit tests
run: |
poetry run skyplane init -y --disable-config-aws --disable-config-azure --disable-config-gcp --disable-config-ibm --disable-config-cloudflare
poetry run skyplane config set usage_stats false
poetry run pytest -s tests/unit_nocloud
test-aws:
# run if push to main or pull request by contributor or pull request target with label 'safe to test' (to avoid running on forks)
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'safe to test'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install poetry
run: pipx install poetry
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "poetry"
- name: Set Poetry config
run: |
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs
- name: Install Dependencies
run: |
poetry install -E gateway -E solver -E aws -E azure -E gcp -E ibm
poetry run pip install -r requirements-dev.txt
if: steps.cache.outputs.cache-hit != 'true'
- name: Run cloud tests
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
run: |
poetry run skyplane init -y --disable-config-azure --disable-config-gcp --disable-config-ibm --disable-config-cloudflare
poetry run skyplane config set usage_stats false
poetry run pytest -s tests/unit_aws
test-azure:
# run if push to main or pull request by contributor or pull request target with label 'safe to test' (to avoid running on forks)
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'safe to test'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install poetry
run: pipx install poetry
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "poetry"
- name: Set Poetry config
run: |
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs
- name: Log into Azure
uses: azure/login@v1
with:
creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}'
- name: Install Dependencies
run: |
poetry install -E gateway -E solver -E aws -E azure -E gcp -E ibm
poetry run pip install -r requirements-dev.txt
if: steps.cache.outputs.cache-hit != 'true'
- name: Run cloud tests
run: |
poetry run pip freeze
poetry run skyplane init -y --disable-config-aws --disable-config-gcp --disable-config-ibm --disable-config-cloudflare
poetry run skyplane config set usage_stats false
poetry run pytest -s tests/unit_azure
test-gcp:
# run if push to main or pull request or pull request target with label 'safe to test' (to avoid running on forks)
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'safe to test'))
runs-on: ubuntu-latest
env:
STRATEGY_UUID: pytest-${{ github.run_id }}-${{ github.run_attempt }}
steps:
- uses: actions/checkout@v1
- name: Install poetry
run: pipx install poetry
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "poetry"
- name: Set Poetry config
run: |
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs
- name: Install Dependencies
run: |
poetry install -E gateway -E solver -E aws -E azure -E gcp -E ibm
poetry run pip install -r requirements-dev.txt
poetry run sudo apt install default-jdk
if: steps.cache.outputs.cache-hit != 'true'
- id: 'auth'
uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS_JSON }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v0'
with:
project_id: '${{ secrets.GCP_PROJECT_ID }}'
export_default_credentials: true
- name: Run cloud tests
run: |
poetry run skyplane config set gcp_service_account_name ${{ env.STRATEGY_UUID }}
poetry run skyplane init -y --disable-config-aws --disable-config-azure --disable-config-ibm --disable-config-cloudflare
poetry run skyplane config set usage_stats false
poetry run pytest -s tests/unit_gcs
- name: Cleanup GCP service account
if: always()
run: gcloud iam service-accounts delete ${{ env.STRATEGY_UUID }}@${{ secrets.GCP_PROJECT_ID }}.iam.gserviceaccount.com