mirror of
https://github.com/livekit/livekit.git
synced 2026-11-04 09:07:37 +00:00
97 lines
3.6 KiB
YAML
97 lines
3.6 KiB
YAML
# 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
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches: [master]
|
|
pull_request:
|
|
branches: [master]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
- uses: shogo82148/actions-setup-redis@ffaf3c39499b2917543d84f6acc818277580b531 # v1.58.1
|
|
with:
|
|
redis-version: "6.x"
|
|
auto-start: true
|
|
- run: redis-cli ping
|
|
|
|
# Test with the same Go toolchain the published image is built with
|
|
- name: Resolve Go version
|
|
id: go-version
|
|
run: |
|
|
# Assign first so a failed lookup trips `set -e`; inside echo its exit
|
|
# status would be discarded and an empty version written.
|
|
version=$(.github/scripts/go-version.sh Dockerfile)
|
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
|
|
with:
|
|
go-version: ${{ steps.go-version.outputs.version }}
|
|
|
|
- name: Replace mutexes
|
|
run: |
|
|
go get github.com/sasha-s/go-deadlock
|
|
grep -rl sync.Mutex ./pkg | xargs sed -i 's/sync\.Mutex/deadlock\.Mutex/g'
|
|
grep -rl sync.RWMutex ./pkg | xargs sed -i 's/sync\.RWMutex/deadlock\.RWMutex/g'
|
|
grep -rl deadlock.Mutex ./pkg | xargs go tool goimports -w
|
|
grep -rl deadlock.RWMutex ./pkg | xargs go tool goimports -w
|
|
go mod tidy
|
|
|
|
# Run mage at the version go.mod pins, rather than the mage-action's
|
|
# `version: latest`, so the binary matches the mage/mg library the magefile is
|
|
# compiled against and Renovate owns the version like any other module.
|
|
- name: Mage Build
|
|
run: go run github.com/magefile/mage build
|
|
|
|
- name: Lint
|
|
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
|
|
with:
|
|
version: v2.14.0
|
|
|
|
- name: Test
|
|
run: |
|
|
set -euo pipefail
|
|
MallocNanoZone=0 go test -race -json -v ./... 2>&1 | tee /tmp/gotest.log | go tool gotestfmt
|
|
|
|
# gotestfmt folds every test into a collapsed group, which hides a failure in a long log.
|
|
# List the failed tests in the log and on the run summary page.
|
|
- name: Failed tests
|
|
if: failure()
|
|
run: |
|
|
[ -f /tmp/gotest.log ] || exit 0
|
|
{
|
|
echo "### Failed tests"
|
|
jq -rR 'fromjson? | select(.Action == "fail") | if .Test then "- `\(.Package)` \(.Test)" else "- `\(.Package)` (package)" end' /tmp/gotest.log | sort -u
|
|
} | tee -a "$GITHUB_STEP_SUMMARY"
|
|
|
|
# Upload the original go test log as an artifact for later review.
|
|
- name: Upload test log
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
if: always()
|
|
with:
|
|
name: test-log
|
|
path: /tmp/gotest.log
|
|
# no log when an earlier step such as Lint fails; that failure is already reported
|
|
if-no-files-found: warn
|