Skip to content

Commit 25e42d9

Browse files
committed
Add cleanup GH job
1 parent 498d169 commit 25e42d9

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

.github/workflows/cleanup.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Cleanup after tests
2+
env:
3+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4+
STREAM_API_KEY: ${{ vars.TEST_API_KEY }}
5+
STREAM_SECRET: ${{ secrets.TEST_SECRET }}
6+
7+
# Runs midnight at every Sunday https://crontab.guru/weekly
8+
on:
9+
schedule:
10+
- cron: "0 0 * * 0"
11+
12+
cleanup:
13+
runs-on: ubuntu-latest
14+
concurrency:
15+
group: test-workflow
16+
cancel-in-progress: true
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
- name: Setup Node
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: 20
25+
cache: "yarn"
26+
27+
- name: Install Dependencies
28+
run: yarn install --immutable
29+
- name: Build
30+
run: yarn build
31+
- name: Cleanup
32+
run: node test-cleanup.js

__tests__/messages.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'dotenv/config';
2-
import { beforeAll, describe, expect, it } from 'vitest';
2+
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
33
import { createTestClient } from './create-test-client';
44
import { StreamChannel } from '../src/StreamChannel';
55
import { StreamClient } from '../src/StreamClient';
@@ -188,4 +188,8 @@ describe('messages API', () => {
188188
`Stream error code 4: GetMessage failed with error: "Message with id ${messageId} doesn't exist"`,
189189
);
190190
});
191+
192+
afterAll(async () => {
193+
await channel.delete({ hardDelete: true });
194+
});
191195
});

test-cleanup.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ const cleanUpChannels = async () => {
5757

5858
await Promise.all(
5959
channels.map((c) =>
60-
client.chat.channel(c.channel.type, c.channel.id).delete(),
60+
client.chat
61+
.channel(c.channel.type, c.channel.id)
62+
.delete({ hardDelete: true }),
6163
),
6264
);
6365
};

0 commit comments

Comments
 (0)