Refactor tests #175
Workflow file for this run
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: commcare-export tests | |
| on: | |
| pull_request: | |
| branches: | |
| - master | |
| env: | |
| DB_USER: db_user | |
| DB_PASSWORD: Password123 | |
| jobs: | |
| test: | |
| runs-on: ubuntu-22.04 | |
| services: | |
| mssql: | |
| image: mcr.microsoft.com/mssql/server:2017-latest | |
| env: | |
| SA_PASSWORD: ${{ env.DB_PASSWORD }} | |
| ACCEPT_EULA: 'Y' | |
| ports: | |
| - 1433:1433 | |
| postgres: | |
| image: postgres | |
| env: | |
| POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }} | |
| POSTGRES_USER: ${{ env.DB_USER }} | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| strategy: | |
| matrix: | |
| python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # setuptools-scm needs full git history | |
| # MySQL set up | |
| - run: sudo service mysql start | |
| - run: mysql -uroot -proot -e "CREATE USER '${{ env.DB_USER }}'@'%';" | |
| - run: mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO '${{ env.DB_USER }}'@'%';" | |
| # Install uv | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: "pyproject.toml" | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - run: sudo apt-get install pandoc | |
| # Build and install package | |
| - name: Build distribution | |
| run: uv build | |
| - name: Install package with extras | |
| run: | | |
| uv pip install --system dist/*.whl | |
| uv pip install --system pymysql psycopg2 pyodbc | |
| uv pip install --system coverage coveralls | |
| uv pip install --system mypy | |
| uv pip install --system pytest | |
| uv pip install --system -e ".[test]" | |
| # Run tests and save test coverage | |
| - run: coverage run -m pytest | |
| env: | |
| POSTGRES_URL: postgresql://${{ env.DB_USER }}:${{ env.DB_PASSWORD }}@localhost/ | |
| MYSQL_URL: mysql+pymysql://${{ env.DB_USER }}:@localhost/ | |
| MSSQL_URL: mssql+pyodbc://sa:${{ env.DB_PASSWORD }}@localhost/ | |
| HQ_USERNAME: ${{ secrets.HQ_USERNAME }} | |
| HQ_API_KEY: ${{ secrets.HQ_API_KEY }} | |
| # Convert coverage data for Coveralls | |
| - run: coverage lcov -o coverage/lcov.info | |
| # Use Coveralls to track coverage | |
| - name: Coveralls | |
| uses: coverallsapp/github-action@v2 | |
| with: | |
| parallel: true | |
| flag-name: run-${{ join(matrix.*, '-') }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| typing: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: "pyproject.toml" | |
| - name: Set up Python 3.13 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: Build distribution | |
| run: uv build | |
| - name: Install package with test dependencies | |
| run: | | |
| uv pip install --system dist/*.whl | |
| uv pip install --system -e ".[test]" | |
| - run: mypy commcare_export/ tests/ | |
| finish: | |
| needs: test | |
| if: ${{ always() }} | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Close parallel build | |
| uses: coverallsapp/github-action@v2 | |
| with: | |
| parallel-finished: true | |
| carryforward: "run-3.9,run-3.10,run-3.11,run-3.12,run-3.13" | |
| github-token: ${{ secrets.GITHUB_TOKEN }} |