Skip to content

Commit

Permalink
include common directory in tests on path changes
Browse files Browse the repository at this point in the history
Signed-off-by: greg pereira <[email protected]>
  • Loading branch information
Gregory-Pereira committed Apr 13, 2024
1 parent 999093d commit f8cbaf1
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/chatbot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ on:
branches:
- main
paths:
- ./recipes/common/Makefile.common
- ./recipes/natural_language_processing/chatbot/**
- .github/workflows/chatbot.yaml
push:
branches:
- main
paths:
- ./recipes/common/Makefile.common
- ./recipes/natural_language_processing/chatbot/**
- .github/workflows/chatbot.yaml

Expand All @@ -22,6 +24,7 @@ env:

jobs:
build-and-push-image:
if: "!contains(github.event.pull_request.labels.*.name, 'hold-tests')"
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/codegen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ on:
branches:
- main
paths:
- ./recipes/common/Makefile.common
- ./recipes/natural_language_processing/codegen/**
- .github/workflows/codegen.yaml
push:
branches:
- main
paths:
- ./recipes/common/Makefile.common
- ./recipes/natural_language_processing/codegen/**
- .github/workflows/codegen.yaml

Expand All @@ -22,6 +24,7 @@ env:

jobs:
build-and-push-image:
if: "!contains(github.event.pull_request.labels.*.name, 'hold-tests')"
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -59,8 +62,8 @@ jobs:
run: make install

- name: Download model
working-directory: ./model_servers/llamacpp_python
run: make mistral
working-directory: ./recipes/natural_language_processing/${{ env.IMAGE_NAME }}
run: make download-model-mistral

- name: Run Functional Tests
shell: bash
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/model_image_build_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ env:

jobs:
build-and-push-model-converter-image:
if: "!contains(github.event.pull_request.labels.*.name, 'hold-tests')"
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -61,6 +62,7 @@ jobs:
tags: ${{ steps.build_convert_models_image.outputs.tags }}

build-and-push-mistral-model-image:
if: contains( github.event.pull_request.labels.*.name, 'hold-tests')
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/model_servers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
paths:
- ./model_servers/
- ./model_servers/**
- .github/workflows/model_servers.yaml
push:
branches:
Expand All @@ -22,6 +22,7 @@ env:

jobs:
build-and-push-image:
if: "!contains(github.event.pull_request.labels.*.name, 'hold-tests')"
strategy:
matrix:
include:
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/rag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ on:
branches:
- main
paths:
- ./recipes/common/Makefile.common
- ./recipes/natural_language_processing/rag/**
- .github/workflows/rag.yaml
push:
branches:
- main
paths:
- ./recipes/common/Makefile.common
- ./recipes/natural_language_processing/rag/**
- .github/workflows/rag.yaml

Expand All @@ -22,6 +24,7 @@ env:

jobs:
build-and-push-image:
if: "!contains(github.event.pull_request.labels.*.name, 'hold-tests')"
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -64,8 +67,8 @@ jobs:
run: make install

- name: Download model
working-directory: ./model_servers/llamacpp_python
run: make mistral
working-directory: ./recipes/natural_language_processing/${{ env.IMAGE_NAME }}
run: make download-model-mistral

- name: Run Functional Tests
shell: bash
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/summarizer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ on:
branches:
- main
paths:
- ./recipes/common/Makefile.common
- ./recipes/natural_language_processing/summarizer/**
- .github/workflows/summarizer.yaml
push:
branches:
- main
paths:
- ./recipes/common/Makefile.common
- ./recipes/natural_language_processing/summarizer/**
- .github/workflows/summarizer.yaml

Expand All @@ -22,6 +24,7 @@ env:

jobs:
build-and-push-image:
if: "!contains(github.event.pull_request.labels.*.name, 'hold-tests')"
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -59,8 +62,8 @@ jobs:
run: make install

- name: Download model
working-directory: ./model_servers/llamacpp_python
run: make mistral
working-directory: ./recipes/natural_language_processing/${{ env.IMAGE_NAME }}
run: make download-model-mistral

- name: Run Functional Tests
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ models/*
!models/Makefile
!models/README.md
convert_models/converted_models
recipes/chromedriver
recipes/Google\ Chrome.app
recipes/common/bin/*
*/.venv/
29 changes: 15 additions & 14 deletions recipes/common/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ endif
CHROMEDRIVER_VERSION := 103.0.5060.53
CHROMEDRIVER_MIRROR := https://chromedriver.storage.googleapis.com
CHROMEDRIVER_DOWNLOAD_PATH :=
CHROMEDRIVER_INSTALLATION_PATH ?=
RECIPE_BINARIES_PATH ?=
CHROME_DOWNLOAD_PATH ?=

