Test Build Mysql #1456
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Build Mysql | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- 'packages/watchmen-test-postman/**' | |
- 'packages/watchmen-web-client/**' | |
- 'packages/watchmen-storage-mongodb/**' | |
- 'packages/watchmen-storage-mssql/**' | |
- 'packages/watchmen-storage-oracle/**' | |
- 'packages/watchmen-storage-postgresql/**' | |
- 'packages/watchmen-storage-s3/**' | |
#on: workflow_dispatch | |
jobs: | |
test-api: | |
runs-on: ubuntu-latest | |
env: | |
DB_DATABASE: watchmen | |
DB_USER: admin | |
DB_PASSWORD: admin | |
LOG_FILE: /tmp/scripts/runtime.log | |
BASE_PATH: ${{ github.workspace }} | |
META_STORAGE_TYPE: mysql | |
META_STORAGE_USER_NAME: admin | |
META_STORAGE_PASSWORD: admin | |
META_STORAGE_HOST: localhost | |
META_STORAGE_PORT: 3306 | |
META_STORAGE_NAME: watchmen | |
TUPLE_DELETABLE: True | |
SYNC_TOPIC_TO_STORAGE: TRUE | |
REPLACE_TOPIC_TO_STORAGE: TRUE | |
PIPELINE_ELASTIC_SEARCH_EXTERNAL_WRITER: TRUE | |
META_STORAGE_ECHO: FALSE | |
PIPELINE_PARALLEL_ACTIONS_IN_LOOP_UNIT: False | |
USE_STORAGE_DIRECTLY: TRUE | |
LOGGER_LEVEL: INFO | |
LOGGER_TO_FILE: TRUE | |
services: | |
mysql: | |
image: mysql:8.0.21 | |
env: | |
MYSQL_DATABASE: ${{ env.DB_DATABASE }} | |
MYSQL_USER: ${{ env.DB_USER }} | |
MYSQL_PASSWORD: ${{ env.DB_PASSWORD }} | |
MYSQL_ROOT_PASSWORD: ${{ env.DB_PASSWORD }} | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=3 | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ inputs.branch }} | |
# - name: Set up MySQL | |
# run: | | |
# sudo /etc/init.d/mysql start | |
# mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }};' -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} | |
- name: Set global variable log_bin_trust_function_creators | |
run: | | |
mysql -e 'set global log_bin_trust_function_creators=1;' -uroot -p${{ env.DB_PASSWORD }} -P3306 --default-character-set=utf8 ${{ env.DB_DATABASE }} --protocol=tcp | |
# - name: Create User for admin@127.0.0.1 | |
# run: | | |
# mysql -e 'create user "admin"@"127.0.0.1" identified by "admin";' -uroot -p${{ env.DB_PASSWORD }} -P3306 --default-character-set=utf8 ${{ env.DB_DATABASE }} --protocol=tcp | |
# mysql -e 'grant all privileges on watchmen.* to "admin"@"127.0.0.1" with grant option; flush privileges;' -uroot -p${{ env.DB_PASSWORD }} -P3306 --default-character-set=utf8 ${{ env.DB_DATABASE }} --protocol=tcp | |
# mysql -e 'select * from mysql.user where user="admin";' -uroot -padmin -P3306 --default-character-set=utf8 watchmen --protocol=tcp | |
- name: Run db meta script | |
run: | | |
script_path=./packages/watchmen-storage-mysql/meta-scripts | |
for version in `ls -v ${script_path}` | |
do | |
if [ -d ${script_path}/$version ];then | |
for file in ${script_path}/$version/* | |
do | |
echo `pwd`/$file | |
mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} -P3306 --default-character-set=utf8 ${{ env.DB_DATABASE }} --protocol=tcp < $file 2>&1 | |
done | |
fi | |
done | |
- name: Run db data script | |
run: | | |
script_path=./packages/watchmen-storage-mysql/data-scripts | |
for version in `ls -v ${script_path}` | |
do | |
if [ -d ${script_path}/$version ];then | |
for file in ${script_path}/$version/* | |
do | |
echo `pwd`/$file | |
mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} -P3306 --default-character-set=utf8 ${{ env.DB_DATABASE }} --protocol=tcp < $file 2>&1 | |
done | |
fi | |
done | |
- name: Setup python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.12' | |
architecture: 'x64' | |
- name: Setup poetry | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
- name: Make directory for server log | |
working-directory: ./packages/watchmen-rest-doll | |
run: mkdir -p temp | |
- name: build [watchmen-rest-doll] and start | |
working-directory: ./packages/watchmen-rest-doll | |
run: | | |
poetry config virtualenvs.create false | |
poetry update | |
poetry install --no-dev -vv -E mysql -E trino | |
uvicorn watchmen_rest_doll.main:app --host='0.0.0.0' --port='8000' > server.out 2>&1 & | |
- name: Install Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: Install newman | |
run: | | |
npm install -g newman | |
npm install -g newman-reporter-htmlextra | |
- name: Make directory for result | |
run: mkdir -p testResults | |
- name: Run postman collection | |
run: | | |
newman run ./packages/watchmen-test-postman/watchmen-postman.json -e ./packages/watchmen-test-postman/mysql.json --bail -r cli,htmlextra --reporter-htmlextra-export testResults/htmlreport.html --delay-request 1000 | |
- name: Output the run details | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: RunReports | |
path: testResults | |
- name: Output the doll details | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: DollServerOput | |
path: ./packages/watchmen-rest-doll/temp | |
- name: Send email | |
if: always() | |
uses: dawidd6/action-send-mail@v3.2.0 | |
with: | |
server_address: smtp.feishu.cn | |
server_port: 465 | |
username: github-ci@mail.matrdata.com | |
password: ${{secrets.MAIL_PASSWORD}} | |
subject: job ${{ job.status }} for ${{ github.job }} job of ${{ github.repository }} | |
to: ci-postman@mail.matrdata.com | |
from: github-ci@mail.matrdata.com | |
body: ${{ github.job }} job in worflow ${{ github.workflow }} of ${{ github.repository }} has ${{ job.status }} | |
attachments: testResults/htmlreport.html | |
- name: notify feishu | |
if: always() | |
uses: potaesm/github-actions-request@1.0.7 | |
with: | |
url: ${{ secrets.FEISHU_CHANNLE_ID }} | |
method: post | |
baseURL: https://open.feishu.cn/open-apis/bot/v2/hook | |
headers: '{ "Content-Type": "application/json" }' | |
data: '{"msg_type":"interactive","card":{"config":{"wide_screen_mode":true},"header":{"title":{"tag":"lark_md","content":"Mysql CI testing ${{ job.status }}"}},"elements":[{"tag":"hr"},{"tag":"action","actions":[{"tag":"button","text":{"tag":"plain_text","content":"Check it out."},"type":"primary","url":"https://github.com/Indexical-Metrics-Measure-Advisory/watchmen/actions"}]}]}}' | |
timeout: 30000 |