Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: capturing new migrations. #33614

Closed
wants to merge 127 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
36864b4
build: capturing new migrations.
awais786 Oct 30, 2023
4cccc1c
build: capturing new migrations.
awais786 Oct 30, 2023
7c1e179
build: capturing new migrations.
awais786 Oct 30, 2023
e528ee7
build: capturing new migrations.
awais786 Oct 30, 2023
278d58f
build: capturing new migrations.
awais786 Oct 30, 2023
7ff9d15
build: capturing new migrations.
awais786 Oct 30, 2023
b8119f0
build: capturing new migrations.
awais786 Oct 30, 2023
4354d98
build: capturing new migrations.
awais786 Oct 30, 2023
ebcca97
build: capturing new migrations.
awais786 Oct 30, 2023
448b6b9
build: capturing new migrations.
awais786 Oct 30, 2023
4bbdeff
build: capturing new migrations.
awais786 Oct 30, 2023
3a7edb7
build: capturing new migrations.
awais786 Oct 30, 2023
26f4dc1
build: capturing new migrations.
awais786 Oct 30, 2023
8d3e915
build: capturing new migrations.
awais786 Oct 30, 2023
ec1e12e
build: capturing new migrations.
awais786 Oct 30, 2023
d9a053d
build: capturing new migrations.
awais786 Oct 30, 2023
450df4b
build: capturing new migrations.
awais786 Oct 30, 2023
a9d0efc
build: capturing new migrations.
awais786 Oct 30, 2023
799da94
build: capturing new migrations.
awais786 Oct 30, 2023
aba4737
build: capturing new migrations.
awais786 Oct 30, 2023
cf48e69
build: capturing new migrations.
awais786 Oct 30, 2023
75ed777
build: capturing new migrations.
awais786 Oct 30, 2023
8124279
build: capturing new migrations.
awais786 Oct 30, 2023
cfd565e
build: capturing new migrations.
awais786 Oct 31, 2023
4cbff6b
build: capturing new migrations.
awais786 Oct 31, 2023
0889070
build: capturing new migrations.
awais786 Oct 31, 2023
61b4575
build: capturing new migrations.
awais786 Oct 31, 2023
ad9e64f
build: capturing new migrations.
awais786 Oct 31, 2023
47b0b6e
build: capturing new migrations.
awais786 Oct 31, 2023
1a641d1
build: capturing new migrations.
awais786 Oct 31, 2023
0b94e4b
build: capturing new migrations.
awais786 Oct 31, 2023
b8d90a7
build: capturing new migrations.
awais786 Oct 31, 2023
9c37433
build: capturing new migrations.
awais786 Oct 31, 2023
9868d8f
build: capturing new migrations.
awais786 Oct 31, 2023
6725df0
build: capturing new migrations.
awais786 Oct 31, 2023
01e8e35
build: capturing new migrations.
awais786 Oct 31, 2023
ecd2762
build: capturing new migrations.
awais786 Oct 31, 2023
206c060
build: capturing new migrations.
awais786 Oct 31, 2023
1a2d51b
build: capturing new migrations.
awais786 Oct 31, 2023
70dd4e0
build: capturing new migrations.
awais786 Oct 31, 2023
2b33ce3
build: capturing new migrations.
awais786 Oct 31, 2023
464c0f6
build: capturing new migrations.
awais786 Oct 31, 2023
c1a06bc
build: capturing new migrations.
awais786 Oct 31, 2023
a573f2f
build: capturing new migrations.
awais786 Oct 31, 2023
01634fe
build: capturing new migrations.
awais786 Oct 31, 2023
4a0dc06
build: capturing new migrations.
awais786 Oct 31, 2023
7c75eb2
build: capturing new migrations.
awais786 Oct 31, 2023
c5af3c2
build: capturing new migrations.
awais786 Oct 31, 2023
9c2dfc5
build: capturing new migrations.
awais786 Oct 31, 2023
40bec3f
build: capturing new migrations.
awais786 Oct 31, 2023
2819758
build: capturing new migrations.
awais786 Oct 31, 2023
a1eca1d
build: capturing new migrations.
awais786 Oct 31, 2023
a793a3f
build: capturing new migrations.
awais786 Oct 31, 2023
2a710e6
build: capturing new migrations.
awais786 Oct 31, 2023
ec0d51d
build: capturing new migrations.
awais786 Oct 31, 2023
da9a59b
build: capturing new migrations.
awais786 Oct 31, 2023
1157b6e
build: capturing new migrations.
awais786 Oct 31, 2023
be46807
build: capturing new migrations.
awais786 Oct 31, 2023
2d4fc6f
build: capturing new migrations.
awais786 Oct 31, 2023
1bdb0a3
build: capturing new migrations.
awais786 Oct 31, 2023
067fdf7
build: capturing new migrations.
awais786 Oct 31, 2023
aaf85b5
build: capturing new migrations.
awais786 Oct 31, 2023
045d375
build: capturing new migrations.
awais786 Oct 31, 2023
351886c
build: capturing new migrations.
awais786 Oct 31, 2023
438b39e
build: capturing new migrations.
awais786 Oct 31, 2023
2286711
build: capturing new migrations.
awais786 Oct 31, 2023
5387113
build: capturing new migrations.
awais786 Oct 31, 2023
6fbe2c4
build: capturing new migrations.
awais786 Oct 31, 2023
2198e8b
build: capturing new migrations.
awais786 Oct 31, 2023
34ae3c4
build: capturing new migrations.
awais786 Oct 31, 2023
bd439a1
build: capturing new migrations.
awais786 Oct 31, 2023
f3ff04d
build: capturing new migrations.
awais786 Oct 31, 2023
a81c86f
build: capturing new migrations.
awais786 Oct 31, 2023
5475cb3
build: capturing new migrations.
awais786 Oct 31, 2023
8b9ecb3
build: capturing new migrations.
awais786 Oct 31, 2023
6f03b5b
build: capturing new migrations.
awais786 Oct 31, 2023
01a76c5
build: capturing new migrations.
awais786 Oct 31, 2023
ef11b70
build: capturing new migrations.
awais786 Oct 31, 2023
627082a
build: capturing new migrations.
awais786 Oct 31, 2023
b8c6cf1
build: capturing new migrations.
awais786 Oct 31, 2023
afdb3b6
build: capturing new migrations.
awais786 Oct 31, 2023
5767c23
build: capturing new migrations.
awais786 Oct 31, 2023
b064db7
build: capturing new migrations.
awais786 Oct 31, 2023
285b2cc
build: capturing new migrations.
awais786 Oct 31, 2023
ddf6ee6
build: capturing new migrations.
awais786 Oct 31, 2023
72eefe5
build: capturing new migrations.
awais786 Oct 31, 2023
a48e7c1
build: capturing new migrations.
awais786 Oct 31, 2023
8d6b1c6
build: capturing new migrations.
awais786 Oct 31, 2023
c3e30ad
build: capturing new migrations.
awais786 Oct 31, 2023
f98b183
build: capturing new migrations.
awais786 Oct 31, 2023
6a7052c
build: capturing new migrations.
awais786 Oct 31, 2023
6e5f07a
build: capturing new migrations.
awais786 Oct 31, 2023
5c03ce8
build: capturing new migrations.
awais786 Oct 31, 2023
b3940d4
build: capturing new migrations.
awais786 Oct 31, 2023
0e3ec4b
build: capturing new migrations.
awais786 Oct 31, 2023
a5ef96d
build: capturing new migrations.
awais786 Oct 31, 2023
fc0975f
build: capturing new migrations.
awais786 Oct 31, 2023
741b0c0
build: capturing new migrations.
awais786 Oct 31, 2023
b5fd62a
build: capturing new migrations.
awais786 Oct 31, 2023
2de3bd3
build: capturing new migrations.
awais786 Oct 31, 2023
1787a61
build: capturing new migrations.
awais786 Oct 31, 2023
f0913e1
build: capturing new migrations.
awais786 Oct 31, 2023
4694586
build: capturing new migrations.
awais786 Nov 1, 2023
a97f8d4
build: capturing new migrations.
awais786 Nov 1, 2023
15af0d1
build: capturing new migrations.
awais786 Nov 1, 2023
7f2e60d
build: capturing new migrations.
awais786 Nov 1, 2023
584aa4e
build: capturing new migrations.
awais786 Nov 1, 2023
df32bc1
build: capturing new migrations.
awais786 Nov 1, 2023
e916d96
build: capturing new migrations.
awais786 Nov 1, 2023
8bb6649
build: capturing new migrations.
awais786 Nov 1, 2023
4e45a2a
build: capturing new migrations.
awais786 Nov 1, 2023
884ea60
build: capturing new migrations.
awais786 Nov 1, 2023
30eaff8
build: capturing new migrations.
awais786 Nov 1, 2023
0668178
build: capturing new migrations.
awais786 Nov 1, 2023
c09efbb
build: capturing new migrations.
awais786 Nov 1, 2023
fdcf6ae
build: capturing new migrations.
awais786 Nov 1, 2023
2490833
build: capturing new migrations.
awais786 Nov 1, 2023
85ad6e3
build: capturing new migrations.
awais786 Nov 1, 2023
0b1a933
build: capturing new migrations.
awais786 Nov 1, 2023
8582e2e
build: capturing new migrations.
awais786 Nov 1, 2023
9a5b696
build: capturing new migrations.
awais786 Nov 1, 2023
a42792a
build: capturing new migrations.
awais786 Nov 1, 2023
764e010
build: capturing new migrations.
awais786 Nov 1, 2023
83bc48e
build: capturing new migrations.
awais786 Nov 1, 2023
6172e08
build: capturing new migrations.
awais786 Nov 1, 2023
5df08af
build: capturing new migrations.
awais786 Nov 1, 2023
b470868
build: capturing new migrations.
awais786 Nov 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
209 changes: 209 additions & 0 deletions .github/workflows/capture_new_migrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
name: Check any new 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 ]
# 'pinned' is used to install the latest patch version of Django
# within the global constraint i.e. Django==3.2.21 in current case
# because we have global constraint of Django<4.2
django-version: ["4.2"]
mongo-version: ["4"]
mysql-version: ["8"]
# excluding mysql5.7 with Django 4.2 since Django 4.2 has
# dropped support for MySQL<8
exclude:
- django-version: "4.2"
mysql-version: "5.7"
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 master repo
uses: actions/checkout@v2
with:
ref: master

