name: Unit test

on:
  pull_request:
  push:

jobs:
  unit-test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Set up Helm 3.11.1
        uses: azure/setup-helm@v1
        with:
          version: '3.11.1'

      - name: Set up Go 1.19
        uses: actions/setup-go@v2
        with:
          go-version: 1.19

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

      - name: Run unit tests
        working-directory: ./test
        run:
          go test -v github.com/goharbor/harbor-helm/unittest
