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

Update ruff formatter to work differently between forks and native branches #821

Merged
merged 24 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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