- 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
if [[ "${{ matrix.django-version }}" != "pinned" ]]; then
pip install "django~=${{ matrix.django-version }}.0"
pip check # fail if this test-reqs/Django combination is broken
fi

- name: Run migrations on master branch
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 social_django
# echo "Running the CMS migrations."
# ./manage.py cms migrate

- name: Verify executed migrations on master.
id: capture1
shell: bash
run: |
query_result1=$(mysql -h 127.0.0.1 -uedxapp001 -ppassword -e "select count(*) from django_migrations;" edxapp;)
echo "echo $query_result1"
numeric_result=$(echo "$query_result1" | tr -d '\n' | sed -E 's/[^0-9]+//g')
echo "Numeric Result: $numeric_result"
echo "FIRST_QUERY=$numeric_result" >> $GITHUB_ENV

- name: Step 12
run: |
subtraction_result=${{ env.FIRST_QUERY }}
echo "State is: subtraction_result"

- name: Checkout branch repo
uses: actions/checkout@v2

- name: Install Python dependencies
run: |
make dev-requirements
if [[ "${{ matrix.django-version }}" != "pinned" ]]; then
pip install "django~=${{ matrix.django-version }}.0"
pip check # fail if this test-reqs/Django combination is broken
fi
#
- name: list installed package versions
run: |
pip freeze

