From ca207e135e57e68bb1998d27aa1ad1604eae588b Mon Sep 17 00:00:00 2001 From: Aneesh Puttur Date: Tue, 4 Feb 2025 12:40:56 -0500 Subject: [PATCH] add unittest Signed-off-by: Aneesh Puttur --- .github/workflows/test.yml | 4 +- .github/workflows/unittest.yml | 109 +++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/unittest.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8ac621b6..193577e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,10 +13,10 @@ jobs: with: go-version: ${{ matrix.go-version }} - - name: Checkout code + - name: Checkouts code uses: actions/checkout@v4 - - name: Run Revive Action by pulling pre-built image + - name: Run Revive Action by pulling pre-built image for test uses: docker://morphy/revive-action:v2 with: exclude: "./vendor/..." diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml new file mode 100644 index 00000000..fbdd24b5 --- /dev/null +++ b/.github/workflows/unittest.yml @@ -0,0 +1,109 @@ +name: Test linuxptp daemon + +on: [push, pull_request] + +concurrency: + group: ${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + + build: + name: build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.22 + uses: actions/setup-go@v3 + with: + go-version: 1.22.x + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: fmt + run: IS_CONTAINER=yes make fmt + + - name: Build + run: make all + + test: + name: test + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.22 + uses: actions/setup-go@v2 + with: + go-version: 1.22.x + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: test + run: make test- + + modules: + name: check go modules + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.22 + uses: actions/setup-go@v2 + with: + go-version: 1.22.x + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: check go modules are up to date + run: make check-deps + + golangci: + name: Golangci-lint + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.22 + uses: actions/setup-go@v2 + with: + go-version: 1.22.x + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: v1.55.2 + + shellcheck: + name: Shellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + with: + severity: error + + test-coverage: + name: test-coverage + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.22 + uses: actions/setup-go@v2 + with: + go-version: 1.22.x + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: test + run: make test + + - name: Coveralls + uses: coverallsapp/github-action@1.1.3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: lcov.out +