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
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI
on:
push:
branches:
- main
- develop
- feat/**
pull_request:
branches:
- main
- develop
- feat/**

jobs:
cli-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: stable
- name: cli-lint
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --timeout=10m
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: stable
- name: Run Tests
run: make test || exit 1
- name: Upload Test Reports
uses: actions/upload-artifact@v6
with:
name: test-reports
path: reports/tests-cov.out
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: stable
- name: Run Build
run: make build || exit 1
8 changes: 4 additions & 4 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ jobs:
run:
working-directory: ./docs
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: master
submodules: true
submodules: true
fetch-depth: 0

- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
uses: peaceiris/actions-hugo@v3
with:
hugo-version: 'latest'
extended: true
- name: Build
run: hugo --minify

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/public
Expand Down
31 changes: 0 additions & 31 deletions .github/workflows/goreleaser.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: goreleaser

on:
push:
tags:
- "*"

jobs:
goreleaser:
environment: releaser
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.25.x
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ github.token }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ dist/
resources/

dist/
docs/resources
docs/resources
reports/
20 changes: 20 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[submodule "tools/hugo"]
path = tools/hugo
url = https://github.com/gohugoio/hugo
branch = master
shallow = true
[submodule "themes/presidium-layouts-base"]
path = themes/presidium-layouts-base
url = https://github.com/SPANDigital/presidium-layouts-base
branch = main
shallow = true
[submodule "themes/presidium-layouts-blog"]
path = themes/presidium-layouts-blog
url = https://github.com/SPANDigital/presidium-layouts-blog
branch = main
shallow = true
[submodule "themes/presidium-styling-base"]
path = themes/presidium-styling-base
url = https://github.com/SPANDigital/presidium-styling-base
branch = main
shallow = true
30 changes: 30 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: "2"
linters:
default: none
enable:
- errcheck
- govet
- ineffassign
- staticcheck
- unused
- gocyclo
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
5 changes: 3 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
before:
hooks:
- go mod tidy
- packr2
builds:
- env:
- tags:
- extended
env:
- CGO_ENABLED=0
goos:
- linux
Expand Down
51 changes: 32 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
FILENAME=main
TESTDIRS=`go list ./... |grep -v "vendor/" |grep -v "swagger/"`
.DEFAULT_GOAL=build
.PHONY: dist clean
FILENAME=presidium
DOCSDIR=docs
.DEFAULT_GOAL=help
.PHONY: build test dist clean fmt vet tidy coverage_report help

test:
help: ## Display available targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-18s %s\n", $$1, $$2}'

build: ## Build the presidium binary
go build -tags extended -o $(FILENAME) .

test: ## Run tests with coverage
@mkdir -p reports
go test -p 1 -v $(TESTDIRS) -coverprofile=reports/tests-cov.out
go test -race -timeout 120s ./... -coverprofile=reports/tests-cov.out

fmt: ## Format Go source files
go fmt ./...

pack:
go get -u github.com/gobuffalo/packr/v2/packr2
packr2
go mod tidy
vet: ## Run go vet
go vet ./...

build:
make pack
go build -o $(FILENAME) main.go
packr2 clean
tidy: ## Tidy and verify module dependencies
go mod tidy && go mod verify

clean:
clean: ## Remove build artifacts
rm -fr "dist"

coverage_report:
coverage_report: ## Open coverage report in browser
@go tool cover -html=reports/tests-cov.out

dist:
[ -d "dist" ] || mkdir "dist"
go build -o "dist/presidium" --tags extended
dist: ## Build distribution binary
mkdir -p "dist"
go build -trimpath -o "dist/presidium" --tags extended

checks: tidy fmt vet lint test build

serve-docs:
cd $(DOCSDIR) && make serve

lint:
golangci-lint run --timeout 10m
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,26 @@ Read Presidium's [documentation](http://presidium.spandigital.net/overview/) for
For detailed instructions on getting started, please see [Getting Started](http://presidium.spandigital.net/getting-started/).

# Features and Issues
All upcoming features and issues are tracked [here](https://github.com/SPANDigital/presidium/issues).
All upcoming features and issues are tracked [here](https://github.com/SPANDigital/presidium/issues).

# Development

Presidium embeds a specific verison of [Hugo](https://github.com/gohugoio/hugo) to ensure that the user is building their docs with a Hugo version that is compatible with our Presidium Themes.

Since we require the embedded Hugo version to be built into a binary, some of the cli commands only work after running the `make build` cmd.

## Getting started

Run the build command:
```
make build
```

Move the binary into a valid documentation site directory, then run the hugo build cmd:
```
./presidium hugo
```
Or if you want to serve the site after the hugo build, then run:
```
./presidium hugo server
```
15 changes: 1 addition & 14 deletions cmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@ var convertCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(convertCmd)
fs := filesystem.New()

cwd, err := fs.GetWorkingDir()
if err != nil {
log.Fatal("could not get working dir")
} else {
cwd, err = fs.AbsolutePath(".")
if err != nil {
log.Fatal("something bad happened to get working dir")
} else {
cwd = "."
}
}

stagingDir, err := filesystem.AFS.TempDir(os.TempDir(), "staging")
if err != nil {
Expand All @@ -60,7 +47,7 @@ func init() {
pflags.StringVarP(&config.Flags.SourceRepoDir, "sourceRepoDir", "s", "", "Source directory")
pflags.StringVar(&config.Flags.BrandTheme, "brand", "", "path to brand theme")
pflags.StringVar(&config.Flags.SyntaxStyle, "markup", "github", "specify markup theme, other than the default github style")
pflags.StringVarP(&config.Flags.DestinationRepoDir, "destDir", "d", cwd, "Destination directory")
pflags.StringVarP(&config.Flags.DestinationRepoDir, "destDir", "d", ".", "Destination directory")
pflags.BoolVar(&config.Flags.AddSlugAndUrl, "slugIt", false, "Add slug and url in the front matter")
pflags.BoolVar(&config.Flags.CleanTarget, "clean", true, "Clean the target directory")
pflags.BoolVarP(&config.Flags.WeightBasedOnFilename, "weightBasedOnFilename", "w", conversion.Defaults.WeightBasedOnFileName, "Base front matter weight on filename")
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func init() {
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().BoolVar(&debug, config.DebugKey, false, "enables debug logs")
rootCmd.PersistentFlags().StringVar(&cfgFile, config.ConfigFileKey, "", "config file (default is $HOME/.presidium.yaml)")
viper.BindPFlag(config.DebugKey, rootCmd.PersistentFlags().Lookup(config.DebugKey))
_ = viper.BindPFlag(config.DebugKey, rootCmd.PersistentFlags().Lookup(config.DebugKey))
}

// initConfig reads in config file and ENV variables if set.
Expand Down
8 changes: 2 additions & 6 deletions cmd/versioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func versionCommand() *cobra.Command {
Short: "managing versioning of presidium site",
Run: func(cmd *cobra.Command, args []string) {
if !enabled {
v:= versioning.New(".")
v := versioning.New(".")
if !v.IsEnabled() {
v.SetEnabled(true)
}
Expand All @@ -28,10 +28,9 @@ func versionCommand() *cobra.Command {
return cmd
}


func activateNextVersionCommand() *cobra.Command {
return &cobra.Command{
Use: "next",
Use: "next",
Short: "creates a next version based on last version",
Run: func(cmd *cobra.Command, args []string) {
v := versioning.New(".")
Expand All @@ -40,7 +39,6 @@ func activateNextVersionCommand() *cobra.Command {
}
}


func syncLatestCommand() *cobra.Command {
return &cobra.Command{
Use: "update",
Expand All @@ -51,5 +49,3 @@ func syncLatestCommand() *cobra.Command {
},
}
}


Loading