name: Test invoke.py on: push: branches: - 'main' - 'development' - 'fix-gh-actions-fork' pull_request: branches: - 'main' - 'development' jobs: matrix: strategy: fail-fast: false matrix: stable-diffusion-model: # - 'https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt' - 'https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt' os: - ubuntu-latest - macOS-12 include: - os: ubuntu-latest environment-file: environment-lin-cuda.yml default-shell: bash -l {0} - os: macOS-12 environment-file: environment-mac.yml default-shell: bash -l {0} # - stable-diffusion-model: https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt # stable-diffusion-model-dl-path: models/ldm/stable-diffusion-v1/sd-v1-4.ckpt # stable-diffusion-model-switch: stable-diffusion-1.4 - stable-diffusion-model: https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt stable-diffusion-model-dl-path: models/ldm/stable-diffusion-v1/v1-5-pruned-emaonly.ckpt stable-diffusion-model-switch: stable-diffusion-1.5 name: ${{ matrix.os }} with ${{ matrix.stable-diffusion-model-switch }} runs-on: ${{ matrix.os }} env: CONDA_ENV_NAME: invokeai defaults: run: shell: ${{ matrix.default-shell }} steps: - name: Checkout sources id: checkout-sources uses: actions/checkout@v3 - name: create models.yaml from example run: cp configs/models.yaml.example configs/models.yaml - name: create environment.yml run: cp environments-and-requirements/${{ matrix.environment-file }} environment.yml - name: Use cached conda packages id: use-cached-conda-packages uses: actions/cache@v3 with: path: ~/conda_pkgs_dir key: conda-pkgs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles(matrix.environment-file) }} - name: Activate Conda Env id: activate-conda-env uses: conda-incubator/setup-miniconda@v2 with: activate-environment: ${{ env.CONDA_ENV_NAME }} environment-file: environment.yml miniconda-version: latest - name: set test prompt to main branch validation if: ${{ github.ref == 'refs/heads/main' }} run: echo "TEST_PROMPTS=tests/preflight_prompts.txt" >> $GITHUB_ENV - name: set test prompt to development branch validation if: ${{ github.ref == 'refs/heads/development' }} run: echo "TEST_PROMPTS=tests/dev_prompts.txt" >> $GITHUB_ENV - name: set test prompt to Pull Request validation if: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/development' }} run: echo "TEST_PROMPTS=tests/validate_pr_prompt.txt" >> $GITHUB_ENV - name: Use Cached Stable Diffusion Model id: cache-sd-model uses: actions/cache@v3 env: cache-name: cache-${{ matrix.stable-diffusion-model-switch }} with: path: ${{ matrix.stable-diffusion-model-dl-path }} key: ${{ env.cache-name }} - name: Download ${{ matrix.stable-diffusion-model-switch }} id: download-stable-diffusion-model if: ${{ steps.cache-sd-model.outputs.cache-hit != 'true' }} run: | [[ -d models/ldm/stable-diffusion-v1 ]] \ || mkdir -p models/ldm/stable-diffusion-v1 curl \ -H "Authorization: Bearer ${{ secrets.HUGGINGFACE_TOKEN }}" \ -o ${{ matrix.stable-diffusion-model-dl-path }} \ -L ${{ matrix.stable-diffusion-model }} - name: run preload_models.py id: run-preload-models run: | python scripts/preload_models.py \ --no-interactive - name: Run the tests id: run-tests run: | time python scripts/invoke.py \ --model ${{ matrix.stable-diffusion-model-switch }} \ --from_file ${{ env.TEST_PROMPTS }} - name: export conda env id: export-conda-env run: | mkdir -p outputs/img-samples conda env export --name ${{ env.CONDA_ENV_NAME }} > outputs/img-samples/environment-${{ runner.os }}-${{ runner.arch }}.yml - name: Archive results id: archive-results uses: actions/upload-artifact@v3 with: name: results_${{ matrix.os }}_${{ matrix.stable-diffusion-model-switch }} path: outputs/img-samples