Skip to content

Commit

Permalink
Merge pull request #141 from hofstadter-io/docs-ci
Browse files Browse the repository at this point in the history
hof/docs: ci work
  • Loading branch information
verdverm authored Feb 26, 2023
2 parents bea98af + 3cec1ef commit 377035a
Show file tree
Hide file tree
Showing 48 changed files with 494 additions and 213 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ jobs:
docs:
runs-on: ubuntu-latest
steps:
- run: |-
mkdir tmp
cd tmp
wget https://github.com/cue-lang/cue/releases/download/v0.5.0-beta.5/cue_v0.5.0-beta.5_linux_amd64.tar.gz -O cue.tar.gz
tar -xf cue.tar.gz
sudo mv cue /usr/local/bin/cue
cd ../
rm -rf tmp
- name: Install Go
uses: actions/setup-go@v3
with:
Expand Down Expand Up @@ -39,18 +47,16 @@ jobs:
- name: Build hof
run: go install ./cmd/hof
- name: Setup
run: "cd docs\nmake first "
- name: Test
run: |-
cd docs
make test
- name: Build
run: |-
hof fmt start prettier@v0.6.8-beta.6
cd docs
make build
- name: Check
hof mod link
make deps
- name: Test
run: |-
cd docs
make gen
make test
make run &
make broken-link
strategy: {}
Expand Down
63 changes: 61 additions & 2 deletions .github/workflows/release-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,43 @@ name: release (docs)
"on":
push:
tags:
- docs-*
- docs-**
workflow_dispatch:
inputs:
deploy:
description: where to deploy
required: true
default: next
type: choice
options:
- next
- prod
jobs:
docs:
runs-on: ubuntu-latest
environment: hof docs
steps:
- run: |-
mkdir tmp
cd tmp
wget https://github.com/cue-lang/cue/releases/download/v0.5.0-beta.5/cue_v0.5.0-beta.5_linux_amd64.tar.gz -O cue.tar.gz
tar -xf cue.tar.gz
sudo mv cue /usr/local/bin/cue
cd ../
rm -rf tmp
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- uses: actions/cache@v3
with:
path: |-
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
~\AppData\Local\go-build
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ matrix.go-version }}-
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Vars
Expand All @@ -20,7 +52,34 @@ jobs:
fi
echo "HOF_SHA=${SHA}" >> $GITHUB_ENV
echo "HOF_TAG=${TAG}" >> $GITHUB_ENV
- name: Setup
- name: Fetch Go deps
run: go mod download
- name: Build hof
run: go install ./cmd/hof
- name: Setup
run: |-
hof fmt start prettier@v0.6.8-beta.6
cd docs
hof mod link
make deps
- name: Build
run: |-
cd docs
make gen
make hugo.next
- name: GCloud Auth
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.HOF_GCLOUD_JSON }}
- name: GCloud Setup
uses: google-github-actions/setup-gcloud@v1
- name: Docker Auth
run: gcloud auth configure-docker
- name: Image
run: |-
cd docs
make docker
make push
make deploy.next.view
strategy: {}
services: {}
55 changes: 55 additions & 0 deletions ci/gha/common/steps.cue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ Steps: {
"""
}

cue: {
install: {
#ver: string | *"v0.5.0-beta.5"
run: """
mkdir tmp
cd tmp
wget https://github.com/cue-lang/cue/releases/download/\(#ver)/cue_\(#ver)_linux_amd64.tar.gz -O cue.tar.gz
tar -xf cue.tar.gz
sudo mv cue /usr/local/bin/cue
cd ../
rm -rf tmp
"""
}
}

go: {
setup: {
#ver: string | *(string & Versions.go)
Expand Down Expand Up @@ -110,5 +125,45 @@ Steps: {

}
}

gcloud: {
auth: {
name: "GCloud Auth"
uses: "google-github-actions/auth@v1"
with: credentials_json: "${{ secrets.HOF_GCLOUD_JSON }}"
}
setup: {
name: "GCloud Setup"
uses: "google-github-actions/setup-gcloud@v1"
}

dockerAuth: {
name: "Docker Auth"
run: """
gcloud auth configure-docker
"""
}
}

hof: {
install: {
name: "Build hof"
run: "go install ./cmd/hof"
}
}

docs: {

setup: {
name: "Setup"
run: """
hof fmt start prettier@v0.6.8-beta.6
cd docs
hof mod link
make deps
"""
}

}
}

34 changes: 7 additions & 27 deletions ci/gha/docs.cue
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,25 @@ ghacue.#Workflow & {
jobs: {
docs: {
"runs-on": "ubuntu-latest"
// environment: "hof docs"

steps: [
// general setup
common.Steps.cue.install,
common.Steps.go.setup & { #ver: "1.20.x" },
common.Steps.go.cache,
common.Steps.checkout,
common.Steps.vars,
common.Steps.go.deps,
{
name: "Build hof"
run: "go install ./cmd/hof"
},
{
name: "Setup"
run: """
cd docs
make first
"""
},
common.Steps.hof.install,

// dev build site & test
common.Steps.docs.setup,
{
name: "Test"
run: """
cd docs
make gen
make test
"""
},
{
name: "Build"
run: """
cd docs
make build
"""
},

{
name: "Check"
run: """
cd docs
make run &
make broken-link
"""
Expand All @@ -61,4 +42,3 @@ ghacue.#Workflow & {
}
}
}

52 changes: 47 additions & 5 deletions ci/gha/release-docs.cue
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,65 @@ import (
ghacue.#Workflow & {
name: "release (docs)"

on: push: {
tags: ["docs-*"]
on: {
push: {
tags: ["docs-**"]
}
workflow_dispatch: {
inputs: {
deploy: {
description: "where to deploy"
required: true
default: "next"
type: "choice"
options: ["next", "prod"]
}
}
}
}

jobs: {
docs: {
"runs-on": "ubuntu-latest"
// environment: "hof docs"
environment: "hof docs"

steps: [
// general setup
common.Steps.cue.install,
common.Steps.go.setup & { #ver: "1.20.x" },
common.Steps.go.cache,
common.Steps.checkout,
common.Steps.vars,
common.Steps.go.deps,
common.Steps.hof.install,

// prod build site & image
common.Steps.docs.setup,
{
name: "Setup"
run: "go install ./cmd/hof"
name: "Build"

run: """
cd docs
make gen
make hugo.next
"""
},

// gcloud auth setup
common.Steps.gcloud.auth,
common.Steps.gcloud.setup,
common.Steps.gcloud.dockerAuth,

// push image & deploy
{
name: "Image"
run: """
cd docs
make docker
make push
make deploy.next.view
"""
},
]
}
}
Expand Down
9 changes: 8 additions & 1 deletion docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
/dist/
/resources/
/code/*.html

# ignore html files generatied from cue files
/code/**/*.html
# remember html files we manually write for examples
!/code/**/templates/*.html
!/code/**/templates/**/*.html
!/code/**/partials/*.html
!/code/**/partials/**/*.html

# /code/flow/examples/
# /code/flow/schemas/
/cue.mod/pkg/
Expand Down
14 changes: 6 additions & 8 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include ./hack/make/*.inc

TAG = $(shell git rev-parse --short HEAD | tr -d "\n")
PROJECT = "hof-io--develop"
COMMIT = $(shell git rev-parse --short HEAD | tr -d "\n")
PROJECT = "hof-io--develop"

help:
@cat Makefile
Expand All @@ -11,15 +11,13 @@ run: dev
lint: fmt broken-link
test: verify

.PHONY: fmt broken-link code highlight
.PHONY: fmt broken-link highlight
fmt: cuefmt gofmt
broken-link: blc.dev
examples: gen
highlight: highlight-cue

# build the world and push to production
.PHONY: first setup publish
first: deps setup
setup: config.yaml extern code highlight
publish: setup build deploy
.PHONY: first gen
first: deps gen
gen: config.yaml extern examples highlight

2 changes: 1 addition & 1 deletion docs/ci/cuelm.cue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Update: schema.#List & {

#Site: {
_Values: {
name: "hof-docs"
name: string | *"hof-docs" @tag(name)
namespace: "websites"

registry: "us.gcr.io/hof-io--develop"
Expand Down
5 changes: 5 additions & 0 deletions docs/code/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
gen:
make -C first-example gen

test:
make -C first-example test
2 changes: 1 addition & 1 deletion docs/code/cmd-help/hof
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Main commands:
gen modular and composable code gen: CUE & data + templates = _
flow run CUE pipelines with the hof/flow DAG engine
fmt format any code and manage the formatters
mod go style dependency management for CUE
mod CUE dependency management based on Go mods

Additional commands:
help help about any command
Expand Down
Loading

0 comments on commit 377035a

Please sign in to comment.