Skip to content

Commit

Permalink
CI: Skip running tests when only docs changes are detected (#225)
Browse files Browse the repository at this point in the history
* CI: Skip running tests when only docs changes are detected
  • Loading branch information
burnash authored Apr 5, 2023
1 parent 08eabd1 commit ba39802
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 2 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/get_docs_changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: get docs changes

on:
workflow_call:
outputs:
changes_outside_docs:
description: "Changes outside docs"
value: ${{ jobs.get_docs_changes.outputs.changes_outside_docs }}

jobs:
get_docs_changes:
runs-on: ubuntu-latest
outputs:
changes_outside_docs: ${{ steps.check_changes.outputs.changes_outside_docs }}

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Check changes outside docs
id: check_changes
run: |
echo "base.sha: ${{ github.event.pull_request.base.sha }}"
echo "head.sha: ${{ github.event.pull_request.head.sha }}"
changes_outside_docs=$(
git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} \
| grep -v '^docs/' || true
)
echo $changes_outside_docs
if [ -z "$changes_outside_docs" ]; then
echo "No changes outside docs. Skipping tests."
echo "changes_outside_docs=false" >> $GITHUB_OUTPUT
else
echo "Changes detected outside docs."
echo "changes_outside_docs=true" >> $GITHUB_OUTPUT
fi
5 changes: 5 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ on:
workflow_dispatch:

jobs:
get_docs_changes:
uses: ./.github/workflows/get_docs_changes.yml

run_lint:
name: Runs mypy, flake and bandit
needs: get_docs_changes
if: needs.get_docs_changes.outputs.changes_outside_docs == 'true'

runs-on: ubuntu-latest

steps:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test_common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ env:
RUNTIME__LOG_LEVEL: ERROR

jobs:
get_docs_changes:
uses: ./.github/workflows/get_docs_changes.yml

run_common:
name: Tests common dlt code
needs: get_docs_changes
if: needs.get_docs_changes.outputs.changes_outside_docs == 'true'
strategy:
fail-fast: false
matrix:
Expand All @@ -25,7 +29,6 @@ jobs:
runs-on: ${{ matrix.os }}

steps:

- name: Check out
uses: actions/checkout@master

Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test_dbt_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ env:
RUNTIME__LOG_LEVEL: ERROR

jobs:
get_docs_changes:
uses: ./.github/workflows/get_docs_changes.yml

run_dbt:
name: Tests dbt runner
needs: get_docs_changes
if: needs.get_docs_changes.outputs.changes_outside_docs == 'true'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -85,4 +89,4 @@ jobs:
poetry run pytest tests/helpers/dbt_tests --ignore=tests/helpers/dbt_tests/local -m "not forked" -k "(not local)"
if: runner.os == 'Windows'
name: Run dbt runner with venv - Windows
shell: cmd
shell: cmd
4 changes: 4 additions & 0 deletions .github/workflows/test_destination_bigquery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ env:
RUNTIME__LOG_LEVEL: ERROR

jobs:
get_docs_changes:
uses: ./.github/workflows/get_docs_changes.yml

run_loader:
name: Tests BigQuery loader
needs: get_docs_changes
if: needs.get_docs_changes.outputs.changes_outside_docs == 'true'
strategy:
fail-fast: false
matrix:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test_destinations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ env:
RUNTIME__DLTHUB_TELEMETRY_SEGMENT_WRITE_KEY: TLJiyRkGVZGCi2TtjClamXpFcxAA1rSB

jobs:
get_docs_changes:
uses: ./.github/workflows/get_docs_changes.yml

run_loader:
name: test destinations redshift, postgres and duckdb
needs: get_docs_changes
if: needs.get_docs_changes.outputs.changes_outside_docs == 'true'
strategy:
fail-fast: false
matrix:
Expand Down

0 comments on commit ba39802

Please sign in to comment.