Skip to content

Commit

Permalink
fix: refactor workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
irtazaakram committed Oct 3, 2024
1 parent 28fefe8 commit e4f98cc
Show file tree
Hide file tree
Showing 25 changed files with 511 additions and 506 deletions.
57 changes: 0 additions & 57 deletions .ci/docker-compose-ci.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .ci/docker.mk

This file was deleted.

7 changes: 0 additions & 7 deletions .ci/run_check_keywords.sh

This file was deleted.

8 changes: 0 additions & 8 deletions .ci/run_pii_checker.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .ci/run_tests.sh

This file was deleted.

1 change: 0 additions & 1 deletion .dockerignore

This file was deleted.

82 changes: 47 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,59 @@ name: Django CI

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches:
- "**"

jobs:
build:

run_tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 4
matrix:
python-version: ['py311', 'py312']
django-version: ['django42']
db-version: ['mysql80']
python-version: ["3.11", "3.12"]
toxenv: ["django42"] # "quality", "pii_check", "check_keywords"

steps:
- uses: actions/checkout@v4
- name: Start container
run: |
docker compose -f .ci/docker-compose-ci.yml up -d
- name: Install Dependencies
run: |
docker exec -e TOXENV=${{ matrix.python-version }}-${{ matrix.django-version }} --env DB_HOST=${{ matrix.db-version }} -u root edx_notes_api \
/bin/bash -c "apt-get update && apt-get install python3-dev default-libmysqlclient-dev build-essential pkg-config"
- name: setup python 311
if: ${{ matrix.python-version == 'py311' }}
run: |
docker exec -e TOXENV=${{ matrix.python-version }}-${{ matrix.django-version }} --env DB_HOST=${{ matrix.db-version }} -u root edx_notes_api \
/bin/bash -c "add-apt-repository ppa:deadsnakes/ppa -y && apt install python3.11 python3.11-dev python3.11-distutils -y"
- name: setup python 312
if: ${{ matrix.python-version == 'py312' }}
run: |
docker exec -e TOXENV=${{ matrix.python-version }}-${{ matrix.django-version }} --env DB_HOST=${{ matrix.db-version }} -u root edx_notes_api \
/bin/bash -c "add-apt-repository ppa:deadsnakes/ppa -y && apt install python3.12 python3.12-dev python3.12-distutils -y"
- name: Run Tests
run: |
docker exec -e TOXENV=${{ matrix.python-version }}-${{ matrix.django-version }} --env DB_HOST=${{ matrix.db-version }} -u root edx_notes_api /edx/app/edx_notes_api/edx_notes_api/.ci/run_tests.sh
- name: Run PII Check
run: |
docker exec -e TOXENV=${{ matrix.python-version }}-${{ matrix.django-version }} -u root edx_notes_api /edx/app/edx_notes_api/edx_notes_api/.ci/run_pii_checker.sh
- name: Run Reserved Keywords Check
run: |
docker exec -e TOXENV=${{ matrix.python-version }}-${{ matrix.django-version }} -u root edx_notes_api /edx/app/edx_notes_api/edx_notes_api/.ci/run_check_keywords.sh
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install system MySQL
run: |
sudo apt-get update && sudo apt-get install -y libxmlsec1-dev mysql-client
sudo service mysql start
mysql -h 127.0.0.1 -u root -proot -e "UPDATE mysql.user SET authentication_string = null WHERE user = 'root'; FLUSH PRIVILEGES;"
echo "CREATE DATABASE IF NOT EXISTS edx_notes_api;" | sudo mysql -u root
- name: Install Elasticsearch
run: |
curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | \
sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] \
https://artifacts.elastic.co/packages/7.x/apt stable main" | \
sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt-get update && sudo apt-get install -y elasticsearch=7.13.4
sudo service elasticsearch start
- name: Install pip and Tox
run: |
pip install --upgrade pip tox
- name: Run Tox tests
env:
CONN_MAX_AGE: 60
DB_ENGINE: django.db.backends.mysql
DB_HOST: localhost
DB_NAME: edx_notes_api
DB_PASSWORD:
DB_PORT: 3306
DB_USER: root
ENABLE_DJANGO_TOOLBAR: 1
ELASTICSEARCH_URL: http://localhost:9200
run: tox -e ${{ matrix.toxenv }}
113 changes: 46 additions & 67 deletions .github/workflows/migrations-mysql8-check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Migrations check on mysql8
name: Migrations check on MySQL 8

