Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(test): skip tests on version and changelog changes #1642

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
172 changes: 145 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,51 @@ env:
GHA_CACHE_KEY_VERSION: "v1"

jobs:
check_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check Version
run: |
make check-version

changelog:
runs-on: ubuntu-latest
steps:
# need to checkout otherwise paths-filter will fail on merge-queue trigger
- uses: actions/checkout@v3
- if: github.ref != 'refs/heads/main'
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- 'unstructured/**'
- if: steps.changes.outputs.src == 'true' && github.ref != 'refs/heads/main'
uses: dangoslen/changelog-enforcer@v3

skip_conditions:
runs-on: ubuntu-latest
outputs:
no_code_changes: ${{ steps.version_only_change.outputs.should_skip }}
steps:
- id: version_only_change
uses: fkirc/skip-duplicate-actions@v5
with:
paths_ignore: '["unstructured/__version__.py", "CHANGELOG.md"]'

shellcheck:
runs-on: ubuntu-latest
needs: skip_conditions
if: needs.skip_conditions.outputs.no_code_changes == 'false'
steps:
- uses: actions/checkout@v3
- name: ShellCheck
uses: ludeeus/action-shellcheck@master

setup:
needs: skip_conditions
if: needs.skip_conditions.outputs.no_code_changes == 'false'
strategy:
matrix:
python-version: ["3.8","3.9","3.10","3.11"]
Expand All @@ -39,12 +83,13 @@ jobs:
[ ! -d "$NLTK_DATA" ] && mkdir "$NLTK_DATA"
make install-ci

check-deps:
check_deps:
strategy:
matrix:
python-version: ["3.8","3.9","3.10","3.11"]
runs-on: ubuntu-latest
needs: setup
needs: [setup, skip_conditions]
if: needs.skip_conditions.outputs.no_code_changes == 'false'
steps:
- uses: actions/checkout@v3
- uses: actions/cache/restore@v3
Expand All @@ -69,12 +114,24 @@ jobs:
source .venv/bin/activate
make check-deps

check_deps_result: # report the final result of the check_deps job, so that it can be properly skipped as needed
if: needs.skip_conditions.outputs.no_code_changes == 'false' && always()
runs-on: ubuntu-latest
needs:
- skip_conditions
- check_deps
steps:
- name: Mark result as failed
if: needs.check_deps.result != 'success'
run: exit 1

lint:
strategy:
matrix:
python-version: ["3.8","3.9","3.10","3.11"]
runs-on: ubuntu-latest
needs: setup
needs: [setup, skip_conditions]
if: needs.skip_conditions.outputs.no_code_changes == 'false'
steps:
- uses: actions/checkout@v3
- uses: actions/cache/restore@v3
Expand All @@ -97,14 +154,19 @@ jobs:
- name: Lint
run: |
source .venv/bin/activate
make check
make check-src
make check-tests

shellcheck:
lint_result: # report the final result of the lint job, so that it can be properly skipped as needed
if: needs.skip_conditions.outputs.no_code_changes == 'false' && always()
runs-on: ubuntu-latest
needs:
- skip_conditions
- lint
steps:
- uses: actions/checkout@v3
- name: ShellCheck
uses: ludeeus/action-shellcheck@master
- name: Mark result as failed
if: needs.lint.result != 'success'
run: exit 1

test_unit:
strategy:
Expand All @@ -113,7 +175,8 @@ jobs:
runs-on: ubuntu-latest
env:
NLTK_DATA: ${{ github.workspace }}/nltk_data
needs: [setup, lint]
needs: [setup, skip_conditions, lint]
if: needs.skip_conditions.outputs.no_code_changes == 'false'
steps:
- uses: actions/checkout@v3
- uses: actions/cache/restore@v3
Expand Down Expand Up @@ -150,14 +213,26 @@ jobs:
make test CI=true UNSTRUCTURED_INCLUDE_DEBUG_METADATA=true
make check-coverage

test_unit_result: # report the final result of the test_unit job, so that it can be properly skipped as needed
if: needs.skip_conditions.outputs.no_code_changes == 'false' && always()
runs-on: ubuntu-latest
needs:
- skip_conditions
- test_unit
steps:
- name: Mark result as failed
if: needs.test_unit.result != 'success'
run: exit 1

test_unit_no_extras:
strategy:
matrix:
python-version: ["3.8"]
runs-on: ubuntu-latest
env:
NLTK_DATA: ${{ github.workspace }}/nltk_data
needs: [setup, lint]
needs: [setup, skip_conditions, lint]
if: needs.skip_conditions.outputs.no_code_changes == 'false'
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -185,6 +260,17 @@ jobs:
source .venv-base/bin/activate
make test-no-extras CI=true

test_unit_no_extras_result: # report the final result of the test_unit_no_extras job, so that it can be properly skipped as needed
if: needs.skip_conditions.outputs.no_code_changes == 'false' && always()
runs-on: ubuntu-latest
needs:
- skip_conditions
- test_unit_no_extras
steps:
- name: Mark result as failed
if: needs.test_unit_no_extras.result != 'success'
run: exit 1

