File tree Expand file tree Collapse file tree 4 files changed +99
-4
lines changed
Expand file tree Collapse file tree 4 files changed +99
-4
lines changed Original file line number Diff line number Diff line change 1+ name : integration-test
2+
3+ on :
4+ workflow_dispatch
5+
6+ jobs :
7+ integration-test :
8+ runs-on : ubuntu-latest
9+
10+ steps :
11+ - uses : actions/checkout@v4
12+
13+ - name : Set up Python 3.11
14+ uses : actions/setup-python@v5
15+ with :
16+ python-version : " 3.11"
17+
18+ - name : Install dependencies
19+ run : |
20+ python -m pip install --upgrade pip
21+ pip install -e ".[dev]"
22+
23+ - name : Run Discord Integration Test
24+ env :
25+ DISCORD_TOKEN : ${{ secrets.DISCORD_TOKEN }}
26+ run : python tests/integration_test_discord.py
27+
28+ - name : Upload integration artifact
29+ if : always()
30+ uses : actions/upload-artifact@v4
31+ with :
32+ name : integration-transcript
33+ path : tests/artifacts/integration_transcript.html
34+ if-no-files-found : error
Original file line number Diff line number Diff line change @@ -3,8 +3,6 @@ name: lint
33on :
44 push :
55 branches : [ "**" ]
6- pull_request :
7- branches : [ "**" ]
86
97jobs :
108 ruff :
Original file line number Diff line number Diff line change @@ -3,8 +3,6 @@ name: test
33on :
44 push :
55 branches : [ "**" ]
6- pull_request :
7- branches : [ "**" ]
86
97jobs :
108 test :
Original file line number Diff line number Diff line change 1+ import os
2+ import asyncio
3+ import discord
4+ import chat_exporter
5+ import sys
6+
7+ # Configuration from environment variables
8+ TOKEN = os .getenv ("DISCORD_TOKEN" )
9+ GUILD_ID = 715959114647208017
10+ CHANNEL_ID = 1456616358681772135
11+
12+ if not TOKEN :
13+ print ("Error: DISCORD_TOKEN environment variable is not set." )
14+ sys .exit (1 )
15+
16+ intents = discord .Intents .default ()
17+ intents .message_content = True
18+ intents .members = True
19+
20+ bot = discord .Client (intents = intents )
21+
22+ @bot .event
23+ async def on_ready ():
24+ print (f"Logged in as { bot .user } " )
25+
26+ guild = bot .get_guild (GUILD_ID )
27+ if not guild :
28+ print (f"Error: Could not find guild with ID { GUILD_ID } " )
29+ await bot .close ()
30+ sys .exit (1 )
31+
32+ channel = guild .get_channel (CHANNEL_ID )
33+ if not channel :
34+ print (f"Error: Could not find channel with ID { CHANNEL_ID } in guild { GUILD_ID } " )
35+ await bot .close ()
36+ sys .exit (1 )
37+
38+ print (f"Exporting channel: { channel .name } ({ channel .id } )" )
39+
40+ try :
41+ transcript = await chat_exporter .export (
42+ channel ,
43+ bot = bot ,
44+ )
45+
46+ if transcript :
47+ os .makedirs ("tests/artifacts" , exist_ok = True )
48+ with open ("tests/artifacts/integration_transcript.html" , "w" , encoding = "utf-8" ) as f :
49+ f .write (transcript )
50+ print ("Successfully saved transcript to tests/artifacts/integration_transcript.html" )
51+ else :
52+ print ("Error: Export returned empty transcript." )
53+ await bot .close ()
54+ sys .exit (1 )
55+
56+ except Exception as e :
57+ print (f"Error during export: { e } " )
58+ await bot .close ()
59+ sys .exit (1 )
60+
61+ print ("Integration test completed successfully." )
62+ await bot .close ()
63+
64+ if __name__ == "__main__" :
65+ bot .run (TOKEN )
You can’t perform that action at this time.
0 commit comments