Skip to content

Commit

Permalink
Add github actions ci job; update xtemplate_caddy
Browse files Browse the repository at this point in the history
  • Loading branch information
infogulch committed Oct 13, 2023
1 parent 1010873 commit 1e382f5
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 5 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: ci

on:
push:
branches: [ "master" ]
tags: [ "v**" ]
pull_request:
branches: [ "master" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...

- run: go build -o xtemplate ./bin

- uses: actions/upload-artifact@v3
with:
name: xtemplate
path: xtemplate
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
go.work*
xtemplate*
10 changes: 10 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
- [ ] Integrate a static file server based on `caddy.caddyhttp.file_server`
- [ ] Add "Why?" section to readme.

### Automation

- Add github workflows
- [ ] Set up go tests
- [ ] Set up hurl tests
- [ ] Publish binaries and release when a git tag is pushed

### Demos

- [ ] Demonstrate how to do auth with xtemplate
Expand All @@ -20,6 +27,7 @@
- [ ] Document how to use standalone
- [ ] Demo how to use standalone
- [ ] Build a way to send live updates to a page by rendering a template to an SSE stream. Maybe backed by NATS.io?
- [ ] Consider using the functional options pattern for configuring XTemplate


# DONE
Expand All @@ -31,3 +39,5 @@
- [x] Split into separate packages `xtemplate` and `xtemplate/caddy`, rename repo to `xtemplate`
- [x] Write basic server based on net/http
- [x] Update docs describe the separate packages
- [x] Add github automation
- [x] Build and upload binaries
23 changes: 21 additions & 2 deletions bin/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
This package wraps `xtemplate` into a usable binary.
This package wraps `xtemplate` into a basic web server binary with CLI options.

Usage:
This is meant to serve as a starting point and demonstration for how to
integrate the XTemplate library into a web server.

### Build

```sh
# build from ./bin
go build -o xtemplate

# build from repo root
go build -o xtemplate ./bin
```

### Usage

```
$ ./xtemplate --help
Expand Down Expand Up @@ -29,3 +42,9 @@ xtemplate is a hypertext preprocessor and http templating web server
-watch-template
Watch the template directory and reload if changed (default true)
```

### Example

```
xtemplate -template-root templates -watch-template -log -4
```
2 changes: 1 addition & 1 deletion caddy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21.0
require (
github.com/caddyserver/caddy/v2 v2.7.4
github.com/infogulch/watch v0.1.2
github.com/infogulch/xtemplate v0.1.1
github.com/infogulch/xtemplate v0.1.2
github.com/mattn/go-sqlite3 v1.14.17
go.uber.org/zap/exp v0.2.0
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
Expand Down
4 changes: 2 additions & 2 deletions caddy/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ github.com/infogulch/pathmatcher v0.2.0 h1:pi8/e2BQ8x1nB1WAEnnVOIw+EciKDDSUYqDZs
github.com/infogulch/pathmatcher v0.2.0/go.mod h1:ywO4eSHD1ARQElpii9hjqkPYFZ+IZKJ+3qDo9IZyt78=
github.com/infogulch/watch v0.1.2 h1:7mF3VN1T1Nby5NO0npTqE+OgHR7+OfJO261stDJH7TY=
github.com/infogulch/watch v0.1.2/go.mod h1:i9OU29MppSWictJKM3LoipjLVw+6VHiOK/SrzfujJGc=
github.com/infogulch/xtemplate v0.1.1 h1:+nGXlKkPM+/vYX0rpWXdk/SMFomMn60mOnQiJk2Xs9I=
github.com/infogulch/xtemplate v0.1.1/go.mod h1:bIMBcUB3Pio3lwX2TCaQW5RKrdvVi8CSCc3uH0qBy8g=
github.com/infogulch/xtemplate v0.1.2 h1:ytJtL3301cKkr9i3zdf/s1Bdh08KDWv/mWdvWyXbMjQ=
github.com/infogulch/xtemplate v0.1.2/go.mod h1:FZwceAVuWokIWwb9jjMvnd0iaZTU3j2Ur08wGk+wHh4=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
Expand Down

0 comments on commit 1e382f5

Please sign in to comment.