build-and-test.yml•2.88 kB
name: Build and Test
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm ci
- name: Run Check
run: npm run check
- name: Run build
run: npm run build
- name: Run unit tests
run: npx vitest run --coverage --exclude tests/integration/**
- name: Upload results to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
integration-tests:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm ci
- name: Run build
run: npm run build
- name: Run integration tests
run: npx vitest run tests/integration
env:
HEVY_API_KEY: ${{ secrets.HEVY_API_KEY }}
docker-build:
runs-on: ubuntu-latest
needs: [build, integration-tests]
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
otel-cicd-action:
if: always()
name: OpenTelemetry Export Trace
runs-on: ubuntu-latest
needs: [build, integration-tests, docker-build] # must run when all jobs are completed
steps:
- name: Export workflow
uses: corentinmusard/otel-cicd-action@v2
with:
otlpEndpoint: 'grpc://in-otel.hyperdx.io:4317/'
otlpHeaders: ${{ secrets.HYPERDX_OTLP_HEADERS }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
runId: ${{ github.event.workflow_run.id }}