-
Notifications
You must be signed in to change notification settings - Fork 1
176 lines (151 loc) · 6.1 KB
/
containerize-agent.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
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
176
name: containerize-agent
on:
push:
branches:
- main
jobs:
containerize-agent:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Read python version from .python-version
id: read-python-version
run: echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ steps.read-python-version.outputs.PYTHON_VERSION }}
cache-dependency-path: poetry.lock
- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local # the path depends on the OS
key: poetry-0 # increment to reset cache
- name: Install Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install --with dev,sql --sync
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Configure ECR AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::258143015559:role/github-amazonec2containerregistrypoweruser
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
# Cannot multi arch build AND load
# https://github.com/docker/buildx/issues/59
- name: Build arm64, No Load, No Push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/arm64
push: false
load: false
tags: |
greatexpectations/agent:latest
greatexpectations/agent:stable
# https://docs.docker.com/build/ci/github-actions/test-before-push/
- name: Build amd64, With Load, No Push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: false
load: true
tags: |
greatexpectations/agent:latest
greatexpectations/agent:stable
- name: Smoke Test the Image
run: docker run --rm greatexpectations/agent:stable poetry run gx-agent -h
# Uses local image built in previous step
- name: Test New amd64 Agent Image
run: |
echo "STARTING db and mq"
docker compose up db mq -d
echo "STARTING db-provisioner"
docker compose run db-provisioner
echo "STARTING db-seeder"
docker compose run db-seeder
echo "STARTING mq-wait"
docker compose run mq-wait
echo "STARTING mercury-service-api"
docker compose up mercury-service-api -d
echo "STARTING mercury-service-api-v1"
docker compose up mercury-service-api-v1 -d
echo "STARTING nginx"
docker compose up nginx -d
echo "STARTING gx-agent"
docker compose up gx-agent -d
echo "RUNNING TESTS"
poetry run pytest -m "agentjobs"
env:
GX_CLOUD_BASE_URL: "http://localhost:5000"
GX_CLOUD_ORGANIZATION_ID: ${{ secrets.GX_CLOUD_ORGANIZATION_ID }}
GX_CLOUD_ACCESS_TOKEN: ${{ secrets.GX_CLOUD_ACCESS_TOKEN }}
AUTH0_API_AUDIENCE: ${{ secrets.AUTH0_API_AUDIENCE }}
AUTH0_MERCURY_API_CLIENT_ID: ${{ secrets.AUTH0_MERCURY_API_CLIENT_ID }}
AUTH0_MERCURY_API_CLIENT_SECRET: ${{ secrets.AUTH0_MERCURY_API_CLIENT_SECRET }}
AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }}
GE_USAGE_STATISTICS_URL: ${{ secrets.GE_USAGE_STATISTICS_URL }}
- name: Get version from pyproject.toml
id: get_version
run: echo "POETRY_VERSION=$(poetry version -s)" >> $GITHUB_OUTPUT
- name: Get is_dev from pyproject.toml
id: get_is_dev
run: echo "IS_DEV=$(poetry run invoke is-dev-release)" >> $GITHUB_OUTPUT
- name: Get is_pre_release from pyproject.toml
id: get_is_pre_release
run: echo "IS_PRERELEASE=$(poetry run invoke is-pre-release)" >> $GITHUB_OUTPUT
- name: Get is_release from pyproject.toml
id: get_is_release
run: echo "IS_RELEASE=$(poetry run invoke is-release)" >> $GITHUB_OUTPUT
# Uses the version from pyproject.toml for the tag
- name: Push Pre-Release to Docker Hub and Internal ECR
if: ${{ steps.get_is_dev.outputs.IS_DEV == 'True'}}
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
greatexpectations/agent:dev
greatexpectations/agent:${{ steps.get_version.outputs.POETRY_VERSION }}
258143015559.dkr.ecr.us-east-1.amazonaws.com/gx/agent:${{ steps.get_version.outputs.POETRY_VERSION }}
- name: Push Release to Docker Hub and Internal ECR
if: ${{ steps.get_is_release.outputs.IS_RELEASE == 'True' }}
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
greatexpectations/agent:dev
greatexpectations/agent:${{ steps.get_version.outputs.POETRY_VERSION }}
greatexpectations/agent:latest
greatexpectations/agent:stable
258143015559.dkr.ecr.us-east-1.amazonaws.com/gx/agent:${{ steps.get_version.outputs.POETRY_VERSION }}
- name: Show logs, if failure
if: failure()
run: docker compose logs
# NOTE: can't use coveralls here without refactoring workflows
# upload coverage report to codecov
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: great-expectations/cloud
# use the same flags as the test markers
flags: agentjobs