-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (143 loc) · 4.81 KB
/
container-orchestration.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: Test orchestration Container
on:
pull_request:
branches:
- "**"
merge_group:
types:
- checks_requested
push:
branches:
- main
paths-ignore:
- pyproject.toml
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
TEST_RUNNER_PYTHON_VERSION: 3.11
CONTAINER: orchestration
jobs:
orchestration-python-linting: # This job is the same as the python-linting job in linting-python.yaml but does not run if using linting-python.yaml
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup python ${{env.TEST_RUNNER_PYTHON_VERSION}}
uses: actions/setup-python@v5
with:
python-version: ${{env.TEST_RUNNER_PYTHON_VERSION}}
cache: pip
- name: Install dependencies
run: |
pip install -U pip
pip install ruff==0.4.3
- name: Run linter (ruff)
run: |
ruff check --output-format=github .
- name: Run formatter (ruff)
run: |
ruff format --check
orchestration-unit-test-python:
runs-on: ubuntu-latest
services:
test-db:
image: postgres:13-alpine3.16
env:
POSTGRES_PASSWORD: pw
POSTGRES_DB: testdb
POSTGRES_USER: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--name testdb
ports:
- 5432:5432
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup python ${{env.TEST_RUNNER_PYTHON_VERSION}}
uses: actions/setup-python@v5
with:
python-version: ${{env.TEST_RUNNER_PYTHON_VERSION}}
cache: pip
- name: Install pytest and pytest-cov
run: pip install pytest pytest-cov
- name: Install dependencies
working-directory: ./containers/${{env.CONTAINER}}
run: |
commit_hash=$(git rev-parse HEAD)
find ./ -name requirements.txt -exec sed -i -e "s/phdi@main/phdi@${commit_hash}/g" {} \;
pip install -r requirements.txt
if [ -f dev-requirements.txt ]; then
pip install -r dev-requirements.txt
fi
- name: Run unit tests for container with coverage
working-directory: ./containers/${{env.CONTAINER}}
run: |
python -m pytest --cov-report xml --cov=. -m "not integration" tests/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: ${{ env.CONTAINER }}
orchestration-integration-test-python:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup python ${{env.TEST_RUNNER_PYTHON_VERSION}}
uses: actions/setup-python@v5
with:
python-version: ${{env.TEST_RUNNER_PYTHON_VERSION}}
cache: pip
- name: Install pytest
run: pip install pytest
- name: Install dependencies
working-directory: ./containers/${{env.CONTAINER}}
# When running as a PR check, instead of importing the SDK from @main,
# import it from the current commit. (Need to do this for all containers)
run: |
if [[ $GITHUB_REF != "refs/heads/main" ]]; then
commit_hash=$(git rev-parse HEAD)
find ./ -name requirements.txt -exec sed -i -e "s/phdi@main/phdi@${commit_hash}/g" {} \;
fi
pip install -r requirements.txt
if [ -f dev-requirements.txt ]; then
pip install -r dev-requirements.txt
fi
- name: Run integration tests for containers
env:
MPI_DBNAME: testdb
MPI_PASSWORD: pw
MPI_DB_TYPE: postgres
MPI_HOST: localhost
MPI_USER: postgres
MPI_PORT: 5432
working-directory: ./containers/${{env.CONTAINER}}/tests/integration
run: |
python -m pytest -m "integration"
build-orchestration-container:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build ${{ env.CONTAINER }} Container
uses: docker/build-push-action@v3
with:
context: ./containers/${{ env.CONTAINER }}
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
"INGESTION_URL=${{secrets.INGESTION_URL}}"
"MESSAGE_PARSER_URL=${{secrets.MESSAGE_PARSER_URL}}"
"SMARTY_AUTH_ID=${{secrets.SMARTY_AUTH_ID}}"
"SMARTY_AUTH_TOKEN=${{secrets.SMARTY_AUTH_TOKEN}}"