Skip to content
Merged
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
25 changes: 25 additions & 0 deletions .github/workflows/goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,32 @@ permissions:
id-token: write

jobs:
lint-test:
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6

- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version: ">=1.26.1"

- name: golangci-lint
uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee # v9
with:
version: latest
install-only: true

- name: lint
run: make lint

- name: unit test
run: make test

goreleaser:
needs: lint-test
uses: libops/.github/.github/workflows/sitectl-plugin-goreleaser.yaml@main
permissions:
contents: write
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/integration-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: integration-test

on:
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: integration-test-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
create-ojs:
name: sitectl create ojs ${{ matrix.create_definition }}
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- create_definition: default
create_args: ""
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10

- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c
with:
go-version: ">=1.26.1"

- name: Install sitectl
uses: libops/.github/.github/actions/install-sitectl@main

- name: setup git identity
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"

- name: Run create integration test
run: make integration-test CREATE_DEFINITION=${{ matrix.create_definition }} CREATE_ARGS="${{ matrix.create_args }}"
env:
TERM: xterm-256color
28 changes: 28 additions & 0 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: lint-test
on: [push]
permissions:
contents: read
packages: write

jobs:
lint-test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6

- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version: ">=1.26.1"

- name: golangci-lint
uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee # v9
with:
version: latest
install-only: true

- name: lint
run: make lint

- name: unit test
run: make test
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ bin/
*.dll
*.so
*.dylib
sitectl-isle
sitectl-isle-*
sitectl-ojs
sitectl-ojs-*

# Test binary, built with `go test -c`
*.test
Expand Down Expand Up @@ -39,5 +39,4 @@ temp/
# Build artifacts
dist/
release/
sitectl-ojs
.cache
1 change: 1 addition & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ brews:
name: homebrew
dependencies:
- name: "libops/homebrew/sitectl"
- name: "libops/homebrew/sitectl-triplet"
nfpms:
- id: sitectl-ojs
package_name: sitectl-ojs
Expand Down
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.PHONY: build deps test work install
.PHONY: build deps lint test work install integration-test

BINARY_NAME=sitectl-ojs
CREATE_DEFINITION?=default
CREATE_ARGS?=
SITECTL_CONTEXT?=integration-test

deps: work
go mod tidy
Expand All @@ -11,8 +14,15 @@ build:
install: build
mv $(BINARY_NAME) /usr/local/bin

lint:
go fmt ./...
golangci-lint run

test: build
go test ./...
go test -v -race ./...

work:
./scripts/use-go-work.sh

integration-test:
SITECTL_CONTEXT="$(SITECTL_CONTEXT)" CREATE_DEFINITION="$(CREATE_DEFINITION)" CREATE_ARGS="$(CREATE_ARGS)" ./scripts/test-create.sh
6 changes: 6 additions & 0 deletions cmd/dependencies.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package cmd

// IncludedPlugins returns application plugins accepted by OJS contexts.
func IncludedPlugins() []string {
return []string{}
}
15 changes: 15 additions & 0 deletions cmd/dependencies_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package cmd

import (
"reflect"
"testing"
)

func TestIncludedPlugins(t *testing.T) {
t.Parallel()

want := []string{}
if got := IncludedPlugins(); !reflect.DeepEqual(got, want) {
t.Fatalf("IncludedPlugins() = %v, want %v", got, want)
}
}
30 changes: 30 additions & 0 deletions cmd/healthcheck.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cmd

import (
"github.com/libops/sitectl/pkg/config"
"github.com/libops/sitectl/pkg/healthcheck"
"github.com/libops/sitectl/pkg/plugin"
sitevalidate "github.com/libops/sitectl/pkg/validate"
"github.com/spf13/cobra"
)

type ojsHealthcheckRunner struct{}

func (ojsHealthcheckRunner) BindFlags(cmd *cobra.Command) {}

func (ojsHealthcheckRunner) Run(cmd *cobra.Command, ctx *config.Context) ([]sitevalidate.Result, error) {
results := []sitevalidate.Result{
healthcheck.CheckHTTP(cmd.Context(), "http:ojs", healthcheck.PublicURLFromEnv(ctx, "http", "localhost")),
}

checker, err := healthcheck.NewDockerChecker(ctx)
if err != nil {
return nil, err
}
defer func() { _ = checker.Close() }()

results = append(results, checker.CheckMariaDB(cmd.Context(), "mariadb"))
return results, nil
}

