diff --git a/.github/workflows/workflow-ci.yml b/.github/workflows/workflow-ci.yml index 78a75ad0..f0049c8e 100644 --- a/.github/workflows/workflow-ci.yml +++ b/.github/workflows/workflow-ci.yml @@ -5,6 +5,10 @@ on: branches: - master +permissions: + contents: read + pull-requests: write + concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number }} cancel-in-progress: true @@ -102,6 +106,29 @@ jobs: BIZYAIR_API_KEY: ${{ secrets.BIZYAIR_KEY }} PYTHONPATH: ${{ github.workspace }}/ComfyUI + - name: Add PR review comment about the time taken to run the examples on Linux + if: matrix.os == 'ubuntu-latest' + uses: actions/github-script@v4 + with: + script: | + const { pull_request } = context.payload; + const fs = require('fs'); + const timeTaken = fs.readFileSync('ComfyUI/custom_nodes/BizyAir/time_taken.txt', 'utf8'); + const comment = `The time taken by running the examples on Linux: \n${timeTaken}`; + await github.issues.createComment({ + issue_number: pull_request.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }) + + + + - name: remove the time_taken.txt file + if: matrix.os == 'ubuntu-latest' + run: | + rm ComfyUI/custom_nodes/BizyAir/time_taken.txt + - name: Run ComfyUI on Windows if: matrix.os == 'windows-latest' run: | @@ -115,3 +142,24 @@ jobs: BIZYAIR_KEY: ${{ secrets.BIZYAIR_KEY }} BIZYAIR_API_KEY: ${{ secrets.BIZYAIR_KEY }} PYTHONPATH: ${{ github.workspace }}/ComfyUI + + - name: Add PR review comment about the time taken to run the examples on Windows + if: matrix.os == 'windows-latest' + uses: actions/github-script@v4 + with: + script: | + const { pull_request } = context.payload; + const fs = require('fs'); + const timeTaken = fs.readFileSync('ComfyUI/custom_nodes/BizyAir/time_taken.txt', 'utf8'); + const comment = `The time taken by running the examples on Windows: \n${timeTaken}`; + await github.issues.createComment({ + issue_number: pull_request.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }) + + - name: remove the time_taken.txt file + if: matrix.os == 'windows-latest' + run: | + rm ComfyUI/custom_nodes/BizyAir/time_taken.txt diff --git a/tests/test_examples.py b/tests/test_examples.py index 8edb3177..0bbd92d5 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -149,8 +149,12 @@ def launch_prompt(driver, comfy_host, comfy_port, workflow, timeout): print(f" check if error occurs...") check_error_occurs(driver) print(f" no error occurs when executing workflow") + with open(os.path.join(base_path, "..", "time_taken.txt"), "a") as f: + f.write(f"{duration:.1f} s |\n") except TimeoutException: print("Time out") + with open(os.path.join(base_path, "..", "time_taken.txt"), "a") as f: + f.write(f"timeout |\n") driver.quit() driver = init_driver() driver.get(f"http://{comfy_host}:{comfy_port}") @@ -159,6 +163,8 @@ def launch_prompt(driver, comfy_host, comfy_port, workflow, timeout): print(type(e)) print(e) print(" exit with error: 1") + with open(os.path.join(base_path, "..", "time_taken.txt"), "a") as f: + f.write(f"error |\n") driver.quit() exit(1) @@ -225,8 +231,12 @@ def filter_examples_json(all_examples_json: dict, bypass_titles: list): print("========Running all examples========") print("\n".join(f"{key} -- {value}" for key, value in all_examples_json.items())) print("====================================") + with open(os.path.join(base_path, "..", "time_taken.txt"), "a") as f: + f.write(f"| title and file | timetaken |\n|:--:|:--:|\n") for title, file in all_examples_json.items(): print(f"Running example: {title} - {file}") + with open(os.path.join(base_path, "..", "time_taken.txt"), "a") as f: + f.write(f"| {title} - {file} |") launch_prompt( driver, COMFY_HOST,