Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name: docs
name: Docs

on:
push:
branches:
- main
paths-ignore:
- "**.md"
workflow_dispatch:

jobs:
documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v6
- uses: actions/setup-node@v4
- name: Installation
uses: bahmutov/npm-install@v1
with:
Expand Down
56 changes: 27 additions & 29 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
name: "Lint"
name: Lint

on: [push, pull_request]
on:
push:
branches:
- main
paths-ignore:
- "**.md"
- "docs/**"
pull_request:
paths-ignore:
- "**.md"
- "docs/**"

concurrency:
group: lint-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
golangci:
name: "Lint"
runs-on: "ubuntu-latest"
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
- uses: actions/checkout@v4
- name: Crete empty build directory
run: mkdir ui/build && touch ui/build/.gitkeep
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
version: v1.64

codeql:
name: "Analyze with CodeQL"
runs-on: "ubuntu-latest"
permissions:
actions: "read"
contents: "read"
security-events: "write"
strategy:
fail-fast: false
matrix:
language: ["go"]
steps:
- uses: "actions/checkout@v2"
- uses: "github/codeql-action/init@v1"
go-version-file: "go.mod"
cache: true
- name: Create empty UI build directory
run: mkdir -p ui/build && touch ui/build/.gitkeep
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
languages: "${{ matrix.language }}"
- uses: "github/codeql-action/autobuild@v1"
- uses: "github/codeql-action/analyze@v1"
version: latest
args: --timeout=5m
18 changes: 10 additions & 8 deletions .github/workflows/release-server.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Release

on:
push:
tags:
- "v*.*.*"
- "v*"
Comment on lines 5 to +6
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Tag filter widened from semver to any v* tag.

Changing v*.*.*v* means any tag starting with v (e.g. v-test, valpha, v1, v2-rc) will now trigger the release + Docker publish workflow. If that's intentional to support pre-release / short tags, ignore; otherwise consider restricting to semver-shaped tags, e.g.:

-      - "v*"
+      - "v[0-9]+.[0-9]+.[0-9]+"
+      - "v[0-9]+.[0-9]+.[0-9]+-*"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/release-server.yml around lines 5 - 6, The tags filter in
release-server.yml has been broadened to "- "v*"" which will trigger the
workflow for any tag starting with "v"; to restrict releases to semver tags
change that value back to a semver pattern such as "- "v*.*.*"" or use a
stricter regex-like pattern (e.g. "v[0-9]+.[0-9]+.[0-9]+(-.*)?") in the tags:
field; if the wider matching is intentional for pre-release/short tags, leave
"v*" as-is, otherwise replace the current "v*" entry in the tags: list with one
of the semver patterns ("v*.*.*" or the regex form).

workflow_dispatch:
inputs:
goreleaserArgs:
Expand All @@ -14,24 +15,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v6
with:
go-version: "1.20"
go-version-file: "go.mod"
cache: true
- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v4
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: v1.21.2
args: --rm-dist ${{ inputs.goreleaserArgs }}
version: latest
args: release --clean ${{ inputs.goreleaserArgs }}
env:
GITHUB_TOKEN: ${{ secrets.GO_RELEASER_TOKEN }}
37 changes: 26 additions & 11 deletions .github/workflows/test-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,24 @@ on:
push:
branches:
- main
paths-ignore:
- "**.md"
- "docs/**"
pull_request:
workflow_dispatch:
paths-ignore:
- "**.md"
- "docs/**"

concurrency:
group: test-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13
image: postgres:15
env:
POSTGRES_HOST: localhost
POSTGRES_USER: postgres
Expand All @@ -26,18 +35,24 @@ jobs:
ports:
- 5432:5432
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v4
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: ^1.20
id: go
go-version-file: "go.mod"
cache: true
- name: Create empty UI build directory
run: mkdir -p ui/build && touch ui/build/.gitkeep
- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
version: "3.x"
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Test
version: "25.x"
- name: Run Test
run: make test
env:
TEST_DB_CONNECTIONSTRING: "postgres://postgres:postgres@localhost:5432/test_stencil_db?sslmode=disable"
- name: Install goveralls and send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
go install github.com/mattn/goveralls@latest
goveralls -coverprofile=coverage.out -service=github
Comment on lines +53 to +58
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify that `make test` produces coverage.out at the repo root and check the test target definition.
fd -HI -t f '^Makefile$' --max-depth 3
rg -nP -C2 '^(test|coverage)\s*:' Makefile 2>/dev/null || true
rg -n 'coverage\.out|-coverprofile' Makefile 2>/dev/null || true

