Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 当脚本始终运行时,如何配置github操作?_Python_Github_Yaml_Discord.py_Github Actions - Fatal编程技术网

Python 当脚本始终运行时,如何配置github操作?

Python 当脚本始终运行时,如何配置github操作?,python,github,yaml,discord.py,github-actions,Python,Github,Yaml,Discord.py,Github Actions,这是我的yml脚本 name: roBOT test on: pull_request: branches: [ master ] jobs: build: runs-on: ubuntu-latest strategy: matrix: python-version: [3.8, 3.9] timeout-minutes: 5 steps: - uses: actions/checkout@v2 - name: Set up Python uses:

这是我的yml脚本

name: roBOT test

on:
  pull_request:
    branches: [ master ]

jobs:
  build:

runs-on: ubuntu-latest
strategy:
  matrix:
    python-version: [3.8, 3.9]

timeout-minutes: 5

steps:
- uses: actions/checkout@v2
- name: Set up Python
  uses: actions/setup-python@v2
  with:
      python-version: ${{ matrix.python-version }}
- name: Install dependencies
  run: |
    python -m pip install --upgrade pip
    pip install flake8 pytest
    pip install -r requirements.txt --upgrade pip
- name: Lint with flake8
  run: |
    # stop the build if there are Python syntax errors or undefined names
    flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
    # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
    flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test
  env:
      TOKEN: ${{ secrets.TOKEN }}
      MONGO: ${{ secrets.MONGO }}
  run: python main.py
py是discord bot的脚本

import discord
import os
from decouple import config
from discord import channel
import  requests
import json
from duckduckgo_search import ddg
import wikipedia as wiki
import urllib
import database
import quiz

db = database.Database()
client = discord.Client()
quiz = quiz.Quiz(client)

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    # more elif blocks here


DISCORD_TOKEN=config('TOKEN')
client.run(DISCORD_TOKEN)

我想从github操作中得到的只是main.py已经成功运行的测试。但是当我的github操作运行时,它会无限运行,然后在6小时后停止。如果脚本运行成功,我如何在github操作中运行main.py并通过测试?

您可以为工作流使用超时:并且。@GuiFalourd我可以这样做。但那不是我的目标。这样做会导致测试失败(尽管我的脚本实际上正在运行)Ok。在这种情况下,在python脚本中配置它不是更容易吗?例如,通过返回成功或失败的消息来结束其执行,允许您在gha工作流上执行其他步骤。@GuiFalourd您能提供如何执行的见解吗?我对Python不太熟悉(至少您在这里使用它的方式)。但我所想的是执行这些测试一次,或者在特定的时间段内,然后根据场景返回错误或成功输出,以结束文件执行并遵循github工作流。