diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 420805ae..28737924 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -25,14 +25,36 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Build docker image - run: | - docker build \ - -t sip-test \ - -f ./build/test/Dockerfile . + - name: Install Opus dependencies + run: sudo apt-get update && sudo apt-get install -y libopus-dev libopusfile-dev + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.21" + + - name: Set up gotestfmt + run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@v2.5.0 - - name: Run tests + - name: Static Check + uses: dominikh/staticcheck-action@v1.3.0 + with: + checks: '["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-SA1019"]' + version: "2023.1.3" + install-go: false + + - name: Test run: | - docker run --rm \ - -e GITHUB_WORKFLOW=1 \ - sip-test + set -euo pipefail + go test -race -json -v -coverprofile=coverage.out -covermode=atomic ./... 2>&1 | tee /tmp/gotest.log | gotestfmt + + - name: Upload test log + uses: actions/upload-artifact@v3 + if: always() + with: + name: test-log + path: /tmp/gotest.log + if-no-files-found: error + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 diff --git a/build/test/Dockerfile b/build/test/Dockerfile deleted file mode 100644 index 39867025..00000000 --- a/build/test/Dockerfile +++ /dev/null @@ -1,42 +0,0 @@ -# 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. - -FROM livekit/gstreamer:1.20.4-dev - -ARG TARGETPLATFORM - -WORKDIR /workspace - -# install deps -RUN apt-get update && \ - apt-get install -y \ - curl libopus-dev libopusfile-dev - -RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then GOARCH=arm64; else GOARCH=amd64; fi && \ - curl -L -o /tmp/go.tar.gz "https://go.dev/dl/go1.20.7.linux-$GOARCH.tar.gz" -RUN tar -C /usr/local -xzf /tmp/go.tar.gz -ENV PATH="$PATH:/usr/local/go/bin" - -# download go modules -COPY go.mod . -COPY go.sum . -RUN go mod download - -# copy source -COPY res/ res/ -COPY pkg/ pkg/ -COPY version/ version/ - -COPY build/test/entrypoint.sh . -ENTRYPOINT ["./entrypoint.sh"] diff --git a/build/test/entrypoint.sh b/build/test/entrypoint.sh deleted file mode 100755 index 8c3d4ccb..00000000 --- a/build/test/entrypoint.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -# 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. - -set -exo pipefail - - -# Run tests -if [[ -z "${GITHUB_WORKFLOW}" ]]; then - exec go test -v -timeout 20m ./pkg/... -else - go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest - exec go tool test2json -p sip go test -test.v=true -test.timeout 20m ./pkg/... 2>&1 | "$HOME"/go/bin/gotestfmt -fi