Skip to content

chore: go 1.20

chore: go 1.20 #547

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
# - ingesthackernews # HINT(lukasmalkmus): We do not test this example as it takes too long!
- logrus
- otelinstrument
- oteltraces
- query
- querylegacy
- slog
- zap
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 _traces -f=json | jq -e 'any( .numEvents ; . >= 1 )'
- example: oteltraces
verify: |
axiom dataset info _traces -f=json | jq -e 'any( .numEvents ; . >= 1 )'
- 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 )'
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@v3
- uses: actions/setup-go@v4
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 }}/main.go
- 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