Skip to content

Commit

Permalink
Reusable integration tests. Separate pydantic v1. Update action versi…
Browse files Browse the repository at this point in the history
…ons.
  • Loading branch information
marius-baseten committed Jul 5, 2024
1 parent 0c68f0c commit 1400c90
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .github/actions/setup-python/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: "setups python, poetry and associated cache"
runs:
using: "composite"
steps:
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9.9'

Expand All @@ -22,7 +22,7 @@ runs:
shell: bash

- name: Set up cache
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: .venv
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-context-builder-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
outputs:
version: ${{ steps.versions.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# We need to use a different github token because GITHUB_TOKEN cannot trigger a workflow from another
token: ${{secrets.BASETENBOT_GITHUB_TOKEN}}
Expand All @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-20.04
needs: [detect-version]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/commit_new_release_to_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ secrets.BASETENBOT_GITHUB_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create_release_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install poetry
run: |
Expand Down
39 changes: 8 additions & 31 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
release_version: ${{ steps.versions.outputs.release_version }}
is_prerelease_version: ${{ steps.versions.outputs.is_prerelease_version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# We need to use a different github token because GITHUB_TOKEN cannot trigger a workflow from another
token: ${{secrets.BASETENBOT_GITHUB_TOKEN}}
Expand All @@ -44,7 +44,7 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-python/
- run: poetry install
- shell: bash
Expand All @@ -56,32 +56,9 @@ jobs:
--version-tag ${{ needs.detect-version-changed.outputs.new_base_image_version }} \
--skip-login --push
integration-tests:
needs: [detect-version-changed, build-and-push-truss-base-images-if-needed]
if: ${{ !failure() && !cancelled() && (needs.build-and-push-truss-base-images-if-needed.result == 'success' || needs.build-and-push-truss-base-images-if-needed.result == 'skipped') }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
split_group: ["1", "2", "3", "4", "5"]
steps:
- name: Purge Docker cache
run: docker builder prune -af
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-python/
- run: poetry install
- run: poetry run pytest truss/tests --durations=0 -m 'integration' --splits 5 --group ${{ matrix.split_group }}

chain-integration-tests:
needs: [detect-version-changed, build-and-push-truss-base-images-if-needed]
if: ${{ !failure() && !cancelled() && (needs.build-and-push-truss-base-images-if-needed.result == 'success' || needs.build-and-push-truss-base-images-if-needed.result == 'skipped') }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
steps:
- name: Purge Docker cache
run: docker builder prune -af
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-python/
- run: poetry install
- run: poetry run pytest truss-chains/tests -s --log-cli-level=INFO --durations=0 -m 'integration'
jobs:
integration-tests:
needs: [detect-version-changed, build-and-push-truss-base-images-if-needed]
uses: ./.github/workflows/shared/integration-tests.yml
with:
build-and-push-truss-base-images-if-needed-result: ${{ needs.build-and-push-truss-base-images-if-needed.result }}
20 changes: 6 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
release_version: ${{ steps.versions.outputs.release_version }}
is_prerelease_version: ${{ steps.versions.outputs.is_prerelease_version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# We need to use a different github token because GITHUB_TOKEN cannot trigger a workflow from another
token: ${{secrets.BASETENBOT_GITHUB_TOKEN}}
Expand All @@ -47,7 +47,7 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-python/
- run: poetry install
- shell: bash
Expand All @@ -61,25 +61,17 @@ jobs:
integration-tests:
needs: [detect-version-changed, build-and-push-truss-base-images-if-needed]
if: ${{ !failure() && !cancelled() && (needs.build-and-push-truss-base-images-if-needed.result == 'success' || needs.build-and-push-truss-base-images-if-needed.result == 'skipped') }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
split_group: ["1", "2", "3", "4", "5"]
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-python/
- run: poetry install
- run: poetry run pytest truss/tests -m 'integration' --splits 5 --group ${{ matrix.split_group }}
uses: ./.github/workflows/shared/integration-tests.yml
with:
build-and-push-truss-base-images-if-needed-result: ${{ needs.build-and-push-truss-base-images-if-needed.result }}

publish-to-pypi:
needs: [detect-version-changed]
if: ${{ !failure() && !cancelled() && needs.detect-version-changed.outputs.release_version == 'true' && needs.detect-version-changed.outputs.is_prerelease_version == 'true' }}
runs-on: ubuntu-20.04
steps:
- name: "Git tag release"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{secrets.BASETENBOT_GITHUB_TOKEN}}
- run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-truss-utils.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: "Git tag release"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{secrets.BASETENBOT_GITHUB_TOKEN}}

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
release_version: ${{ steps.versions.outputs.release_version }}
is_prerelease_version: ${{ steps.versions.outputs.is_prerelease_version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# We need to use a different github token because GITHUB_TOKEN cannot trigger a workflow from another
token: ${{secrets.BASETENBOT_GITHUB_TOKEN}}
Expand All @@ -33,7 +33,7 @@ jobs:
if: ${{ !failure() && !cancelled() && needs.detect-version-changed.outputs.release_version == 'true' }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: "Git tag release"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{secrets.BASETENBOT_GITHUB_TOKEN}}
- run: |
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/shared/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Integration Tests

on:
workflow_call:
inputs:
build-and-push-truss-base-images-if-needed-result:
required: true
type: string

jobs:
integration-tests:
if: ${{ !failure() && !cancelled() && (build-and-push-truss-base-images-if-needed-result == 'success' || build-and-push-truss-base-images-if-needed-result == 'skipped') }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
split_group: ["1", "2", "3", "4", "5"]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-python/
- run: poetry install
- run: poetry run pytest truss/tests --durations=0 -m 'integration' --splits 5 --group ${{ matrix.split_group }} -k "not test_requirements_pydantic[1]"

integration-tests-pydantic-v1:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-python/
- run: poetry install
- run: poetry run pytest truss/tests/test_model_inference.py::test_requirements_pydantic[1]

chain-integration-tests:
if: ${{ !failure() && !cancelled() && (build-and-push-truss-base-images-if-needed-result == 'success' || build-and-push-truss-base-images-if-needed-result == 'skipped') }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-python/
- run: poetry install
- run: poetry run pytest truss-chains/tests -s --log-cli-level=INFO --durations=0 -m 'integration'

0 comments on commit 1400c90

Please sign in to comment.