Repository: raystack/stencil

Length of output: 518


🏁 Script executed:

#!/bin/bash
# Check if v0.0.12 is a valid version and look for available versions of goveralls
curl -s https://api.github.com/repos/mattn/goveralls/releases | jq -r '.[0:5] | .[] | "\(.tag_name)"' 2>/dev/null || echo "Unable to fetch releases"

Repository: raystack/stencil

Length of output: 84


Harden the coverage-upload step.

Two concrete issues worth addressing:

  1. go install github.com/mattn/goveralls@latest is a floating pin — pin to a specific version so CI behavior is reproducible if upstream ships a breaking change.
  2. Because there's no if: always(), a single test failure prevents coverage upload entirely. Coverage trends are lost on flaky tests. Consider if: always() to capture coverage even when tests fail (or accept this intentionally).

The assumption that make test produces coverage.out is correct: the test target in the Makefile explicitly uses -coverprofile=coverage.out. Using secrets.GITHUB_TOKEN as COVERALLS_TOKEN with -service=github is also the documented pattern, so that part is fine.

♻️ Suggested change
       - name: Install goveralls and send coverage
+        if: always()
         env:
           COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
-          go install github.com/mattn/goveralls@latest
+          go install github.com/mattn/goveralls@v0.0.12
           goveralls -coverprofile=coverage.out -service=github
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/test-server.yaml around lines 53 - 58, The "Install
goveralls and send coverage" step currently uses a floating go install (`@latest`)
and runs only on successful jobs; change the go install invocation to pin
goveralls to a fixed released tag (replace github.com/mattn/goveralls@latest
with github.com/mattn/goveralls@<specific-version>) so CI is reproducible, and
add if: always() to the step so coverage upload runs even when tests fail (leave
COVERALLS_TOKEN and -service=github as-is).

38 changes: 15 additions & 23 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
version: "2"
run:
timeout: 5m
output:
formats:
- format: colored-line-number
formatters:
enable:
- goimports
- gofmt
linters:
enable-all: false
disable-all: true
enable:
- govet
- goimports
- thelper
- tparallel
- unconvert
- wastedassign
- revive
- unused
- gofmt
- whitespace
- misspell
linters-settings:
revive:
ignore-generated-header: true
severity: warning
issues:
exclude-dirs:
- api/proto
- clients/java
- clients/js
- docs
- scripts
- ui
fix: true
severity:
default-severity: error
- errcheck
- staticcheck
exclusions:
paths:
- clients/java
- clients/js
- docs
- scripts
- ui
- gen
6 changes: 3 additions & 3 deletions cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ func checkSchemaCmd(cdk *CDK) *cobra.Command {
}

cmd.Flags().StringVarP(&namespaceID, "namespace", "n", "", "Parent namespace ID")
cmd.MarkFlagRequired("namespace")
_ = cmd.MarkFlagRequired("namespace")

cmd.Flags().StringVarP(&comp, "comp", "c", "", "Schema compatibility")
cmd.MarkFlagRequired("comp")
_ = cmd.MarkFlagRequired("comp")

cmd.Flags().StringVarP(&file, "file", "F", "", "Path to the schema file")
cmd.MarkFlagRequired("file")
_ = cmd.MarkFlagRequired("file")

return cmd
}
4 changes: 2 additions & 2 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ func createSchemaCmd(cdk *CDK) *cobra.Command {
}

cmd.Flags().StringVarP(&namespaceID, "namespace", "n", "", "Namespace ID")
cmd.MarkFlagRequired("namespace")
_ = cmd.MarkFlagRequired("namespace")

cmd.Flags().StringVarP(&format, "format", "f", "", "Schema format")

cmd.Flags().StringVarP(&comp, "comp", "c", "", "Schema compatibility")

cmd.Flags().StringVarP(&file, "file", "F", "", "Path to the schema file")
cmd.MarkFlagRequired("file")
_ = cmd.MarkFlagRequired("file")

return cmd
}
2 changes: 1 addition & 1 deletion cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func deleteSchemaCmd(cdk *CDK) *cobra.Command {
}

cmd.Flags().StringVarP(&namespaceID, "namespace", "n", "", "Parent namespace ID")
cmd.MarkFlagRequired("namespace")
_ = cmd.MarkFlagRequired("namespace")

cmd.Flags().Int32VarP(&version, "version", "v", 0, "Particular version to be deleted")

