livekit-protocol 0.8.1

Livekit protocol and utilities for the Rust SDK
Documentation
# Copyright 2023 LiveKit, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Test

on:
  workflow_dispatch:
  push:
    branches: [main]
  pull_request:
    branches: [main]

permissions:
  contents: read # Lint and test only read the checkout

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

      - name: Set up Go
        uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
        with:
          go-version-file: "go.mod"
          # setup-go's own cache restores on an exact key only, so any go.sum
          # change is a full cold build. Restored below instead.
          cache: false

      # The run_id suffix never pre-exists, so a push always writes a fresh
      # entry rather than one frozen at the go.sum that first created it.
      - name: Restore Go caches
        id: go-cache
        uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
        with:
          path: |
            ~/.cache/go-build
            ~/go/pkg/mod
          key: go-${{ runner.os }}-${{ hashFiles('go.sum') }}-${{ github.run_id }}
          restore-keys: |
            go-${{ runner.os }}-${{ hashFiles('go.sum') }}-
            go-${{ runner.os }}-

      - name: Set up gotestfmt
        run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@9eae5abc81d6d08f73268741ef4a8b97f29b60d8 # v2.4.1

      - name: Download Go modules
        run: go mod download

      - name: Lint
        uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
        with:
          version: v2.12.2

      - name: Test
        run: |
          set -euo pipefail
          MallocNanoZone=0 go test -race -json -v ./... 2>&1 | gotestfmt

      # Only main writes. Pull requests read main's entry, which keeps ~1 GB
      # per PR run out of the repo's 10 GB cache budget.
      - name: Save Go caches
        if: github.event_name == 'push'
        uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
        with:
          path: |
            ~/.cache/go-build
            ~/go/pkg/mod
          key: ${{ steps.go-cache.outputs.cache-primary-key }}