Feat/project api #230
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: Run Test | |
| on: | |
| pull_request: | |
| paths: | |
| - wacruit/** | |
| - .github/workflows/test.yaml | |
| jobs: | |
| pytest: | |
| runs-on: ubuntu-latest | |
| services: | |
| mysql: | |
| image: mysql:5.7 | |
| env: | |
| MYSQL_USER: test-user | |
| MYSQL_PASSWORD: password | |
| MYSQL_ROOT_PASSWORD: root-password | |
| MYSQL_DATABASE: testdb | |
| ports: | |
| - 3307:3306 | |
| options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
| env: | |
| env: test | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: change mysql charset | |
| run: mysql -h 127.0.0.1 -P 3307 -u root -p'root-password' -e "ALTER DATABASE testdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" | |
| - name: Install poetry | |
| run: pipx install poetry | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.11 | |
| - name: Set poetry environment & install dependencies | |
| run: | | |
| poetry config virtualenvs.in-project true | |
| poetry env use 3.11 | |
| poetry install --no-root | |
| - name: Run tests | |
| run: | | |
| cd ${GITHUB_WORKSPACE}/wacruit/ | |
| poetry run pytest --junit-xml=${GITHUB_WORKSPACE}/wacruit/test.xml ./ | |
| - name: Test reports | |
| uses: dorny/test-reporter@v1 | |
| if: success() || failure() | |
| with: | |
| name: backend tests | |
| path: "./wacruit/test.xml" | |
| reporter: java-junit | |
| # run pre-commit only different from base branch | |
| # it contains pylint, black, isort, etc. | |
| - name: Run pre-commit | |
| run: | | |
| git fetch origin ${{ github.base_ref }} | |
| poetry run pre-commit run --from-ref origin/${{ github.base_ref }} --to-ref HEAD | |
| - name: Run alembic migration test | |
| run: | | |
| mkdir -p wacruit/src/database/migrations/versions | |
| ls wacruit/src/database/migrations/versions/* || poetry run alembic revision --autogenerate | |
| poetry run alembic upgrade head |