Now that we're using standard service containers, we can use a matrix to test both the current supported versions in one job. This should also make it easier to test with future versions as we get ready to upgrade.
106 lines
2.9 KiB
YAML
106 lines
2.9 KiB
YAML
name: Check Django Migrations
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
check_migrations:
|
|
name: check migrations
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ ubuntu-20.04 ]
|
|
python-version: [ 3.8 ]
|
|
mongo-version: ["4"]
|
|
mysql-version: ["5.7", "8"]
|
|
services:
|
|
mongo:
|
|
image: mongo:${{ matrix.mongo-version }}
|
|
ports:
|
|
- 27017:27017
|
|
# Note: Calling mongo here only works with mongo 4, in newer versions of mongo
|
|
# we'll have to use `mongosh`
|
|
options: >-
|
|
--health-cmd "mongo --quiet --eval 'db.runCommand(\"ping\")'"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 3
|
|
mysql:
|
|
image: mysql:${{ matrix.mysql-version }}
|
|
ports:
|
|
- 3306:3306
|
|
env:
|
|
MYSQL_DATABASE: "edxapp"
|
|
MYSQL_USER: "edxapp001"
|
|
MYSQL_PASSWORD: "password"
|
|
MYSQL_RANDOM_ROOT_PASSWORD: true
|
|
options: >-
|
|
--health-cmd "mysqladmin ping"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 3
|
|
steps:
|
|
- name: Setup mongodb user
|
|
run: |
|
|
mongosh edxapp --eval '
|
|
db.createUser(
|
|
{
|
|
user: "edxapp",
|
|
pwd: "password",
|
|
roles: [
|
|
{ role: "readWrite", db: "edxapp" },
|
|
]
|
|
}
|
|
);
|
|
'
|
|
|
|
- name: Verify mongo and mysql db credentials
|
|
run: |
|
|
mysql -h 127.0.0.1 -uedxapp001 -ppassword -e "select 1;" edxapp
|
|
mongosh --host 127.0.0.1 --username edxapp --password password --eval 'use edxapp; db.adminCommand("ping");' edxapp
|
|
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Setup Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Install system Packages
|
|
run: |
|
|
sudo apt-get update
|
|
make ubuntu-requirements
|
|
|
|
- name: Get pip cache dir
|
|
id: pip-cache-dir
|
|
run: |
|
|
echo "::set-output name=dir::$(pip cache dir)"
|
|
|
|
- name: Cache pip dependencies
|
|
id: cache-dependencies
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ${{ steps.pip-cache-dir.outputs.dir }}
|
|
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/edx/development.txt') }}
|
|
restore-keys: ${{ runner.os }}-pip-
|
|
|
|
- name: Install Python dependencies
|
|
run: |
|
|
make dev-requirements
|
|
|
|
- name: Run Tests
|
|
env:
|
|
LMS_CFG: lms/envs/minimal.yml
|
|
# This is from the LMS dir on purpose since we don't need anything different for the CMS yet.
|
|
STUDIO_CFG: lms/envs/minimal.yml
|
|
run: |
|
|
echo "Running the LMS migrations."
|
|
./manage.py lms migrate
|
|
echo "Running the CMS migrations."
|
|
./manage.py cms migrate
|