Skip to content

Feature 50 improve logging (#333) #98

Feature 50 improve logging (#333)

Feature 50 improve logging (#333) #98

Workflow file for this run

name: Compare two databases
on:
pull_request:
push:
branches:
- develop
- develop-ref
- feature_*
- issue_*
- main_*
- bugfix_*
defaults:
run:
shell: bash -leo pipefail {0}
jobs:
run-shell-command:
runs-on: ubuntu-20.04
name: job_run
env:
DB_DATABASE: mv_ci_prod
DB_USER: root
DB_PASSWORD: 'root'
DB_HOST: localhost
steps:
- name: check out headnew code
uses: actions/checkout@v4
with:
path: headnew
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: check out baseold code
uses: actions/checkout@v4
with:
path: baseold
ref: ${{github.event.pull_request.base.ref}}
- name: start mysql
run: |
sudo systemctl start mysql
python3 -V
pip3 --version
mysql -e 'SELECT VERSION();' -uroot -proot
mysql -e 'CREATE DATABASE mv_ci_prod;' -uroot -proot
mysql -e 'SOURCE /home/runner/work/METdataio/METdataio/baseold/METdbLoad/sql/mv_mysql.sql;' -uroot -proot mv_ci_prod
mysql -e 'CREATE DATABASE mv_ci_new;' -uroot -proot
mysql -e 'SOURCE /home/runner/work/METdataio/METdataio/headnew/METdbLoad/sql/mv_mysql.sql;' -uroot -proot mv_ci_new
- name: multiline script
run: |
pip3 install numpy
pip3 install pandas
pip3 install pymysql
pip3 install lxml
pip3 install pytest
- name: change default python to python 3
shell: bash
run: |
which python3
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
- name: python command
run: |
import pymysql
import numpy
import pandas
import lxml
conn = pymysql.connect(host='localhost',port=3306,user='root',passwd='root',db='mv_ci_prod')
cur = conn.cursor()
cur.execute('select database();')
print(cur.fetchall())
cur.execute('show tables;')
print(cur.fetchall())
shell: python
- name: get data
shell: bash
run: |
mkdir metdata
cd metdata
curl 'https://dtcenter.ucar.edu/dfiles/code/METplus/METdataio/sample_data-met_out_v9.1.tgz' -o m91.tgz
tar -xvf m91.tgz
# Note that both XML files are taken from the new branch, so they can match if changed
- name: run METdbload prod
shell: bash
run: |
export PYTHONPATH=${GITHUB_WORKSPACE}/baseold
cd ${GITHUB_WORKSPACE}/baseold/METdbLoad/ush
python met_db_load.py ${GITHUB_WORKSPACE}/headnew/METdbLoad/test/load_met_gha_prod.xml
mysql -e 'SHOW TABLE STATUS WHERE `rows` > 0;' -uroot -proot mv_ci_prod
- name: run METdbload new
shell: bash
run: |
export PYTHONPATH=${GITHUB_WORKSPACE}/headnew
cd ${GITHUB_WORKSPACE}/headnew/METdbLoad/ush
python met_db_load.py ${GITHUB_WORKSPACE}/headnew/METdbLoad/test/load_met_gha_new.xml
mysql -e 'SHOW TABLE STATUS WHERE `rows` > 0;' -uroot -proot mv_ci_new
- name: run test_tables to compare tables in 2 databases
shell: bash
run: python ${GITHUB_WORKSPACE}/headnew/METdbLoad/test/test_tables.py