Skip to content

Commit

Permalink
👍 add workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
shun198 committed Jun 9, 2024
1 parent 1cc8cd5 commit 0ee88be
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/test-without-model.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 0ee88be

Please sign in to comment.