Tabular result format #909
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |