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

2024-05-19 19:18:26 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我的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并通过测试


Tags: installpiprunnamepyimport脚本client