on:
workflow_dispatch:
Expand All @@ -9,74 +9,53 @@ on:

jobs:
check_migrations:
name: check migrations
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
python-version: [ '3.11', '3.12' ]
python-version: ["3.11", "3.12"]

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install system Packages
run: |
sudo apt-get update
sudo apt-get install -y libxmlsec1-dev
- name: Get pip cache dir
id: pip-cache-dir
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache pip dependencies
id: cache-dependencies
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache-dir.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/pip-tools.txt') }}
restore-keys: ${{ runner.os }}-pip-

- name: Ubuntu and sql Versions
run: |
lsb_release -a
mysql -V
# pinning xmlsec to version 1.3.13 to avoid the CI error, migration checks are failing due to an issue in the latest release of python-xmlsec
# https://github.com/xmlsec/python-xmlsec/issues/314
- name: Install Python dependencies
run: |
pip install -r requirements/pip-tools.txt
pip install -r requirements/test.txt
pip install -r requirements/base.txt
pip uninstall -y mysqlclient
pip install --no-binary mysqlclient mysqlclient
pip uninstall -y xmlsec
pip install --no-binary xmlsec xmlsec==1.3.13
- name: Initiate Services
run: |
sudo /etc/init.d/mysql start
- name: Reset mysql password
run: |
cat <<EOF | mysql -h 127.0.0.1 -u root --password=root
UPDATE mysql.user SET authentication_string = null WHERE user = 'root';
FLUSH PRIVILEGES;
EOF
- name: Run Tests
env:
DB_ENGINE: django.db.backends.mysql
DB_NAME: edx_notes_api
DB_USER: root
DB_PASSWORD:
DB_HOST: localhost
DB_PORT: 3306
run: |
echo "CREATE DATABASE IF NOT EXISTS edx_notes_api;" | sudo mysql -u root
echo "Running the migrations."
python manage.py migrate --settings=notesserver.settings.test
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }} with cache
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "**/pip-tools.txt"

- name: Install system packages
run: sudo apt-get update && sudo apt-get install -y libxmlsec1-dev

# pinning xmlsec to version 1.3.13 to avoid the CI error, migration checks are failing due to an issue in the latest release of python-xmlsec
# https://github.com/xmlsec/python-xmlsec/issues/314
- name: Install Python dependencies
run: |
pip install -r requirements/pip-tools.txt
pip install -r requirements/test.txt
pip install -r requirements/base.txt
pip uninstall -y mysqlclient
pip install --no-binary mysqlclient mysqlclient
pip uninstall -y xmlsec
pip install --no-binary xmlsec xmlsec==1.3.13
- name: Start MySQL service
run: sudo service mysql start

- name: Reset MySQL root password
run: |
mysql -h 127.0.0.1 -u root -proot -e "UPDATE mysql.user SET authentication_string = null WHERE user = 'root'; FLUSH PRIVILEGES;"
- name: Run migrations
env:
DB_ENGINE: django.db.backends.mysql
DB_NAME: edx_notes_api
DB_USER: root
DB_PASSWORD:
DB_HOST: localhost
DB_PORT: 3306
run: |
echo "CREATE DATABASE IF NOT EXISTS edx_notes_api;" | sudo mysql -u root
python manage.py migrate --settings=notesserver.settings.test
57 changes: 0 additions & 57 deletions .github/workflows/push-docker-image.yml

This file was deleted.

Loading

0 comments on commit e4f98cc

Please sign in to comment.