diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0c7fcf9..b63c428 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,3 +8,5 @@ repos: language: python pass_filenames: false additional_dependencies: [pyyaml, tabulate] # Add this line to specify the dependency + exclude: ^((?!main).)*$ + diff --git a/action.yml b/action.yml index ef8fb39..85f3fac 100644 --- a/action.yml +++ b/action.yml @@ -84,149 +84,30 @@ runs: ## | ----------- ::: | `-' `--' ## ## `-----------------------' ## ############################################################ - - name: '[Unix] Auth to GCS' - uses: "google-github-actions/auth@v2" - if: ${{ inputs.os != 'windows' }} - with: - credentials_json: "${{ inputs.google_credentials }}" - - name: '[Unix] Setup Conda' - uses: conda-incubator/setup-miniconda@v3.0.3 - if: ${{ inputs.os != 'windows' }} + - name: Set up Node.js (required for using actions/github-script) + uses: actions/setup-node@v2 with: - activate-environment: gha-comfyui-${{ inputs.python_version }}-${{ inputs.torch_version }} - miniconda-version: "latest" - auto-activate-base: false - python-version: ${{ inputs.python_version }} - - - name: '[Unix-Mac-Only] Install Pytorch nightly' - if: ${{ inputs.os == 'macos' }} - shell: bash -el {0} - run: | - conda install pytorch torchvision torchaudio -c pytorch-nightly - - - name: '[Unix-Linux-Only] Install Pytorch' - if: ${{ inputs.os == 'linux' }} - shell: bash -el {0} - run: | - conda install pytorch torchvision torchaudio pytorch-cuda=${{ inputs.cuda_version}} -c pytorch -c nvidia - - - name: '[Unix] Install dependencies' - if: ${{ inputs.os != 'windows' }} - shell: bash -el {0} - run: | - which pip3 - pip3 install -r requirements.txt - - - name: '[Unix] Check conda environment' - if: ${{ inputs.os != 'windows' }} - run: | - conda info - conda list - shell: bash -el {0} - - - name: '[Unix] Download models' - if: ${{ inputs.os != 'windows' }} - shell: bash -el {0} - run: | - cd ${{ github.action_path }} - pip3 install -r requirements.txt - python default-models-prep.py --cache-directory ~/.cache/comfy-actions-runner/modelcache --live-directory "$GITHUB_WORKSPACE/models" - - - name: '[Unix] Run ComfyUI quick test' - if: ${{ inputs.os != 'windows' && inputs.skip_quick_ci != 'true' }} - shell: bash -el {0} - run: | - python3 main.py --quick-test-for-ci - - - name: '[Unix] Run ComfyUI' - if: ${{ inputs.os != 'windows' }} - shell: bash -el {0} - run: | - python3 main.py > application.log 2>&1 & - - - name: '[Unix] Check if the server is running' - if: ${{ inputs.os != 'windows' }} - run: | - cd ${{ github.action_path }} - python3 poll_server_start.py > application.log 2>&1 - shell: bash -el {0} - - - name: '[Unix] Get Commit Details' - id: unix_get_commit_details - if: ${{ inputs.os != 'windows' }} - shell: bash -el {0} - run: | - TIMESTAMP=$(git show -s --format=%cI HEAD^) - MESSAGE=$(git show -s --format=%s HEAD^) - COMMIT_HASH=$(git rev-parse HEAD^) - echo "Commit time: $TIMESTAMP" - echo "Commit title: $MESSAGE" - echo "Commit hash: $COMMIT_HASH" - echo "commit_time=$TIMESTAMP" >> $GITHUB_OUTPUT - echo "commit_title=$MESSAGE" >> $GITHUB_OUTPUT - echo "commit_hash=$COMMIT_HASH" >> $GITHUB_OUTPUT - - - name: '[Unix] Run Python Action' - id: unix_action - if: ${{ inputs.os != 'windows' }} - shell: bash -el {0} - run: | - cd ${{ github.action_path }} - echo "Running workflows: ${{ inputs.workflow_filenames }}" - python3 action.py \ - --comfy-workflow-names ${{ inputs.workflow_filenames }} \ - --github-action-workflow-name "${{ github.workflow }}" \ - --os "${{ inputs.os }}" \ - --run-id "${{ github.run_id }}" \ - --gsc-bucket-name "${{ inputs.gcs_bucket_name }}" \ - --workspace-path "${{ github.workspace }}" \ - --output-file-prefix ${{ inputs.output_prefix }} \ - --repo "${{ github.repository }}" \ - --commit-hash "${{ steps.unix_get_commit_details.outputs.commit_hash }}" \ - --commit-time "${{ steps.unix_get_commit_details.outputs.commit_time }}" \ - --commit-message "${{ steps.unix_get_commit_details.outputs.commit_title }}" \ - --branch-name "${{ github.ref_name }}" \ - --api-endpoint "${{ inputs.api_endpoint }}" \ - ${{ inputs.comfyui_flags }} + node-version: '14' - # - name: '[Unix] Sleep for 10 minutes on failure' - # if: ${{ inputs.os != 'windows' && failure() }} - # shell: "bash" - # run: sleep 600 - - - name: '[Unix] Upload Output Files' - uses: actions/upload-artifact@v4 - if: ${{ inputs.os != 'windows' && ( success() || failure() ) }} - with: - name: output-files-${{ github.job }}-${{ inputs.os }}-${{inputs.workflow_name}}-${{ github.run_id }} - path: ${{ github.workspace }}/output/** - - - name: '[Unix] Upload log file to GCS' - if: ${{ inputs.os != 'windows' && ( success() || failure() ) }} - id: unix_upload-log-files - uses: google-github-actions/upload-cloud-storage@v2 - with: - path: ${{ github.workspace }}/application.log - destination: ${{ inputs.gcs_bucket_name }}/logs/${{ github.job }}-${{ inputs.os }}-${{ inputs.workflow_name }}-run${{ github.run_id }} - - - name: '[Unix] Upload log file' - if: ${{ inputs.os != 'windows' && ( success() || failure() ) }} - uses: actions/upload-artifact@v4 + - name: Print Inputs + uses: actions/github-script@v5 with: - name: app-logs-${{ github.job }}-${{ inputs.os }}-${{inputs.workflow_name}}-${{ github.run_id }} - path: ${{ github.workspace }}/application.log - - - name: '[Unix] Cleanup output files only' - if: ${{ inputs.os != 'windows' && ( success() || failure() ) }} - shell: bash -el {0} - run: rm -rf ${{ github.workspace }}/* - - # - name: '[Unix] Cleanup Conda' - # if: ${{ inputs.os != 'windows' && ( success() || failure() ) }} - # shell: bash -el {0} - # run: conda deactivate && conda env remove --name comfyui && conda clean -all - + script: | + console.log(`Operating System: ${{ github.event.inputs.os }}`); + console.log(`Python Version: ${{ github.event.inputs.python_version }}`); + console.log(`CUDA Version: ${{ github.event.inputs.cuda_version }}`); + console.log(`Pytorch Version: ${{ github.event.inputs.torch_version }}`); + console.log(`Models JSON: ${{ github.event.inputs['models-json'] }}`); + console.log(`Workflow Filenames: ${{ github.event.inputs.workflow_filenames }}`); + console.log(`ComfyUI Flags: ${{ github.event.inputs.comfyui_flags }}`); + console.log(`Workflow Raw JSON: ${{ github.event.inputs.workflow_raw_json }}`); + console.log(`Timeout: ${{ github.event.inputs.timeout }}`); + console.log(`Google Credentials: ${{ github.event.inputs.google_credentials }}`); + console.log(`GCS Bucket Name: ${{ github.event.inputs.gcs_bucket_name }}`); + console.log(`Output Prefix: ${{ github.event.inputs.output_prefix }}`); + console.log(`API Endpoint: ${{ github.event.inputs.api_endpoint }}`); + console.log(`Skip QuickCI: ${{ github.event.inputs.skip_quickci }}`); ##################################################################################### ## Windows Steps (F**k powershell) ## @@ -248,145 +129,3 @@ runs: ## ## ## ## ##################################################################################### - - - - name: '[Win] Auth to GCS' - uses: "google-github-actions/auth@v2" - if: ${{ inputs.os == 'windows' }} - with: - credentials_json: "${{ inputs.google_credentials }}" - - - name: '[Win] Setup Conda' - uses: conda-incubator/setup-miniconda@v3.0.3 - if: ${{ inputs.os == 'windows' }} - with: - activate-environment: gha-comfyui-${{ inputs.python_version }}-${{ inputs.torch_version }} - miniconda-version: "latest" - python-version: ${{ inputs.python_version }} - continue-on-error: true - - - name: '[Win-Only] Install Pytorch' - if: ${{ inputs.os == 'windows' }} - shell: powershell - run: | - conda activate gha-comfyui-${{ inputs.python_version }}-${{ inputs.torch_version }} - Get-Command pip - pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 - - - name: '[Win] Install dependencies' - if: ${{ inputs.os == 'windows' }} - shell: powershell - run: | - conda activate gha-comfyui-${{ inputs.python_version }}-${{ inputs.torch_version }} - pip install -r requirements.txt - - - name: "[Win] Check conda environment" - if: ${{ inputs.os == 'windows' }} - run: | - conda activate gha-comfyui-${{ inputs.python_version }}-${{ inputs.torch_version }} - conda info - conda list - shell: powershell - - - name: '[Win] Download models' - if: ${{ inputs.os == 'windows' }} - run: | - conda activate gha-comfyui-${{ inputs.python_version }}-${{ inputs.torch_version }} - cd $Env:GITHUB_ACTION_PATH - pip install -r requirements.txt - python default-models-prep.py --cache-directory C:\actions-runner\modelcache --live-directory "$Env:GITHUB_WORKSPACE/models" - shell: powershell - - - name: '[Win] Run ComfyUI quick test' - if: ${{ inputs.os == 'windows' && inputs.skip_quick_ci != 'true' }} - shell: powershell - run: | - conda activate gha-comfyui-${{ inputs.python_version }}-${{ inputs.torch_version }} - python $Env:GITHUB_WORKSPACE/main.py --quick-test-for-ci - - - name: '[Win] Run ComfyUI' - if: ${{ inputs.os == 'windows' }} - shell: powershell - run: | - $envGithubWorkspace = $Env:GITHUB_WORKSPACE - Write-Output "##############################" - Write-Output $envGithubWorkspace - Write-Output "##############################" - conda activate gha-comfyui-${{ inputs.python_version }}-${{ inputs.torch_version }} - Start-Process powershell -ArgumentList "-File", "${{ github.action_path }}\start-server.ps1", "-GITHUB_WORKSPACE", "`"$envGithubWorkspace`"", "-CondaEnv", "`"gha-comfyui-${{ inputs.python_version }}-${{ inputs.torch_version }}`"" - - - name: '[Win] Check if the server is running' - if: ${{ inputs.os == 'windows' }} - run: | - cd $Env:GITHUB_ACTION_PATH - conda activate gha-comfyui-${{ inputs.python_version }}-${{ inputs.torch_version }} - python poll_server_start.py - shell: powershell - - - name: '[Win] Get Commit Details' - id: win_get_commit_details - if: ${{ inputs.os == 'windows' }} - shell: powershell - run: | - $timestamp = git show -s --format=%cI HEAD^ - $message = git show -s --format=%s HEAD^ - $commit_hash = git rev-parse HEAD^ - "commit_time=$timestamp" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append - "commit_title=$message" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append - "commit_hash=$commit_hash" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append - - - name: '[Win] Run Python Action' - id: windows_action - if: ${{ inputs.os == 'windows' }} - shell: powershell - run: | - cd $Env:GITHUB_ACTION_PATH - conda activate gha-comfyui-${{ inputs.python_version }}-${{ inputs.torch_version }} - Write-Host "Running workflows: ${{ inputs.workflow_filenames }}" - python action.py ` - --comfy-workflow-names "${{ inputs.workflow_filenames }}" ` - --github-action-workflow-name "${{ github.workflow }}" ` - --os "${{ inputs.os }}" ` - --run-id "${{ github.run_id }}" ` - --gsc-bucket-name "${{ inputs.gcs_bucket_name }}" ` - --workspace-path "${{ github.workspace }}" ` - --output-file-prefix "${{ inputs.output_prefix }}" ` - --repo "${{ github.repository }}" ` - --commit-hash "${{ steps.win_get_commit_details.outputs.commit_hash }}" ` - --commit-time "${{ steps.win_get_commit_details.outputs.commit_time }}" ` - --commit-message "${{ steps.win_get_commit_details.outputs.commit_title }}" ` - --branch-name "${{ github.ref_name }}" ` - --api-endpoint "${{ inputs.api_endpoint }}" ` - ${{ inputs.comfyui_flags }} - - - name: '[Win] Upload Output Files' - uses: actions/upload-artifact@v4 - if: ${{ inputs.os == 'windows' && ( success() || failure() ) }} - with: - name: output-files-${{ github.job }}-${{ inputs.os }}-${{inputs.workflow_name}}-${{ github.run_id }} - path: ${{ github.workspace }}/output/** - - - name: '[Win] Upload log file to GCS' - if: ${{ ( success() || failure() ) && inputs.os == 'windows'}} - id: win_upload-log-files - uses: google-github-actions/upload-cloud-storage@v2 - with: - path: ${{ github.workspace }}/application.log - destination: ${{ inputs.gcs_bucket_name }}/logs/${{ github.job }}-${{ inputs.os }}-${{ inputs.workflow_name }}-run${{ github.run_id }} - - - name: '[Win] Upload log file' - uses: actions/upload-artifact@v4 - if: ${{ inputs.os == 'windows' && ( success() || failure() ) }} - with: - name: app-logs-${{ github.job }}-${{ inputs.os }}-${{inputs.workflow_name}}-${{ github.run_id }} - path: ${{ github.workspace }}/application.log - - # - name: '[Win] Sleep for 10 minutes on failure' - # if: ${{ inputs.os == 'windows' && failure() }} - # shell: powershell - # run: Start-Sleep -Seconds 600 - - - name: '[Win] Cleanup output files only' - if: ${{ inputs.os == 'windows' && ( success() || failure() ) }} - shell: powershell - run: Remove-Item -Path "${{ github.workspace }}/output/*" -Recurse -Force