From be9ed4ec928ec5fbcdc4217c2dbd9e2b963819e7 Mon Sep 17 00:00:00 2001 From: BozdoganMehmetozkan <156694989+BozdoganMehmetozkan@users.noreply.github.com> Date: Thu, 29 Aug 2024 10:50:47 +0300 Subject: [PATCH] Create main.yml --- .github/workflows/main.yml | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..5e3c440 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,48 @@ +name: Go CI + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: '1.20' + + - name: Cache Go modules + uses: actions/cache@v3 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Install dependencies + run: go mod download || exit 1 + + - name: Build + run: go build -v || exit 1 + + - name: Run + run: go run main.go || exit 1 + + - name: Run tests + run: go test -v || exit 1 + + - name: Install gosec + run: go install github.com/securego/gosec/v2/cmd/gosec@latest + + - name: Run gosec + run: gosec ./... || exit 1 + + # Optional step for linting + - name: Lint + run: go fmt ./ || exit 1