From 0d6886503f9d6cd3f4c2dabc8d6b0fb5484945fb Mon Sep 17 00:00:00 2001 From: Vasily Tsybenko Date: Tue, 8 Oct 2024 13:59:38 +0300 Subject: [PATCH 1/2] Configure CI via github actions --- .github/workflows/lint.yml | 32 ++++++++++++++++++++++++++ .github/workflows/sec.yml | 32 ++++++++++++++++++++++++++ .github/workflows/test.yml | 47 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/sec.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..a1d71bb --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,32 @@ +name: Lint +on: + push: + branches: + - main + pull_request: + branches: + - main +permissions: + contents: read +jobs: + lint: + strategy: + matrix: + go: [ '1.20' ] + fail-fast: true + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Go ${{ matrix.go }} + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go }} + cache: false + + - name: Run GolangCI-Lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.56.1 + args: --timeout=5m \ No newline at end of file diff --git a/.github/workflows/sec.yml b/.github/workflows/sec.yml new file mode 100644 index 0000000..e0ceeaf --- /dev/null +++ b/.github/workflows/sec.yml @@ -0,0 +1,32 @@ +name: Security Scan + +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: + contents: read + id-token: write + issues: write + pull-requests: write + +jobs: + TruffleHog: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Secret Scanning + uses: trufflesecurity/trufflehog@main + with: + extra_args: --only-verified diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1a76bf5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,47 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + test_and_lint: + name: Test, Lint, and Coverage + strategy: + matrix: + go: [ '1.20' ] + os: [ ubuntu-latest ] + fail-fast: true + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Go ${{ matrix.go }} + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go }} + cache: false + + - name: Install dependencies + run: go mod download + + - name: Run tests with coverage + run: go test -race -cover -coverprofile="coverage.out" -covermode=atomic -v ./... + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + files: ./coverage.out + + - name: Calculate coverage + run: go tool cover -func=coverage.out | grep total | awk '{print substr($3, 1, length($3)-1)}' + id: coverage From cd0514b4b2f8d4c6d45a874966fe33f0a7d4f38d Mon Sep 17 00:00:00 2001 From: Vasily Tsybenko Date: Tue, 8 Oct 2024 14:00:59 +0300 Subject: [PATCH 2/2] Add CODEOWNERS --- .github/workflows/lint.yml | 2 +- CODEOWNERS | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 CODEOWNERS diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a1d71bb..ccfd539 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -29,4 +29,4 @@ jobs: uses: golangci/golangci-lint-action@v3 with: version: v1.56.1 - args: --timeout=5m \ No newline at end of file + args: --timeout=5m diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..6e1f364 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @vasayxtx @MikeYast