introduce hot reload for docs

This commit is contained in:
Willy Kloucek
2021-02-25 14:37:34 +01:00
parent 387b2f3272
commit 083b39ef17
13 changed files with 95 additions and 47 deletions

View File

@@ -77,6 +77,12 @@ $(HUGO): $(BINGO_DIR)/hugo.mod
@echo "(re)installing $(GOBIN)/hugo-v0.80.0"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=hugo.mod -o=$(GOBIN)/hugo-v0.80.0 "github.com/gohugoio/hugo"
MUTAGEN := $(GOBIN)/mutagen-v0.11.8
$(MUTAGEN): $(BINGO_DIR)/mutagen.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/mutagen-v0.11.8"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=mutagen.mod -o=$(GOBIN)/mutagen-v0.11.8 "github.com/mutagen-io/mutagen/cmd/mutagen"
PROTOC_GEN_DOC := $(GOBIN)/protoc-gen-doc-v1.4.1
$(PROTOC_GEN_DOC): $(BINGO_DIR)/protoc-gen-doc.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.

5
.bingo/mutagen.mod Normal file
View File

@@ -0,0 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
go 1.15
require github.com/mutagen-io/mutagen v0.11.8 // cmd/mutagen

View File

@@ -28,6 +28,8 @@ GOX="${GOBIN}/gox-v1.0.1"
HUGO="${GOBIN}/hugo-v0.80.0"
MUTAGEN="${GOBIN}/mutagen-v0.11.8"
PROTOC_GEN_DOC="${GOBIN}/protoc-gen-doc-v1.4.1"
PROTOC_GEN_GO="${GOBIN}/protoc-gen-go-v1.25.0"

View File

