# 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - uses: shogo82148/actions-setup-redis@bd623e2f740257df88cb670bdd279f3a9182f828 # v1 with: redis-version: "6.x" auto-start: true - run: redis-cli ping - name: Set up Go uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6 with: go-version: "^1.26" - name: Set up gotestfmt run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@v2.4.1 - 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' go install golang.org/x/tools/cmd/goimports@latest grep -rl deadlock.Mutex ./pkg | xargs goimports -w grep -rl deadlock.RWMutex ./pkg | xargs goimports -w go mod tidy - name: Mage Build uses: magefile/mage-action@a662bd8c29d8106879588cfff83b2faf6e6f59db # v4 with: version: latest args: build - name: Lint uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0 with: version: v2.12.2 - name: Test run: | set -euo pipefail MallocNanoZone=0 go test -race -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt # Upload the original go test log as an artifact for later review. - name: Upload test log uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 if: always() with: name: test-log path: /tmp/gotest.log if-no-files-found: error