alibaba/kt-connect

View on GitHub
.github/workflows/ci.yml

Summary

Maintainability
Test Coverage
name: ci

on:
  push:
  pull_request:
    branches: [ master ]

jobs:

  unit-test:
    name: Unit Test
    runs-on: ubuntu-latest
    steps:

    - name: Set up Go 1.18
      uses: actions/setup-go@v1
      with:
        go-version: 1.18
      id: go

    - name: KinD (Kubernetes in Docker) Action
      uses: engineerd/setup-kind@v0.5.0

    - name: Test KinD
      run: |
        kubectl cluster-info
        kubectl get pods -n kube-system
        echo "current-context:" $(kubectl config current-context)
        echo "environment-kubeconfig:" ${KUBECONFIG}

    - name: Check out code into the Go module directory
      uses: actions/checkout@v2

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

    - name: Get dependencies
      run: |
        go get -v -t -d ./...
        if [ -f Gopkg.toml ]; then
            curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
            dep ensure
        fi

    - name: Run unit test
      run: make test

  build-cli:
    name: Build biranarys
    runs-on: ubuntu-latest
    steps:

    - name: Set up Go 1.18
      uses: actions/setup-go@v1
      with:
        go-version: 1.18
      id: go

    - name: Check out code into the Go module directory
      uses: actions/checkout@v2

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

    - name: Get dependencies
      run: |
        go get -v -t -d ./...
        if [ -f Gopkg.toml ]; then
            curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
            dep ensure
        fi

    - name: Run go releaser
      uses: goreleaser/goreleaser-action@v1
      with:
        version: latest
        args: --snapshot --skip-publish --rm-dist
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    - name: Archive artifacts
      uses: actions/upload-artifact@v1
      with:
        name: dist
        path: dist