Skip to content

Run tests

Run tests #35

Workflow file for this run

name: Run tests
on:
push:
workflow_run:
workflows: Trigger PR sensitive workflows
types: completed
permissions:
contents: read
jobs:
python:
name: Test web application
if: ${{ github.event_name == 'push' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
env:
ODBC_CONNECTION_STRING: ${{ secrets.ODBC_CONNECTION_STRING}}
VNPAY_TMN_CODE: ${{ secrets.VNPAY_TMN_CODE }}
VNPAY_SECRET_KEY: ${{ secrets.VNPAY_SECRET_KEY }}
PRIVATE_KEY_SEED: ${{ secrets.PRIVATE_KEY_SEED }}
PORT: 8000
steps:
- name: Checkout repository
if: ${{ github.event_name == 'push' }}
uses: actions/checkout@v4
- name: Get pull request HEAD SHA
if: ${{ github.event_name == 'workflow_run' }}
uses: actions/download-artifact@v4
with:
name: pr-sha
path: /tmp/
run-id: ${{ github.event.workflow_run.id }}
- name: Print pull request HEAD SHA
id: pr-sha-step
if: ${{ github.event_name == 'workflow_run' }}
run: echo "sha=$(cat /tmp/pr.txt)" > $GITHUB_OUTPUT
- name: Checkout pull request directory
if: ${{ github.event_name == 'workflow_run' }}
uses: actions/checkout@v4
with:
ref: ${{ steps.pr-sha-step.outputs.sha }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install -r dev-requirements.txt
- name: Install ODBC driver 18
run: |
chmod +x scripts/odbc.sh
scripts/odbc.sh
- name: Run tests
run: coverage run -m pytest -v .
- name: Combine coverage reports
run: coverage combine
- name: Report coverage
run: coverage report -m
- name: Generate HTML coverage report
run: coverage html -d htmlcov
- name: Upload HTML coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-html-${{ matrix.python-version }}
path: htmlcov
flutter:
name: Test client application
if: ${{ github.event_name == 'push' || github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
env:
PRIVATE_KEY_SEED: ${{ secrets.PRIVATE_KEY_SEED }}
steps:
- name: Checkout repository
if: ${{ github.event_name == 'push' }}
uses: actions/checkout@v4
- name: Get pull request HEAD SHA
if: ${{ github.event_name == 'workflow_run' }}
uses: actions/download-artifact@v4
with:
name: pr-sha
path: /tmp/
run-id: ${{ github.event.workflow_run.id }}
- name: Print pull request HEAD SHA
id: pr-sha-step
if: ${{ github.event_name == 'workflow_run' }}
run: echo "sha=$(cat /tmp/pr.txt)" > $GITHUB_OUTPUT
- name: Checkout pull request directory
if: ${{ github.event_name == 'workflow_run' }}
uses: actions/checkout@v4
with:
ref: ${{ steps.pr-sha-step.outputs.sha }}
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.24.3
channel: stable
- name: View Flutter status
run: |
flutter --version
flutter doctor -v
- name: Run tests
working-directory: app/resident_manager
run: flutter test