Smoke test #235
This file contains hidden or 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: Smoke test | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
jobs: | |
setup-database: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
cache: "pip" | |
- name: Install dependencies | |
run: | | |
python --version | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Initialize database | |
id: initialize-database | |
run: | | |
python resources/create_test_cluster.py --password="${{ secrets.CLUSTER_PASSWORD }}" --token="${{ secrets.CLUSTER_API_KEY }}" --init-sql sqlalchemy_singlestoredb/tests/test.sql --output=github --expires=2h "python - $GITHUB_WORKFLOW - $GITHUB_RUN_NUMBER" | |
env: | |
PYTHONPATH: ${{ github.workspace }} | |
outputs: | |
cluster-id: ${{ steps.initialize-database.outputs.cluster-id }} | |
cluster-host: ${{ steps.initialize-database.outputs.cluster-host }} | |
cluster-database: ${{ steps.initialize-database.outputs.cluster-database }} | |
smoke-test: | |
needs: setup-database | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
python-version: | |
- "3.9" | |
- "3.12" | |
driver: | |
- "singlestoredb" | |
- "singlestoredb+https" | |
sqlalchemy-version: | |
- "~=1.4.0" | |
- "~=2.0.0" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "pip" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install "sqlalchemy${{ matrix.sqlalchemy-version }}" | |
pip install -r requirements.txt | |
pip install -r test-requirements.txt | |
- name: Install SingleStoreDB SQLAlchemy package | |
run: | | |
pip install . | |
ls -R $(dirname $(python3 -c 'import sqlalchemy_singlestoredb; print(sqlalchemy_singlestoredb.__file__)')) | |
- name: Run tests | |
if: ${{ matrix.driver == 'singlestoredb' }} | |
run: pytest -v --pyargs sqlalchemy_singlestoredb.tests.test_basics | |
env: | |
SINGLESTOREDB_URL: "${{ matrix.driver }}://${{ secrets.CLUSTER_USER }}:${{ secrets.CLUSTER_PASSWORD }}@${{ needs.setup-database.outputs.cluster-host }}:3306/${{ needs.setup-database.outputs.cluster-database }}" | |
- name: Run tests | |
if: ${{ matrix.driver == 'singlestoredb+https' }} | |
run: pytest -v --pyargs sqlalchemy_singlestoredb.tests.test_basics | |
env: | |
SINGLESTOREDB_URL: "${{ matrix.driver }}://${{ secrets.CLUSTER_USER }}:${{ secrets.CLUSTER_PASSWORD }}@${{ needs.setup-database.outputs.cluster-host }}:443/${{ needs.setup-database.outputs.cluster-database }}" | |
shutdown-database: | |
needs: [setup-database, smoke-test] | |
if: ${{ always() }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
cache: "pip" | |
- name: Install dependencies | |
run: | | |
python --version | |
python -m pip install pip | |
pip install -r requirements.txt | |
- name: Drop database | |
if: ${{ always() }} | |
run: | | |
python resources/drop_db.py --user "${{ secrets.CLUSTER_USER }}" --password "${{ secrets.CLUSTER_PASSWORD }}" --host "${{ needs.setup-database.outputs.cluster-host }}" --port 3306 --database "${{ needs.setup-database.outputs.cluster-database }}" | |
env: | |
PYTHONPATH: ${{ github.workspace }} | |
- name: Shutdown workspace | |
if: ${{ always() }} | |
run: | | |
curl -H "Accept: application/json" -H "Authorization: Bearer ${{ secrets.CLUSTER_API_KEY }}" -X DELETE "https://api.singlestore.com/v1/workspaces/${{ env.CLUSTER_ID }}" | |
env: | |
CLUSTER_ID: ${{ needs.setup-database.outputs.cluster-id }} |