Skip to content

Commit

Permalink
chore: workflow cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
irtazaakram committed Sep 12, 2024
1 parent 6bf7afd commit 5012db2
Show file tree
Hide file tree
Showing 23 changed files with 479 additions and 505 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.

84 changes: 49 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,61 @@ 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 }} with cache
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
default-libmysqlclient-dev build-essential \
libssl-dev openjdk-11-jdk curl
- name: Install MySQL
run: |
sudo apt-get install -y gnupg
curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.32-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.32-1_all.deb
sudo apt-get update
sudo apt-get install -y mysql-server
sudo service mysql start
mysql -e 'CREATE DATABASE edx_notes_api;'
mysql -e "CREATE USER 'notes001'@'localhost' IDENTIFIED BY 'secret';"
mysql -e "GRANT ALL PRIVILEGES ON edx_notes_api.* TO 'notes001'@'localhost';"
- 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
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 5012db2

Please sign in to comment.