From 0ee88be55d6ef6c8ec92347181e5fa5fc1d2bbc1 Mon Sep 17 00:00:00 2001 From: shun198 Date: Sun, 9 Jun 2024 22:01:47 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8D=20add=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test-without-model.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) 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