diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml new file mode 100644 index 00000000..ed8bc099 --- /dev/null +++ b/.github/workflows/code-quality.yml @@ -0,0 +1,50 @@ +name: Code Quality + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + code-quality: + name: Code Quality Checks + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + cache: true + + - name: Install golangci-lint + run: | + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.5.0 + + - name: Check formatting + run: | + # Run gofmt to format code + make fmt + + # Check if any files were modified + if [ -n "$(git status --porcelain)" ]; then + echo "❌ Code formatting issues detected. Please run 'make fmt' locally and commit the changes." + echo "" + echo "Files that need formatting:" + git status --porcelain + echo "" + echo "Differences:" + git diff + exit 1 + fi + echo "✅ All files are properly formatted" + + - name: Run go vet + run: make vet + + - name: Run golangci-lint + run: make lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..541f256d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,28 @@ +name: Tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + unit-tests: + name: Unit Tests + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + cache: true + + - name: Download dependencies + run: go mod download + + - name: Run unit tests + run: make test diff --git a/.golangci.yml b/.golangci.yml index b1859300..dbab8885 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -32,9 +32,6 @@ issues: max-same-issues: 0 output: - formats: - colored-line-number: - path: stdout print-issued-lines: true print-linter-name: true sort-results: true diff --git a/Dockerfile b/Dockerfile index 5f753ec5..03340aa7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,7 @@ RUN echo "Building for ${TARGETOS}/${TARGETARCH}" && \ CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build \ -ldflags "-w -s -X main.version=${VERSION} -X main.gitCommit=${GIT_COMMIT} -X main.buildDate=${BUILD_DATE}" \ -o roxie \ - ./cmd/roxie + ./cmd # Stage 2: Runtime image based on Red Hat UBI Minimal FROM registry.access.redhat.com/ubi9/ubi-minimal:latest diff --git a/flake.nix b/flake.nix index e35243c3..21aaa29c 100644 --- a/flake.nix +++ b/flake.nix @@ -45,7 +45,7 @@ "-X main.buildDate=1970-01-01T00:00:00Z" ]; - subPackages = [ "cmd/roxie" ]; + subPackages = [ "cmd" ]; meta = with pkgs.lib; { description = "Fast, developer-friendly CLI to deploy and manage Red Hat Advanced Cluster Security (ACS)";