From b9d79587401f4faa5c7248ed365d71c4f5d2f856 Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Sun, 26 Oct 2025 22:39:37 +0100 Subject: [PATCH 1/6] Code Quality GHA --- .github/workflows/code-quality.yml | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/code-quality.yml diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml new file mode 100644 index 00000000..5a8dd746 --- /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: | + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + + - 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 From a4e4de0b42610d2f85aa9bf792b44dcd8e116507 Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Sun, 26 Oct 2025 23:07:57 +0100 Subject: [PATCH 2/6] New Code Quality GHA --- .github/workflows/code-quality.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 5a8dd746..608d538f 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -23,7 +23,7 @@ jobs: - name: Install golangci-lint run: | - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v2.5.0 - name: Check formatting run: | From 8a0b127b1c16a29dbdbce1a502b4e3219e45b4fc Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Sun, 26 Oct 2025 23:08:30 +0100 Subject: [PATCH 3/6] GHA for running unit tests --- .github/workflows/test.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/test.yml 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 From 390d17a95019c285d418018b2322c82a70f0376c Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Sun, 26 Oct 2025 23:13:28 +0100 Subject: [PATCH 4/6] Adjust to new directory layout --- Dockerfile | 2 +- flake.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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)"; From d4456d8339ab56af4752b0855d2e2f8f81f3416c Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Sun, 26 Oct 2025 23:13:46 +0100 Subject: [PATCH 5/6] Fix golangci-lint config --- .golangci.yml | 3 --- 1 file changed, 3 deletions(-) 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 From 93e3dfff0f5c7833f8f652a244ffd53a1552b350 Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Sun, 26 Oct 2025 23:16:53 +0100 Subject: [PATCH 6/6] Use golangci-lint install script --- .github/workflows/code-quality.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 608d538f..ed8bc099 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -23,7 +23,7 @@ jobs: - name: Install golangci-lint run: | - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v2.5.0 + 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: |