Repository navigation
122 lines (107 loc) · 4.15 KB
/
Copy pathtest-mongodb.yml
File metadata and controls
122 lines (107 loc) · 4.15 KB
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
name: Tests for MongoDB
on:
workflow_call:
inputs:
mongodb-version:
required: true
type: string
spark-version:
required: true
type: string
etl-entities-version:
required: true
type: string
java-version:
required: true
type: string
python-version:
required: true
type: string
os:
required: true
type: string
with-cache:
required: false
type: boolean
default: true
jobs:
test-mongodb:
name: Run MongoDB tests (server=${{ inputs.mongodb-version }}, spark=${{ inputs.spark-version }}, etl-entities=${{ inputs.etl-entities-version }}, java=${{ inputs.java-version }}, python=${{ inputs.python-version }}, os=${{ inputs.os }})
runs-on: ${{ inputs.os }}
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Start MongoDB
run: |
docker compose --profile all down -v --remove-orphans
docker compose --profile mongodb up -d --pull always
env:
MONGODB_IMAGE: mongo:${{ inputs.mongodb-version }}
- name: Set up Java ${{ inputs.java-version }}
uses: actions/setup-java@v6
with:
distribution: temurin
java-version: ${{ inputs.java-version }}
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v7
with:
python-version: ${{ inputs.python-version }}
# no caching of ~/.ivy2 because MongoDB JDBC driver is just a few MB
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
activate-environment: 'true'
enable-cache: 'false'
# astral-sh/setup-uv cannot restore multiple keys
- name: Cache uv
uses: actions/cache/restore@v6
with:
path: ~/.cache/uv
key: ${{ runner.os }}-python${{ inputs.python-version }}-etl-entities${{ inputs.etl-entities-version}}-spark${{ inputs.spark-version }}-${{ hashFiles('uv.lock') }}
restore-keys: |
${{ runner.os }}-python${{ inputs.python-version }}-etl-entities${{ inputs.etl-entities-version}}-spark${{ inputs.spark-version }}-${{ hashFiles('uv.lock') }}
${{ runner.os }}-python${{ inputs.python-version }}-etl-entities${{ inputs.etl-entities-version}}-spark${{ inputs.spark-version }}-
${{ runner.os }}-python${{ inputs.python-version }}-etl-entities${{ inputs.etl-entities-version}}-
${{ runner.os }}-python${{ inputs.python-version }}-
- name: Wait for MongoDB to be ready
run: |
docker compose --profile mongodb up -d --wait --wait-timeout 200
env:
MONGODB_IMAGE: mongo:${{ inputs.mongodb-version }}
- name: Run tests
uses: nick-fields/retry@v4
with:
timeout_minutes: 10
retry_on: error
max_attempts: 3
command: |
export ETL_ENTITIES_VERSION=${{ inputs.etl-entities-version }}
export SPARK_VERSION=${{ inputs.spark-version }}
mkdir reports/junit -p
rm -rf reports/junit/mongodb-*.xml
export "PYTEST=coverage run -m pytest --junitxml=reports/junit/mongodb-${RANDOM}.xml"
make test-spark UV_ARGS="--group test-mongodb" PYTEST_ARGS="-m mongodb"
- name: Dump MongoDB logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2
with:
images: mongo
dest: ./logs
- name: Upload MongoDB logs
uses: actions/upload-artifact@v7
if: failure()
with:
name: container-logs-mongodb-${{ inputs.mongodb-version }}-spark${{ inputs.spark-version }}
path: logs/*
- name: Shutdown MongoDB
if: always()
run: |
docker compose --profile all down -v --remove-orphans
- name: Upload coverage results
if: success() || failure()
uses: actions/upload-artifact@v7
with:
name: coverage-mongodb-${{ inputs.mongodb-version }}-spark${{ inputs.spark-version }}
path: reports/*
# https://github.com/actions/upload-artifact/issues/602
include-hidden-files: true