diff --git a/.github/workflows/test-without-model.yml b/.github/workflows/test-without-model.yml index 4b8f0ab..a68cc76 100644 --- a/.github/workflows/test-without-model.yml +++ b/.github/workflows/test-without-model.yml @@ -1,7 +1,7 @@ name: Run Pytest without Model on: - push: - branches: [develop] + pull_request: + types: [opened, reopened, synchronize, ready_for_review] env: WORKING_DIRECTORY: application @@ -38,13 +38,13 @@ jobs: steps: - name: Chekcout code uses: actions/checkout@v4 + # https://docs.github.com/en/actions/learn-github-actions/contexts - name: Check for model changes id: check_changes run: | - BASE_BRANCH=${{ github.base_ref }} - git fetch origin $BASE_BRANCH + git fetch origin ${{ github.base_ref }} MODEL_CHANGED=false - if git diff --name-only origin/$BASE_BRANCH ${{ github.sha }} | grep -q "^${{ env.WORKING_DIRECTORY }}/models/"; then + if git diff --name-only origin/$BASE_BRANCH ${{ github.sha }} | grep -q "^${{ env.WORKING_DIRECTORY }}/application/models/"; then MODEL_CHANGED=true fi echo "MODEL_CHANGED=$MODEL_CHANGED" >> $GITHUB_ENV @@ -54,16 +54,17 @@ jobs: uses: ./.github/actions/set-up-poetry with: working-directory: ${{ env.WORKING_DIRECTORY }} - - name: Run migration - run: | - poetry run python manage.py makemigrations - poetry run python manage.py migrate + # - name: Run migration + # run: | + # poetry run python manage.py makemigrations + # poetry run python manage.py migrate - name: Run Pytest Without Model if: env.MODEL_CHANGED == 'true' run: | set -o pipefail poetry run pytest ${{ env.WORKING_DIRECTORY }}/tests/serializers ${{ env.WORKING_DIRECTORY }}/tests/views --junitxml=pytest.xml -x -n auto --cov --no-cov-on-fail --suppress-no-test-exit-code | tee pytest-coverage.txt - name: Run Pytest + if: env.MODEL_CHANGED == 'false' run: | set -o pipefail poetry run pytest --junitxml=pytest.xml -x -n auto --cov --no-cov-on-fail --suppress-no-test-exit-code | tee pytest-coverage.txt