Skip to content

Commit c39c685

Browse files
committed
Add atlas CI
1 parent 10b2a8b commit c39c685

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
set -eu
3+
4+
echo "Starting the container"
5+
6+
IMAGE=mongodb/mongodb-atlas-local:latest
7+
DOCKER=$(which docker || which podman)
8+
9+
$DOCKER pull $IMAGE
10+
11+
$DOCKER kill mongodb_atlas_local || true
12+
13+
CONTAINER_ID=$($DOCKER run --rm -d --name mongodb_atlas_local -p 27017:27017 $IMAGE)
14+
15+
function wait() {
16+
CONTAINER_ID=$1
17+
echo "waiting for container to become healthy..."
18+
$DOCKER logs mongodb_atlas_local
19+
}
20+
21+
wait "$CONTAINER_ID"
22+
23+
# EXPOSED_PORT=$($DOCKER inspect --format='{{ (index (index .NetworkSettings.Ports "27017/tcp") 0).HostPort }}' "$CONTAINER_ID")
24+
# export MONGODB_URI="mongodb://127.0.0.1:$EXPOSED_PORT/?directConnection=true"
25+
# SCRIPT_DIR=$(realpath "$(dirname ${BASH_SOURCE[0]})")
26+
# ROOT_DIR=$(dirname $SCRIPT_DIR)
27+
# echo "MONGODB_URI=$MONGODB_URI" > $ROOT_DIR/.local_atlas_uri
28+
29+
# Sleep for a bit to let all services start.
30+
sleep 5
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Python Atlas Tests
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**.py'
7+
- '!setup.py'
8+
- '.github/workflows/test-python.yml'
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
defaults:
16+
run:
17+
shell: bash -eux {0}
18+
19+
jobs:
20+
build:
21+
name: Django Test Suite
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout django-mongodb-backend
25+
uses: actions/checkout@v4
26+
with:
27+
persist-credentials: false
28+
- name: install django-mongodb-backend
29+
run: |
30+
pip3 install --upgrade pip
31+
pip3 install -e .
32+
- name: Checkout Django
33+
uses: actions/checkout@v4
34+
with:
35+
repository: 'mongodb-forks/django'
36+
ref: 'mongodb-5.1.x'
37+
path: 'django_repo'
38+
persist-credentials: false
39+
- name: Install system packages for Django's Python test dependencies
40+
run: |
41+
sudo apt-get update
42+
sudo apt-get install libmemcached-dev
43+
- name: Install Django and its Python test dependencies
44+
run: |
45+
cd django_repo/tests/
46+
pip3 install -e ..
47+
pip3 install -r requirements/py3.txt
48+
- name: Copy the test settings file
49+
run: cp .github/workflows/mongodb_settings.py django_repo/tests/
50+
- name: Copy the test runner file
51+
run: cp .github/workflows/runtests.py django_repo/tests/runtests_.py
52+
- name: Start local Atlas
53+
working-directory: .
54+
run: bash .github/workflows/start_local_atlas.sh
55+
- name: Run tests
56+
run: python3 django_repo/tests/runtests_.py

0 commit comments

Comments
 (0)