Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the ability to automatically run unit tests after creating a pull request. #764

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
76 changes: 76 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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: "Unit Test"

on:
push:
branches: [ master ]
pull_request:
branches: "*"
types: [opened, synchronize, reopened]

permissions:
contents: read

jobs:
unit-test:
name: Unit Test
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
golang:
- 1.18

steps:
- name: "Set up Go"
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.golang }}

- name: "Checkout code"
uses: actions/checkout@v3
with:
submodules: true

- name: "Cache dependencies"
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: "${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}"
restore-keys: |
"${{ runner.os }}-go-"

- name: "Run Unit Tests"
run: |
echo "=== Starting Unit Tests ==="
go test -v ./... -coverprofile=coverage.txt -covermode=atomic -timeout 10m
if [ $? -ne 0 ]; then
echo "❌ Unit tests failed"
exit 1
fi
echo "✅ Unit tests completed successfully"

- name: "Upload Coverage"
uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
Loading