test_unit_dependency_extras:
# NOTE(newelh) - Split extras into separate steps in the same pipeline (avoid using matrix)
strategy:
Expand All @@ -194,7 +280,8 @@ jobs:
runs-on: ubuntu-latest
env:
NLTK_DATA: ${{ github.workspace }}/nltk_data
needs: [setup, lint, test_unit_no_extras]
needs: [setup, skip_conditions, lint, test_unit_no_extras]
if: needs.skip_conditions.outputs.no_code_changes == 'false'
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -227,14 +314,26 @@ jobs:
tesseract --version
make test-extra-${{ matrix.extra }} CI=true

test_unit_dependency_extras_result: # report the final result of the test_unit_dependency_extras job, so that it can be properly skipped as needed
if: needs.skip_conditions.outputs.no_code_changes == 'false' && always()
runs-on: ubuntu-latest
needs:
- skip_conditions
- test_unit_dependency_extras
steps:
- name: Mark result as failed
if: needs.test_unit_dependency_extras.result != 'success'
run: exit 1

test_ingest:
strategy:
matrix:
python-version: ["3.8","3.9","3.10","3.11"]
runs-on: ubuntu-latest-m
env:
NLTK_DATA: ${{ github.workspace }}/nltk_data
needs: [setup, lint]
needs: [setup, skip_conditions, lint]
if: needs.skip_conditions.outputs.no_code_changes == 'false'
steps:
- uses: actions/checkout@v3
- uses: actions/cache/restore@v3
Expand Down Expand Up @@ -329,6 +428,17 @@ jobs:
make install-ingest-delta-table
./test_unstructured_ingest/test-ingest.sh

test_ingest_result: # report the final result of the test_ingest job, so that it can be properly skipped as needed
if: needs.skip_conditions.outputs.no_code_changes == 'false' && always()
runs-on: ubuntu-latest
needs:
- skip_conditions
- test_ingest
steps:
- name: Mark result as failed
if: needs.test_ingest.result != 'success'
run: exit 1

test_unstructured_api_unit:
strategy:
matrix:
Expand All @@ -337,7 +447,8 @@ jobs:
runs-on: ubuntu-latest
env:
NLTK_DATA: ${{ github.workspace }}/nltk_data
needs: [setup, lint]
needs: [setup, skip_conditions, lint]
if: needs.skip_conditions.outputs.no_code_changes == 'false'
steps:
- uses: actions/checkout@v3
- uses: actions/cache/restore@v3
Expand Down Expand Up @@ -378,27 +489,23 @@ jobs:
make install-nltk-models
make test-unstructured-api-unit

changelog:
test_unstructured_api_unit_result: # report the final result of the test_unstructured_api_unit job, so that it can be properly skipped as needed
if: needs.skip_conditions.outputs.no_code_changes == 'false' && always()
runs-on: ubuntu-latest
needs:
- skip_conditions
- test_unstructured_api_unit
steps:
# need to checkout otherwise paths-filter will fail on merge-queue trigger
- uses: actions/checkout@v3
- if: github.ref != 'refs/heads/main'
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- 'unstructured/**'

- if: steps.changes.outputs.src == 'true' && github.ref != 'refs/heads/main'
uses: dangoslen/changelog-enforcer@v3
- name: Mark result as failed
if: needs.test_unstructured_api_unit.result != 'success'
run: exit 1

# TODO - figure out best practice for caching docker images
# (Using the virtualenv to get pytest)
test_dockerfile:
runs-on: ubuntu-latest
needs: [ setup, lint ]
needs: [setup, skip_conditions, lint]
if: needs.skip_conditions.outputs.no_code_changes == 'false'
steps:
- uses: actions/checkout@v3
- uses: actions/cache/restore@v3
Expand All @@ -422,3 +529,14 @@ jobs:
echo "UNS_API_KEY=${{ secrets.UNS_API_KEY }}" > uns_test_env_file
make docker-build
make docker-test CI=true UNSTRUCTURED_INCLUDE_DEBUG_METADATA=true

test_dockerfile_result: # report the final result of the test_dockerfile job, so that it can be properly skipped as needed
if: needs.skip_conditions.outputs.no_code_changes == 'false' && always()
runs-on: ubuntu-latest
needs:
- skip_conditions
- test_dockerfile
steps:
- name: Mark result as failed
if: needs.test_dockerfile.result != 'success'
run: exit 1
12 changes: 12 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,21 @@ on:
- cron: '21 21 * * 5'

jobs:
skip_conditions:
runs-on: ubuntu-latest
outputs:
no_code_changes: ${{ steps.version_only_change.outputs.should_skip }}
steps:
- id: version_only_change
uses: fkirc/skip-duplicate-actions@v5
with:
paths_ignore: '["unstructured/__version__.py", "CHANGELOG.md"]'

analyze:
name: Analyze
runs-on: ubuntu-latest
needs: skip_conditions
if: needs.skip_conditions.outputs.no_code_changes == 'false'
permissions:
actions: read
contents: read
Expand Down
Loading