From 01f2da2a59cbda6de84c5a6b666ae204e52b1c7b Mon Sep 17 00:00:00 2001 From: Ryan Nikolaidis <1208590+ryannikolaidis@users.noreply.github.com> Date: Thu, 28 Sep 2023 10:25:59 -0700 Subject: [PATCH] break out lint rename ci->test remove cache version key --- .github/workflows/lint.yml | 75 ++++++++++++++++++++++++++ .github/workflows/{ci.yml => test.yml} | 52 ++++-------------- 2 files changed, 84 insertions(+), 43 deletions(-) create mode 100644 .github/workflows/lint.yml rename .github/workflows/{ci.yml => test.yml} (88%) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000000..06c89dc2d3 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,75 @@ +name: Lint + +on: + pull_request: + branches: [ main ] + push: + branches: [ main ] + merge_group: + branches: [ main ] + +jobs: + setup: + strategy: + matrix: + python-version: ["3.8","3.9","3.10","3.11"] + runs-on: ubuntu-latest + env: + NLTK_DATA: ${{ github.workspace }}/nltk_data + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + id: virtualenv-cache + with: + path: | + .venv + nltk_data + key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt') }} + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Setup virtual environment (no cache hit) + run: | + python${{ matrix.python-version }} -m venv .venv + source .venv/bin/activate + [ ! -d "$NLTK_DATA" ] && mkdir "$NLTK_DATA" + make install-ci + + lint: + strategy: + matrix: + python-version: ["3.8","3.9","3.10","3.11"] + runs-on: ubuntu-latest + needs: setup + steps: + - uses: actions/checkout@v3 + - uses: actions/cache/restore@v3 + id: virtualenv-cache + with: + path: | + .venv + nltk_data + key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt') }} + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Setup virtual environment (no cache hit) + if: steps.virtualenv-cache.outputs.cache-hit != 'true' + run: | + python${{ matrix.python-version }} -m venv .venv + source .venv/bin/activate + make install-ci + - name: Lint + run: | + source .venv/bin/activate + make check-tests + make check-src + + shellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: ShellCheck + uses: ludeeus/action-shellcheck@master diff --git a/.github/workflows/ci.yml b/.github/workflows/test.yml similarity index 88% rename from .github/workflows/ci.yml rename to .github/workflows/test.yml index 270259dc64..72978b95e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: CI +name: Test on: push: @@ -8,9 +8,6 @@ on: merge_group: branches: [ main ] -env: - GHA_CACHE_KEY_VERSION: "v1" - jobs: setup: strategy: @@ -27,7 +24,7 @@ jobs: path: | .venv nltk_data - key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ env.GHA_CACHE_KEY_VERSION }}-${{ hashFiles('requirements/*.txt') }} + key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt') }} - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -53,7 +50,7 @@ jobs: path: | .venv nltk_data - key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ env.GHA_CACHE_KEY_VERSION }}-${{ hashFiles('requirements/*.txt') }} + key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt') }} - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -69,37 +66,6 @@ jobs: source .venv/bin/activate make check-deps - lint: - strategy: - matrix: - python-version: ["3.8","3.9","3.10","3.11"] - runs-on: ubuntu-latest - needs: setup - steps: - - uses: actions/checkout@v3 - - uses: actions/cache/restore@v3 - id: virtualenv-cache - with: - path: | - .venv - nltk_data - key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ env.GHA_CACHE_KEY_VERSION }}-${{ hashFiles('requirements/*.txt') }} - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Setup virtual environment (no cache hit) - if: steps.virtualenv-cache.outputs.cache-hit != 'true' - run: | - python${{ matrix.python-version }} -m venv .venv - source .venv/bin/activate - make install-ci - - name: Lint - run: | - source .venv/bin/activate - make check-tests - make check-src - shellcheck: runs-on: ubuntu-latest steps: @@ -123,7 +89,7 @@ jobs: path: | .venv nltk_data - key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ env.GHA_CACHE_KEY_VERSION }}-${{ hashFiles('requirements/*.txt') }} + key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt') }} - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -171,7 +137,7 @@ jobs: path: | nltk_data .venv-base - key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ env.GHA_CACHE_KEY_VERSION }}-${{ hashFiles('requirements/*.txt') }}-base + key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt') }}-base - name: Setup virtual environment if: steps.virtualenv-cache.outputs.cache-hit != 'true' run: | @@ -207,7 +173,7 @@ jobs: with: path: | nltk_data - key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ env.GHA_CACHE_KEY_VERSION }}-${{ hashFiles('requirements/*.txt') }}-base + key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt') }}-base - name: Setup virtual environment run: | python${{ matrix.python-version}} -m venv .venv-${{ matrix.extra }} @@ -244,7 +210,7 @@ jobs: path: | .venv nltk_data - key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ env.GHA_CACHE_KEY_VERSION }}-${{ hashFiles('requirements/*.txt') }} + key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt') }} - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -342,7 +308,7 @@ jobs: path: | .venv nltk_data - key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ env.GHA_CACHE_KEY_VERSION }}-${{ hashFiles('requirements/*.txt') }} + key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt') }} - name: Set up flag for running Unstructured API unit tests run: | # NOTE: Change env `SKIP_API_UNIT_FOR_BREAKING_CHANGE` to true if there is a breaking change in Unstructured repo that will break unstructured api unit tests @@ -387,7 +353,7 @@ jobs: path: | .venv nltk_data - key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ env.GHA_CACHE_KEY_VERSION }}-${{ hashFiles('requirements/*.txt') }} + key: unstructured-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt') }} - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: