Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
Update ruff formatter to work differently between forks and native br…
Browse files Browse the repository at this point in the history
…anches (#821)

* add unformatted file

* test github action

* add conditional suggestion

* fix condition

* try again

* try again

* try diff output

* fork repo conditions

* fix format test

* helpful error message

* put it in the name

* shorten sentence

* fix formatting

* revert changes

* consistent behavior to skipping database tests

* ruff format

* verify none

* ruff format

* empty string or none condition

---------

Co-authored-by: Sung Won Chung <[email protected]>
Co-authored-by: Dan Lawin <[email protected]>
  • Loading branch information
3 people authored Jan 2, 2024
1 parent 40b3c87 commit e3f6315
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/formatter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,25 @@ jobs:
uses: actions/checkout@v3
if: github.event_name == 'workflow_dispatch'

- name: Check files using the ruff formatter
# This is used for forked PRs as write permissions are required to format files
- name: Run and commit changes with `ruff format .` locally on your forked branch to fix errors if they appear
if: ${{ github.event.pull_request.head.repo.fork == true }}
uses: chartboost/ruff-action@v1
id: ruff_formatter_suggestions
with:
args: format --diff

# This only runs if the PR is NOT from a forked repo
- name: Format files using ruff
if: ${{ github.event.pull_request.head.repo.fork == false }}
uses: chartboost/ruff-action@v1
id: ruff_formatter
with:
args: format

# This only runs if the PR is NOT from a forked repo
- name: Auto commit ruff formatting
if: ${{ github.event.pull_request.head.repo.fork == false }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'style fixes by ruff'
commit_message: 'style fixes by ruff'
4 changes: 4 additions & 0 deletions tests/test_dbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def test_integration_basic_dbt(self):
# 1 with a diff
assert diff_string.count(" Rows Added Rows Removed") == 1

@unittest.skipIf(
not os.environ.get("MOTHERDUCK_TOKEN"),
"MOTHERDUCK_TOKEN doesn't exist or is empty if this is run from a forked branch pull request",
)
def test_integration_motherduck_dbt(self):
artifacts_path = os.getcwd() + "/tests/dbt_artifacts"
test_project_path = os.environ.get("DATA_DIFF_DBT_PROJ") or artifacts_path
Expand Down

0 comments on commit e3f6315

Please sign in to comment.