var _ plugin.HealthcheckRunner = ojsHealthcheckRunner{}
6 changes: 2 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const (
createBranch = "main"
pluginName = "ojs"
defaultPath = "./ojs"
displayName = "OJS"
)

func createDefinition() plugin.CreateSpec {
Expand All @@ -34,12 +33,11 @@ func RegisterCommands(s *plugin.SDK) {
RequiredServices: []string{"ojs"},
Reason: "ojs service",
})
s.AddCommand(s.GetDiscoveryMetadataCommand())
plugin.RegisterStandardComposeTemplate(s, createDefinition(), plugin.StandardComposeTemplateOptions{
s.RegisterComposeTemplateCreateRunner(createDefinition(), plugin.ComposeTemplateCreateOptions{
DefaultPath: defaultPath,
DefaultPlugin: pluginName,
ReadyMessage: "OJS is ready for use through sitectl.",
DisplayName: displayName,
})
s.RegisterHealthcheckRunner(ojsHealthcheckRunner{})
registerOJSCommands(s)
}
30 changes: 21 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,29 @@ module github.com/libops/sitectl-ojs
go 1.26.1

require (
github.com/libops/sitectl v0.17.1
github.com/libops/sitectl v0.19.2
github.com/spf13/cobra v1.10.2
)

require (
charm.land/bubbles/v2 v2.1.0 // indirect
charm.land/bubbletea/v2 v2.0.6 // indirect
charm.land/bubbletea/v2 v2.0.7 // indirect
charm.land/fang/v2 v2.0.1 // indirect
charm.land/glamour/v2 v2.0.0 // indirect
charm.land/lipgloss/v2 v2.0.3 // indirect
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/NimbleMarkets/ntcharts/v2 v2.2.0 // indirect
github.com/alecthomas/chroma/v2 v2.26.1 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/charmbracelet/colorprofile v0.4.3 // indirect
github.com/charmbracelet/ultraviolet v0.0.0-20260525132238-948f4557a654 // indirect
github.com/charmbracelet/ultraviolet v0.0.0-20260601155805-6cf7526a1b3f // indirect
github.com/charmbracelet/x/ansi v0.11.7 // indirect
github.com/charmbracelet/x/exp/charmtone v0.0.0-20260525135217-abeec2b8bf0b // indirect
github.com/charmbracelet/x/exp/charmtone v0.0.0-20260602025833-85a30b5e440a // indirect
github.com/charmbracelet/x/exp/slice v0.0.0-20260602025833-85a30b5e440a // indirect
github.com/charmbracelet/x/term v0.2.2 // indirect
github.com/charmbracelet/x/termios v0.1.1 // indirect
github.com/charmbracelet/x/windows v0.2.2 // indirect
Expand All @@ -29,18 +34,22 @@ require (
github.com/containerd/errdefs v1.0.0 // indirect
github.com/containerd/errdefs/pkg v0.3.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/dlclark/regexp2/v2 v2.1.2 // indirect
github.com/docker/docker v28.5.2+incompatible // indirect
github.com/docker/go-connections v0.7.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/lrstanley/bubblezone/v2 v2.0.0 // indirect
github.com/lucasb-eyer/go-colorful v1.4.0 // indirect
github.com/mattn/go-runewidth v0.0.23 // indirect
github.com/mattn/go-runewidth v0.0.24 // indirect
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/sys/sequential v0.6.0 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
Expand All @@ -56,14 +65,17 @@ require (
github.com/sahilm/fuzzy v0.1.2 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yuin/goldmark v1.8.2 // indirect
github.com/yuin/goldmark-emoji v1.0.6 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0 // indirect
go.opentelemetry.io/otel v1.43.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0 // indirect
go.opentelemetry.io/otel v1.44.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 // indirect
go.opentelemetry.io/otel/metric v1.43.0 // indirect
go.opentelemetry.io/otel/trace v1.43.0 // indirect
go.opentelemetry.io/otel/metric v1.44.0 // indirect
go.opentelemetry.io/otel/trace v1.44.0 // indirect
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
golang.org/x/crypto v0.52.0 // indirect
golang.org/x/net v0.55.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/term v0.43.0 // indirect
Expand Down
Loading