@@ -302,7 +302,7 @@ def testOcisModule(ctx, module):
},
{
'name': 'coverage-cache',
'image': 'plugins/s3',
'image': 'plugins/s3:1',
'settings': {
'endpoint': {
'from_secret': 'cache_s3_endpoint'
@@ -411,7 +411,7 @@ def uploadCoverage(ctx):
},
{
'name': 'sonarcloud',
'image': 'sonarsource/sonar-scanner-cli',
'image': 'sonarsource/sonar-scanner-cli:latest',
'pull': 'always',
'environment': sonar_env,
},
@@ -713,7 +713,7 @@ def dockerRelease(ctx, arch):
build() + [
{
'name': 'dryrun',
'image': 'plugins/docker:18.09',
'image': 'plugins/docker:latest',
'pull': 'always',
'settings': {
'dry_run': True,
@@ -733,7 +733,7 @@ def dockerRelease(ctx, arch):
},
{
'name': 'docker',
'image': 'plugins/docker:18.09',
'image': 'plugins/docker:latest',
'pull': 'always',
'settings': {
'username': {
@@ -783,7 +783,7 @@ def dockerEos(ctx):
build() + [
{
'name': 'dryrun-eos-ocis',
'image': 'plugins/docker:18.09',
'image': 'plugins/docker:latest',
'pull': 'always',
'settings': {
'dry_run': True,
@@ -802,7 +802,7 @@ def dockerEos(ctx):
},
{
'name': 'docker-eos-ocis',
'image': 'plugins/docker:18.09',
'image': 'plugins/docker:latest',
'pull': 'always',
'settings': {
'username': {
@@ -915,10 +915,10 @@ def binaryRelease(ctx, name):
},
{
'name': 'changelog',
'image': 'toolhippie/calens:latest',
'image': 'webhippie/golang:1.15',
'pull': 'always',
'commands': [
'calens --version %s -o ocis/dist/CHANGELOG.md' % ctx.build.ref.replace("refs/tags/v", "").split("-")[0],
'make changelog CHANGELOG_VERSION=%s' % ctx.build.ref.replace("refs/tags/v", "").split("-")[0],
],
'when': {
'ref': [
@@ -1195,17 +1195,16 @@ def docs(ctx):
},
{
'name': 'prepare',
'image': 'owncloudci/alpine:latest',
'image': 'webhippie/golang:1.15',
'commands': [
'make -C docs docs-copy'
],
},
{
'name': 'test',
'image': 'owncloudci/hugo:0.71.0',
'image': 'webhippie/golang:1.15',
'commands': [
'cd docs/hugo',
'hugo',
'make -C docs test'
],
},
{
@@ -1234,13 +1233,13 @@ def docs(ctx):
'name': 'list and remove temporary files',
'image': 'owncloudci/alpine:latest',
'commands': [
'tree hugo/public',
'tree docs/hugo/public',
'rm -rf docs/hugo',
],
},
{
'name': 'downstream',
'image': 'plugins/downstream',
'image': 'plugins/downstream:latest',
'settings': {
'server': 'https://drone.owncloud.com/',
'token': {
@@ -1480,7 +1479,7 @@ def deploy(ctx, config, rebuild):
'steps': [
{
'name': 'clone continuous deployment playbook',
'image': 'alpine/git',
'image': 'alpine/git:latest',
'commands': [
'cd deployments/continuous-deployment-config',
'git clone https://github.com/owncloud-devops/continuous-deployment.git',
@@ -1488,7 +1487,7 @@ def deploy(ctx, config, rebuild):
},
{
'name': 'deploy',
'image': 'owncloudci/drone-ansible',
'image': 'owncloudci/drone-ansible:latest',
'failure': 'ignore',
'environment': {
'CONTINUOUS_DEPLOY_SERVERS_CONFIG': '../%s' % (config),

View File

@@ -1,3 +0,0 @@
.PHONY: changelog
changelog: $(CALENS)
$(CALENS) >| CHANGELOG.md

View File

@@ -4,4 +4,4 @@ config-docs-generate: $(FLAEX)
@$(FLAEX) >| ../docs/extensions/$(NAME)/configuration.md
.PHONY: grpc-docs-generate
grpc-docs-generate: ../docs/extensions/${NAME}/grpc.md
grpc-docs-generate: ../docs/extensions/${NAME}/grpc.md

View File

@@ -106,3 +106,7 @@ $(BIN)/$(EXECUTABLE): $(SOURCES)
$(BIN)/$(EXECUTABLE)-debug: $(SOURCES)
$(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(DEBUG_LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME)
.PHONY: watch
watch: $(REFLEX)
$(REFLEX) -c reflex.conf

View File

@@ -30,4 +30,4 @@ release-check:
cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
.PHONY: release-finish
release-finish: release-copy release-check
release-finish: release-copy release-check

View File

@@ -108,12 +108,6 @@ docs-generate:
$(MAKE) --no-print-directory -C $$mod docs-generate; \
done
.PHONY: config-docs-generate
config-docs-generate:
@for mod in $(OCIS_MODULES); do \
$(MAKE) --no-print-directory -C $$mod config-docs-generate; \
done
.PHONY: ci-go-generate
ci-go-generate:
@for mod in $(OCIS_MODULES); do \
@@ -145,5 +139,15 @@ go-coverage:
echo -n "% coverage $$mod: "; $(MAKE) --no-print-directory -C $$mod go-coverage; \
done
.PHONY: bingo-update
bingo-update: $(BINGO)
$(BINGO) get -u
CHANGELOG_VERSION =
.PHONY: changelog
changelog: $(CALENS)
ifndef CHANGELOG_VERSION
$(error CHANGELOG_VERSION is undefined)
endif
$(CALENS) --version $(CHANGELOG_VERSION) -o ocis/dist/CHANGELOG.md

3
docs/.gitignore vendored
View File

@@ -1 +1,2 @@
hugo/
hugo/
mutagen.yml.lock

View File

@@ -10,29 +10,42 @@ help:
docs-generate: ## run docs-generate for all oCIS extensions
@$(MAKE) --no-print-directory -C ../ docs-generate
.PHONY: config-docs-generate
config-docs-generate: ## run config-docs-generate for all oCIS extensions
@$(MAKE) --no-print-directory -C ../ config-docs-generate
.PHONY: docs-copy
docs-copy: ## copy docs to hugo
.PHONY: docs-init
docs-init:
@mkdir -p hugo/content/
@cd hugo; \
git init; \
git config advice.detachedHead false; \
git remote rm origin; \
git remote add origin https://github.com/owncloud/owncloud.github.io; \
git fetch --depth=1; \
git checkout origin/source -f; \
rsync -ax --delete --exclude hugo/ --exclude Makefile --exclude .gitignore --exclude README.md ../. content/; \
@cd hugo && git init
@cd hugo && git config advice.detachedHead false
@cd hugo && git remote rm origin || true
@cd hugo && git remote add origin https://github.com/owncloud/owncloud.github.io
@cd hugo && git fetch --depth=1
@cd hugo && git checkout origin/source -f
.PHONY: docs-serve
docs-serve: $(HUGO) docs-generate docs-copy ## serve docs with hugo
cd hugo && $(HUGO) server
docs-serve: docs-init docs-generate docs-copy ## serve docs with hugo
@bash -c "trap 'trap - SIGINT SIGTERM ERR; $(MAKE) --no-print-directory docs-sync-stop; exit 0' SIGINT SIGTERM ERR; $(MAKE) --no-print-directory docs-sync-start && $(MAKE) --no-print-directory hugo-serve"
.PHONY: test
test: $(HUGO)
@cd hugo && $(HUGO)
.PHONY: docs-serve-simple
docs-serve-simple: $(HUGO) config-docs-generate docs-copy ## serve docs with hugo without protobuf generation
cd hugo && $(HUGO) server
.PHONY: hugo-serve
hugo-serve: $(HUGO)
@cd hugo && $(HUGO) server
.PHONY: docs-copy
docs-copy: docs-init docs-sync-start docs-sync-stop
.PHONY: docs-sync-start
docs-sync-start: $(MUTAGEN)
@$(MUTAGEN) project terminate || true
@$(MUTAGEN) daemon stop || true
@$(MUTAGEN) project start
@$(MUTAGEN) project flush
.PHONY: docs-sync-stop
docs-sync-stop: $(MUTAGEN)
@$(MUTAGEN) project terminate
@$(MUTAGEN) daemon stop
.PHONY: clean
clean: ## clean up docs build artifacts

14
docs/mutagen.yml Normal file
View File

@@ -0,0 +1,14 @@
sync:
docs:
mode: one-way-replica
alpha: .
beta: ./hugo/content
flushOnCreate: true
ignore:
paths:
- .gitignore
- mutagen.yml
- mutagen.yml.lock
- hugo
- README.md
- Makefile

3
store/reflex.conf Normal file
View File

@@ -0,0 +1,3 @@
# backend
-r '^(cmd|pkg)/.*\.go$' -R '^node_modules/' -s -- sh -c 'make bin/ocis-store-debug && bin/ocis-store-debug --log-level debug server --debug-pprof --debug-zpages'
'