OS := $(shell uname -s)
Expand All @@ -51,7 +51,7 @@ endif

CHROME_MIRROR := https://www.slimjet.com/chrome/files/$(CHROMEDRIVER_VERSION)/$(CHROME_DOWNLOAD_PATH)

LOCAL_CHROMEDRIVER_EXISTS ?= $(shell command -v $(CHROMEDRIVER_INSTALLATION_PATH)/chromedriver)
LOCAL_CHROMEDRIVER_EXISTS ?= $(shell command -v $(RECIPE_BINARIES_PATH)/chromedriver)
UNZIP_EXISTS ?= $(shell command -v unzip)

RELATIVE_MODELS_PATH := ?=
Expand All @@ -68,9 +68,9 @@ download-model-mistral:
make MODEL_NAME=mistral-7b-instruct-v0.1.Q4_K_M.gguf MODEL_URL=https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF/resolve/main/mistral-7b-instruct-v0.1.Q4_K_M.gguf -f Makefile download-model

.PHONY: install
install:
$(MAKE) install-chromedriver CHROMEDRIVER_INSTALLATION_PATH=${CHROMEDRIVER_INSTALLATION_PATH}
$(MAKE) install-chrome CHROMEDRIVER_INSTALLATION_PATH=${CHROMEDRIVER_INSTALLATION_PATH}
install::
$(MAKE) install-chromedriver RECIPE_BINARIES_PATH=${RECIPE_BINARIES_PATH}
# $(MAKE) install-chrome RECIPE_BINARIES_PATH=${RECIPE_BINARIES_PATH}
pip install -q -r ${RELATIVE_TESTS_PATH}/requirements.txt

.PHONY: build
Expand Down Expand Up @@ -129,9 +129,9 @@ bootc-image-builder: bootc
install-chromedriver:
@if [[ -z "$(LOCAL_CHROMEDRIVER_EXISTS)" ]]; then \
if [[ -n "$(UNZIP_EXISTS)" ]]; then \
curl -sLO $(CHROMEDRIVER_MIRROR)/$(CHROMEDRIVER_VERSION)/$(CHROMEDRIVER_DOWNLOAD_PATH); \
curl --max-time 300 --connect-timeout 60 -sLO $(CHROMEDRIVER_MIRROR)/$(CHROMEDRIVER_VERSION)/$(CHROMEDRIVER_DOWNLOAD_PATH); \
unzip $(CHROMEDRIVER_DOWNLOAD_PATH); \
mv chromedriver $(CHROMEDRIVER_INSTALLATION_PATH); \
mv chromedriver $(RECIPE_BINARIES_PATH)/; \
rm ./$(CHROMEDRIVER_DOWNLOAD_PATH); \
elif [[ -z "$(UNZIP_EXISTS)" ]]; then \
echo "Install make target requires unizp binary."; \
Expand All @@ -141,14 +141,15 @@ install-chromedriver:

