my-sd/.gitea/workflows/run_tests.yaml
soaska 1e4170ea00
Some checks failed
Linter / eslint (push) Failing after 9s
Linter / ruff (push) Successful in 10s
Tests / tests on CPU (push) Failing after 11s
.
2024-05-03 19:41:16 +03:00

114 lines
4.0 KiB
YAML

name: Tests
on:
- push
- pull_request
env:
FORGE_CQ_TEST: "True"
jobs:
test:
name: tests on CPU
runs-on: soaska
if: gitea.event_name != 'pull_request' || gitea.event.pull_request.head.repo.full_name != gitea.event.pull_request.base.repo.full_name
steps:
- name: Prepare env
run: apk add --no-cache nodejs git curl python3 cmake pkgconfig
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
# python-version: 3.10.6
cache: pip
cache-dependency-path: |
**/requirements*txt
launch.py
- name: create venv
run: python -m venv venv
- name: install sentencepiece
run: curl https://github.com/google/sentencepiece/releases/download/v0.2.0/sentencepiece-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -o sentencepiece.whl && venv/bin/pip3 install sentencepiece.whl
- name: Cache models
id: cache-models
uses: actions/cache@v3
with:
path: models
key: "2023-12-30"
- name: Install test dependencies
run: venv/bin/pip3 install wait-for-it -r requirements-test.txt
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_PROGRESS_BAR: "off"
- name: Setup environment
run: venv/bin/python3 launch.py --skip-torch-cuda-test --exit
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_PROGRESS_BAR: "off"
TORCH_INDEX_URL: https://download.pytorch.org/whl/cpu
WEBUI_LAUNCH_LIVE_OUTPUT: "1"
PYTHONUNBUFFERED: "1"
- name: Print installed packages
run: /venv/bin/pip3 freeze
- name: Download models
run: |
declare -a urls=(
"https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/realisticVisionV51_v51VAE.safetensors"
)
for url in "${urls[@]}"; do
filename="models/Stable-diffusion/${url##*/}" # Extracts the last part of the URL
if [ ! -f "$filename" ]; then
curl -Lo "$filename" "$url"
fi
done
# - name: Download ControlNet models
# run: |
# declare -a urls=(
# "https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny.pth"
# )
# for url in "${urls[@]}"; do
# filename="models/ControlNet/${url##*/}" # Extracts the last part of the URL
# if [ ! -f "$filename" ]; then
# curl -Lo "$filename" "$url"
# fi
# done
- name: Start test server
run: >
venv/bin/python3 -m coverage run
--data-file=.coverage.server
launch.py
--skip-prepare-environment
--skip-torch-cuda-test
--test-server
--do-not-download-clip
--no-half
--disable-opt-split-attention
--always-cpu
--api-server-stop
--ckpt models/Stable-diffusion/realisticVisionV51_v51VAE.safetensors
2>&1 | tee output.txt &
- name: Run tests
run: |
wait-for-it --service 127.0.0.1:7860 -t 20
venv/bin/python3 -m pytest -vv --junitxml=test/results.xml --cov . --cov-report=xml --verify-base-url test
# TODO(huchenlei): Enable ControlNet tests. Currently it is too slow to run these tests on CPU with
# real SD model. We need to find a way to load empty SD model.
# - name: Run ControlNet tests
# run: >
# python -m pytest
# --junitxml=test/results.xml
# --cov ./extensions-builtin/sd_forge_controlnet
# --cov-report=xml
# --verify-base-url
# ./extensions-builtin/sd_forge_controlnet/tests
- name: Kill test server
if: always()
run: curl -vv -XPOST http://127.0.0.1:7860/sdapi/v1/server-stop && sleep 10
- name: Upload main app output
uses: actions/upload-artifact@v3
if: always()
with:
name: output
path: output.txt