- 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 makemigrations
./manage.py lms migrate social_django

echo "Running the CMS migrations."
./manage.py cms makemigrations
# ./manage.py cms migrate

- name: Verify executed migrations on branch.
shell: bash
id: capture2
run: |
query_result1=$(mysql -h 127.0.0.1 -uedxapp001 -ppassword -e "select count(*) from django_migrations;" edxapp;)
echo "echo $query_result1"
numeric_result=$(echo "$query_result1" | tr -d '\n' | sed -E 's/[^0-9]+//g')
echo "Numeric Result: $numeric_result"
echo "SECOND_QUERY=$numeric_result" >> $GITHUB_ENV

- name: Process Data
run: |
number2=${{ env.SECOND_QUERY }}
number1=${{ env.FIRST_QUERY }}
diff=$((number2 - number1))
if [ $number2 -gt $number1 ]; then
data=$(mysql -h 127.0.0.1 -uedxapp001 -ppassword -e "select name from django_migrations ORDER by -id limit $diff;" edxapp;)
echo "$data" > cleaned_data.txt
elif [ $number1 -gt $number2 ]; then
echo "Your PR removed migrations." > cleaned_data.txt
fi
shell: bash

- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
with:
filePath: cleaned_data.txt
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# This job aggregates test results. It's the required check for branch protection.
# https://github.com/marketplace/actions/alls-green#why
# https://github.com/orgs/community/discussions/33579
success:
name: Migrations checks successful
if: always()
needs:
- check_migrations
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
# uses: re-actors/[email protected]
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
with:
jobs: ${{ toJSON(needs) }}
Loading
Loading