Skip to content

Commit c730876

Browse files
authored
Tweak example project execution, fix and improve CI E2E tests (#135)
1 parent f02aa34 commit c730876

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

.github/workflows/end-to-end.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ name: E2E Tests
22

33
on:
44
push:
5-
branches:
6-
- master
5+
paths:
6+
- .github/workflows/end-to-end.yml
7+
- example-project/**
78
schedule:
89
- cron: "20 5 * * *"
910
workflow_dispatch:
@@ -14,6 +15,7 @@ jobs:
1415

1516
strategy:
1617
matrix:
18+
infrastructure: [legacy, cloud]
1719
node-version: [16.x, 18.x, 20.x, 22.x]
1820
dependencies: [install, update]
1921
fail-fast: false
@@ -33,12 +35,17 @@ jobs:
3335
working-directory: ./example-project
3436

3537
- name: Run example project with valid token
36-
run: node index.js ${{ secrets.SOURCE_TOKEN }}
38+
env:
39+
INGESTING_HOST: ${{ matrix.infrastructure == 'cloud' && secrets.CLOUD_INGESTING_HOST || 'in.logs.betterstack.com' }}
40+
SOURCE_TOKEN: ${{ matrix.infrastructure == 'cloud' && secrets.CLOUD_SOURCE_TOKEN || secrets.SOURCE_TOKEN }}
41+
run: node index.js ${{ env.SOURCE_TOKEN }} ${{ env.INGESTING_HOST }}
3742
working-directory: ./example-project
3843

3944
- name: Run example project with invalid token
45+
env:
46+
INGESTING_HOST: ${{ matrix.infrastructure == 'cloud' && secrets.CLOUD_INGESTING_HOST || 'in.logs.betterstack.com' }}
4047
run: |
41-
if node index.js INVALID_TOKEN; then
48+
if node index.js INVALID_TOKEN ${{ env.INGESTING_HOST }}; then
4249
echo "This should have failed but didn't"
4350
exit 1
4451
else
@@ -51,6 +58,7 @@ jobs:
5158

5259
strategy:
5360
matrix:
61+
infrastructure: [legacy, cloud]
5462
bun-version: [latest, 1.0.0]
5563
dependencies: [install, update]
5664
fail-fast: false
@@ -68,12 +76,17 @@ jobs:
6876
working-directory: ./example-project
6977

7078
- name: Run example project with valid token
71-
run: bun run index.js ${{ secrets.SOURCE_TOKEN }}
79+
env:
80+
INGESTING_HOST: ${{ matrix.infrastructure == 'cloud' && secrets.CLOUD_INGESTING_HOST || 'in.logs.betterstack.com' }}
81+
SOURCE_TOKEN: ${{ matrix.infrastructure == 'cloud' && secrets.CLOUD_SOURCE_TOKEN || secrets.SOURCE_TOKEN }}
82+
run: bun run index.js ${{ env.SOURCE_TOKEN }} ${{ env.INGESTING_HOST }}
7283
working-directory: ./example-project
7384

7485
- name: Run example project with invalid token
86+
env:
87+
INGESTING_HOST: ${{ matrix.infrastructure == 'cloud' && secrets.CLOUD_INGESTING_HOST || 'in.logs.betterstack.com' }}
7588
run: |
76-
if bun run index.js INVALID_TOKEN; then
89+
if bun run index.js INVALID_TOKEN ${{ env.INGESTING_HOST }}; then
7790
echo "This should have failed but didn't"
7891
exit 1
7992
else

example-project/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const { Node: Logtail } = require("@logtail/js");
1616
// Create a logger from a Logtail class
1717
const logger = new Logtail(process.argv[2], {
1818
sendLogsToConsoleOutput: true,
19-
endpoint: process.argv[3],
19+
endpoint: `https://${process.argv[3]}`,
2020
});
2121

2222
// Usage

0 commit comments

Comments
 (0)