name: "dev test"
on:
  push:
    branches:
      - master
      - dev
      - 'feature/**'
    paths:
      - '**.go'
      - '**.yml'
      - '**.yaml'      
jobs:
  test:
    runs-on: ubuntu-latest
    env:
      TOKEN: ${{ secrets.TOKEN }}
      USERNAME: ${{ vars.USERNAME }}
      TAG_VERSION: ${{ github.ref_name }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup Go
        uses: actions/setup-go@v5
        with:
          go-version-file: 'go.mod'
      - name: test with go
        run: go test -v ./...

  vulnCheck:
    runs-on: ubuntu-latest
    needs: test
    env:
      TOKEN: ${{ secrets.TOKEN }}
      USERNAME: ${{ vars.USERNAME }}
      TAG_VERSION: ${{ github.ref_name }}
    steps:
      - name: checkout Code
        uses: actions/checkout@v4
        
      - name: go vuln check
        uses: golang/govulncheck-action@v1
        with:
          go-version-file: 'go.mod'
          go-package: ./...

  Ci-Lint:
        runs-on: ubuntu-latest
        needs: vulnCheck
        env:
          TOKEN: ${{ secrets.TOKEN }}
          USERNAME: ${{ vars.USERNAME }}
          TAG_VERSION: ${{ github.ref_name }}
        steps:
          - name: Checkout code
            uses: actions/checkout@v4

          - name: Setup Go
            uses: actions/setup-go@v5
            with:
                go-version-file: 'go.mod'
          - name: CI lint Check 
            uses: golangci/golangci-lint-action@v6
            with:
              only-new-issues: true