Expand Down
10 changes: 6 additions & 4 deletions cmd/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ func diffSchemaCmd(cdk *CDK) *cobra.Command {
}

var placeholder map[string]interface{}
json.Unmarshal(eJson, &placeholder)
if err := json.Unmarshal(eJson, &placeholder); err != nil {
return err
}
config := formatter.AsciiFormatterConfig{
ShowArrayIndex: true,
Coloring: true,
Expand All @@ -147,11 +149,11 @@ func diffSchemaCmd(cdk *CDK) *cobra.Command {
}

cmd.Flags().StringVarP(&namespace, "namespace", "n", "", "Parent namespace ID")
cmd.MarkFlagRequired("namespace")
_ = cmd.MarkFlagRequired("namespace")
cmd.Flags().Int32Var(&earlierVersion, "earlier-version", 0, "Earlier version of the schema")
cmd.MarkFlagRequired("earlier-version")
_ = cmd.MarkFlagRequired("earlier-version")
cmd.Flags().Int32Var(&laterVersion, "later-version", 0, "Later version of the schema")
cmd.MarkFlagRequired("later-version")
_ = cmd.MarkFlagRequired("later-version")
cmd.Flags().StringVar(&fullname, "fullname", "", "Only applicable for FORMAT_PROTO. fullname of proto schema eg: raystack.common.v1.Version")
return cmd
}
4 changes: 2 additions & 2 deletions cmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ func downloadSchemaCmd(cdk *CDK) *cobra.Command {
}

cmd.Flags().StringVarP(&namespaceID, "namespace", "n", "", "Parent namespace ID")
cmd.MarkFlagRequired("namespace")
_ = cmd.MarkFlagRequired("namespace")

cmd.Flags().Int32VarP(&version, "version", "v", 0, "Version of the schema")

cmd.Flags().StringVarP(&output, "output", "o", "", "Path to the output file")
cmd.MarkFlagRequired("output")
_ = cmd.MarkFlagRequired("output")

return cmd
}
4 changes: 2 additions & 2 deletions cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ func editSchemaCmd(cdk *CDK) *cobra.Command {
}

cmd.Flags().StringVarP(&namespaceID, "namespace", "n", "", "Parent namespace ID")
cmd.MarkFlagRequired("namespace")
_ = cmd.MarkFlagRequired("namespace")

cmd.Flags().StringVarP(&comp, "comp", "c", "", "Schema compatibility")
cmd.MarkFlagRequired("comp")
_ = cmd.MarkFlagRequired("comp")

return cmd
}
4 changes: 2 additions & 2 deletions cmd/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"os"

"github.com/MakeNowJust/heredoc"
"github.com/raystack/stencil/pkg/graph"
stencilv1beta1 "github.com/raystack/stencil/gen/raystack/stencil/v1beta1"
"github.com/raystack/stencil/pkg/graph"
"github.com/spf13/cobra"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/descriptorpb"
Expand Down Expand Up @@ -63,7 +63,7 @@ func graphSchemaCmd(cdk *CDK) *cobra.Command {
}

cmd.Flags().StringVarP(&namespaceID, "namespace", "n", "", "provide namespace/group or entity name")
cmd.MarkFlagRequired("namespace")
_ = cmd.MarkFlagRequired("namespace")

cmd.Flags().Int32VarP(&version, "version", "v", 0, "provide version number")

Expand Down
4 changes: 2 additions & 2 deletions cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func infoSchemaCmd(cdk *CDK) *cobra.Command {
}

cmd.Flags().StringVarP(&namespace, "namespace", "n", "", "Provide schema namespace")
cmd.MarkFlagRequired("namespace")
_ = cmd.MarkFlagRequired("namespace")

return cmd
}
Expand Down Expand Up @@ -117,7 +117,7 @@ func versionSchemaCmd(cdk *CDK) *cobra.Command {
}

cmd.Flags().StringVarP(&namespaceID, "namespace", "n", "", "parent namespace ID")
cmd.MarkFlagRequired("namespace")
_ = cmd.MarkFlagRequired("namespace")

return cmd
}
2 changes: 1 addition & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func listSchemaCmd(cdk *CDK) *cobra.Command {
}

cmd.Flags().StringVarP(&namespace, "namespace", "n", "", "Namespace ID")
cmd.MarkFlagRequired("namespace")
_ = cmd.MarkFlagRequired("namespace")

return cmd
}
Loading
Loading