.PHONY: install-chrome
install-chrome:
curl -sLO $(CHROME_MIRROR)
curl --max-time 300 --connect-timeout 60 -sLO $(CHROME_MIRROR)
@if [[ "$(OS)" == "Linux" ]]; then \
sudo dpkg -i $(CHROME_DOWNLOAD_PATH); \
elif [[ "$(OS)" == "Darwin" ]]; then \
open $(CHROME_DOWNLOAD_PATH); \
ls "/Volumes/Google Chrome/Google Chrome.app/Contents/MacOS/Google Chrome"; \
cp -r "/Volumes/Google Chrome/Google Chrome.app" "$(RECIPE_BINARIES_PATH)/"; \
diskutil unmount "/Volumes/Google Chrome" || true; \
rm $(CHROME_DOWNLOAD_PATH); \
cp -r /Volumes/Google\ Chrome/Google\ Chrome.app $(CHROMEDRIVER_INSTALLATION_PATH); \
diskutil unmount /Volumes/Google\ Chrome; \
fi;

.PHONY: quadlet
Expand Down Expand Up @@ -193,20 +194,20 @@ check-model-in-path:
functional-tests:
$(MAKE) MODEL_NAME=$(MODEL_NAME) check-model-in-path
@if [[ -n "$(LOCAL_CHROMEDRIVER_EXISTS)" ]]; then \
IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} MODEL_NAME=${MODEL_NAME} pytest -vvv --driver=Chrome --driver-path=$(CHROMEDRIVER_INSTALLATION_PATH)/chromedriver ${RELATIVE_TESTS_PATH}/functional; \
IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} MODEL_NAME=${MODEL_NAME} pytest -vvv --driver=Chrome --driver-path=$(RECIPE_BINARIES_PATH)/chromedriver ${RELATIVE_TESTS_PATH}/functional; \
else \
echo "fetching chromedriver"; \
make install; \
IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} MODEL_NAME=${MODEL_NAME} pytest -vvv --driver=Chrome --driver-path=$(CHROMEDRIVER_INSTALLATION_PATH)/chromedriver ${RELATIVE_TESTS_PATH}/functional; \
IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} MODEL_NAME=${MODEL_NAME} pytest -vvv --driver=Chrome --driver-path=$(RECIPE_BINARIES_PATH)/chromedriver ${RELATIVE_TESTS_PATH}/functional; \
fi;

.PHONY: integration-tests
integration-tests:
@if [[ -n "$(LOCAL_CHROMEDRIVER_EXISTS)" ]]; then \
URL=${URL} IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} pytest -vvv --driver=Chrome --driver-path=$(CHROMEDRIVER_INSTALLATION_PATH)/chromedriver ${RELATIVE_TESTS_PATH}/integration; \
URL=${URL} IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} pytest -vvv --driver=Chrome --driver-path=$(RECIPE_BINARIES_PATH)/chromedriver ${RELATIVE_TESTS_PATH}/integration; \
else \
echo "fetching chromedriver"; \
make install; \
URL=${URL} IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} pytest -vvv --driver=Chrome --driver-path=$(CHROMEDRIVER_INSTALLATION_PATH)/chromedriver ${RELATIVE_TESTS_PATH}/integration; \
URL=${URL} IMAGE_NAME=${IMAGE_NAME} REGISTRY=${REGISTRY} pytest -vvv --driver=Chrome --driver-path=$(RECIPE_BINARIES_PATH)/chromedriver ${RELATIVE_TESTS_PATH}/integration; \
fi;

Empty file added recipes/common/bin/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion recipes/natural_language_processing/chatbot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ PORT ?= 8501

include ../../common/Makefile.common

CHROMEDRIVER_INSTALLATION_PATH := $(shell realpath ../..)
RECIPE_BINARIES_PATH := $(shell realpath ../../common/bin)
RELATIVE_MODELS_PATH := ../../../models
RELATIVE_TESTS_PATH := ../tests

0 comments on commit f8cbaf1

Please sign in to comment.