-
-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (123 loc) · 4.36 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
name: Tests
on:
push:
branches: [main, experimental]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
# required for google auth
permissions:
contents: "read"
id-token: "write"
env:
TEST: 1
steps:
- uses: actions/checkout@v4
- id: "auth"
uses: google-github-actions/auth@v1
with:
workload_identity_provider: "projects/868781662168/locations/global/workloadIdentityPools/prod-github/providers/github-oidc-pool"
service_account: "[email protected]"
token_format: "id_token"
id_token_audience: "610575311308-9bsjtgqg4jm01mt058rncpopujgk3627.apps.googleusercontent.com"
id_token_include_email: true
create_credentials_file: true
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Fetch models
if: github.event_name == 'push'
run: |
rm -rf ./models
gcloud storage cp -r gs://sentry-ml/seer/models ./
- name: Build image
run: |
make .env
docker buildx bake --file docker-compose.yml --file docker-compose-cache.json --load
docker compose run app flask db history
docker compose run app flask db upgrade
- name: Save Docker images
run: |
mkdir -p /tmp/docker-images
docker compose config --format json | jq -r '.services[].image' | while read -r image; do
docker save "$image" > "/tmp/docker-images/$(echo $image | tr '/:' '_').tar"
done
- name: Upload Docker images
uses: actions/upload-artifact@v4
with:
name: docker-images
path: /tmp/docker-images/*.tar
retention-days: 1
test:
needs: build
runs-on: ubuntu-latest
permissions:
contents: "read"
id-token: "write"
env:
TEST: 1
steps:
- uses: actions/checkout@v4
- id: "auth"
uses: google-github-actions/auth@v1
with:
workload_identity_provider: "projects/868781662168/locations/global/workloadIdentityPools/prod-github/providers/github-oidc-pool"
service_account: "[email protected]"
token_format: "id_token"
id_token_audience: "610575311308-9bsjtgqg4jm01mt058rncpopujgk3627.apps.googleusercontent.com"
id_token_include_email: true
create_credentials_file: true
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set EXTRA_COMPOSE_TEST_OPTIONS
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "EXTRA_COMPOSE_TEST_OPTIONS=-e NO_REAL_MODELS=1 -e NO_SENTRY_INTEGRATION=1 -e CI=1" >> $GITHUB_ENV
else
echo "EXTRA_COMPOSE_TEST_OPTIONS=-e NO_SENTRY_INTEGRATION=1 -e CI=1" >> $GITHUB_ENV
fi
- name: Download Docker images
uses: actions/download-artifact@v4
with:
name: docker-images
path: /tmp/docker-images
- name: Load Docker images
run: |
for image in /tmp/docker-images/*.tar; do
docker load < "$image"
done
- name: Typecheck with mypy
run: |
make mypy
- name: Validate no pending migrations
run: |
make check-no-pending-migrations
- name: Decrypt VCR cassettes
run: |
pip install -r scripts/requirements.txt
make vcr-decrypt
- name: Test with pytest
run: |
make test
- name: Upload to codecov
if: ${{ always() }}
uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ".artifacts/coverage.xml"
override_commit: ${{ github.event.pull_request.head.sha }}
plugin: noop
verbose: true