-
Notifications
You must be signed in to change notification settings - Fork 8
119 lines (115 loc) · 4.38 KB
/
test_examples.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Test Examples
on:
pull_request:
branches:
- main
merge_group:
types:
- checks_requested
push:
branches:
- main
# HINT(lukasmalkmus): Make sure the workflow is only ever run for the latest
# changes in a PR or a commit that was pushed.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# HINT(lukasmalkmus): Test all code examples against the staging environment.
jobs:
test:
name: Test
runs-on: ubuntu-latest
# HINT(lukasmalkmus): Only run example tests for PRs originating from the
# upstream repository and for commits that were pushed to upstream.
if: github.event.pull_request.head.repo.full_name == github.repository ||
github.event.push.head.repo.full_name == github.repository
strategy:
fail-fast: false
matrix:
example:
- apex
- ingestevent
- ingestfile
# HINT(lukasmalkmus): We do not test this example as it takes too long!
# - ingesthackernews
- logrus
- otelinstrument
- oteltraces
- query
- querylegacy
- slog
- zap
- zerolog
include:
- example: apex
verify: |
axiom dataset info $AXIOM_DATASET -f=json | jq -e 'any( .numEvents ; . == 3 )'
- example: ingestevent
verify: |
axiom dataset info $AXIOM_DATASET -f=json | jq -e 'any( .numEvents ; . == 2 )'
- example: ingestfile
setup: |
echo '[{"timestamp":"1668773301","mood":"hyped","msg":"This is awesome!"}]' >> logs.json
verify: |
axiom dataset info $AXIOM_DATASET -f=json | jq -e 'any( .numEvents ; . == 1 )'
- example: logrus
verify: |
axiom dataset info $AXIOM_DATASET -f=json | jq -e 'any( .numEvents ; . == 3 )'
- example: otelinstrument
verify: |
axiom dataset info $AXIOM_DATASET -f=json | jq -e 'any( .numEvents ; . >= 1 )'
- example: oteltraces
verify: |
axiom dataset info $AXIOM_DATASET -f=json | jq -e 'any( .numEvents ; . == 2 )'
- example: query
setup: |
echo '[{"mood":"hyped","msg":"This is awesome!"}]' >> logs.json
axiom ingest $AXIOM_DATASET -f=logs.json -f=logs.json -f=logs.json
sleep 5
- example: querylegacy
setup: |
echo '[{"mood":"hyped","msg":"This is awesome!"}]' >> logs.json
axiom ingest $AXIOM_DATASET -f=logs.json -f=logs.json -f=logs.json
sleep 5
- example: slog
verify: |
axiom dataset info $AXIOM_DATASET -f=json | jq -e 'any( .numEvents ; . == 3 )'
- example: zap
verify: |
axiom dataset info $AXIOM_DATASET -f=json | jq -e 'any( .numEvents ; . == 3 )'
- example: zerolog
verify: |
axiom dataset info $AXIOM_DATASET -f=json | jq -e 'any( .numEvents ; . == 3 )'
env:
AXIOM_URL: ${{ secrets.TESTING_STAGING_API_URL }}
AXIOM_TOKEN: ${{ secrets.TESTING_STAGING_TOKEN }}
AXIOM_ORG_ID: ${{ secrets.TESTING_STAGING_ORG_ID }}
AXIOM_DATASET: test-axiom-go-examples-${{ github.run_id }}-${{ matrix.example }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Setup test dataset
run: |
curl -sL $(curl -s https://api.github.com/repos/axiomhq/cli/releases/tags/v0.10.0 | grep "http.*linux_amd64.tar.gz" | awk '{print $2}' | sed 's|[\"\,]*||g') | tar xzvf - --strip-components=1 --wildcards -C /usr/local/bin "axiom_*_linux_amd64/axiom"
axiom dataset create -n=$AXIOM_DATASET -d="Axiom Go ${{ matrix.example }} example test"
- name: Setup example
if: matrix.setup
run: ${{ matrix.setup }}
- name: Run example
run: go run ./examples/${{ matrix.example }}
- name: Verify example
if: matrix.verify
run: ${{ matrix.verify }}
- name: Delete test dataset
if: always()
run: axiom dataset delete -f $AXIOM_DATASET
examples-pass:
name: Examples Pass
needs: test
runs-on: ubuntu-latest
if: always()
steps:
- if: needs.test.result != 'success' && needs.test.result != 'skipped'
run: exit 1