Skip to content

Commit

Permalink
move to sqlite storage backend #major
Browse files Browse the repository at this point in the history
  • Loading branch information
bart6114 committed Jun 29, 2024
2 parents 07bbecd + c3ee9b9 commit dbfa73b
Show file tree
Hide file tree
Showing 47 changed files with 2,726 additions and 720 deletions.
32 changes: 26 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,25 @@ jobs:
- tests
- golangci
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
outputs:
new_tag: ${{ steps.tag_action.outputs.new_tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Bump version and push tag
if: github.ref == 'refs/heads/main'
id: tag_action
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch
PRERELEASE: ${{ github.ref != 'refs/heads/main' }}

build:
needs: version_tag
runs-on: ubuntu-latest
## need decent versioning strategy in future
if: github.ref == 'refs/heads/main'
env:
CGO_ENABLED: 0
strategy:
Expand All @@ -69,9 +68,19 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
## build tailwind assets
- uses: actions/setup-node@v4
with:
node-version: '19'
- uses: pnpm/action-setup@v2
with:
version: 8
- run: pnpm install
- run: npm run build
## setup go
- uses: actions/setup-go@v5
with:
go-version: "^1.16"
go-version: "^1.22"
## above is fine to get latest for now, also save a copy with short sha
- id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
Expand All @@ -87,10 +96,21 @@ jobs:
- id: upload-files
uses: google-github-actions/[email protected]
with:
path: ${{ matrix.goos }}/${{ matrix.goarch }}
destination: cheek-scheduler/${{ matrix.goos }}/
path: ${{ matrix.goos }}/${{ matrix.goarch }}/cheek-${{ steps.vars.outputs.sha_short }}
destination: cheek-scheduler/${{ matrix.goos }}/${{ matrix.goarch }}/
- uses: google-github-actions/[email protected]
if: github.ref == 'refs/heads/main'
with:
path: ${{ matrix.goos }}/${{ matrix.goarch }}/cheek-${{ needs.version_tag.outputs.new_tag }}
destination: cheek-scheduler/${{ matrix.goos }}/${{ matrix.goarch }}/
- uses: google-github-actions/[email protected]
if: github.ref == 'refs/heads/main'
with:
path: ${{ matrix.goos }}/${{ matrix.goarch }}/cheek
destination: cheek-scheduler/${{ matrix.goos }}/${{ matrix.goarch }}/

docker-build:
## only do this on main
needs:
- build
- version_tag
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,7 @@ build
cheek
cover.out
butt
*sheep
*sheep
*.sqlite3
node_modules
*.out
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

`cheek` is a pico-sized declarative job scheduler designed to excel in a single-node environment. `cheek` aims to be lightweight, stand-alone and simple. It does not compete for robustness.

> 📄 This bump to v1 introduces a storage backend switch, moving from jsonline logs to sqlite. This might introduce the need to adjust your long-term log storage approach.
## Getting started

Fetch the latest version for your system below.
Expand All @@ -22,7 +24,7 @@ Fetch the latest version for your system below.
[linux-arm64](https://storage.googleapis.com/cheek-scheduler/linux/arm64/cheek) |
[linux-amd64](https://storage.googleapis.com/cheek-scheduler/linux/amd64/cheek)

You can (for example) fetch it like below, make it executable and run it. Optionally put the `cheek` on your `PATH`.
You can (for example) fetch it like below, make it executable and run it. Optionally put `cheek` on your `PATH`.

```sh
curl https://storage.googleapis.com/cheek-scheduler/darwin/amd64/cheek -o cheek
Expand Down Expand Up @@ -81,13 +83,11 @@ Check out `cheek run --help` for configuration options.

`cheek` ships with a web UI that by default gets launched on port `8081`. You can define the port on which it is accessible via the `--port` flag.

| ![main-screen](https://i.imgur.com/hq0Zxjb.png) |
| :---------------------------------------------: |
| main overview |
![main-screen](/readme_assets/main.png)
main overview

| ![detail](https://i.imgur.com/jc9wBQJ.png) |
| :----------------------------------------: |
| job detail |
![main-screen](/readme_assets/joboverview.png)
job detail

You can access the UI by navigating to `http://localhost:8081`. When `cheek` is deployed you are recommended to NOT make this port publicly accessible, instead navigate to the UI via an SSH tunnel.

Expand Down
7 changes: 7 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"path"

cheek "github.com/datarootsio/cheek/pkg"
"github.com/spf13/cobra"
Expand All @@ -12,6 +13,7 @@ import (
var (
httpPort string
homeDir string
dbPath string
)

// rootCmd represents the base command when called without any subcommands
Expand All @@ -30,6 +32,7 @@ func Execute() {
func init() {
rootCmd.PersistentFlags().StringVar(&httpPort, "port", "8081", "port on which to open the http server for core to ui communication")
rootCmd.PersistentFlags().StringVar(&homeDir, "homedir", cheek.CheekPath(), fmt.Sprintf("directory in which to save cheek's core & job logs, defaults to '%s'", cheek.CheekPath()))
rootCmd.PersistentFlags().StringVar(&dbPath, "dbpath", path.Join(cheek.CheekPath(), "cheek.sqlite3"), fmt.Sprintf("path to sqlite3 db used for logging, defaults to '%s'", path.Join(cheek.CheekPath(), "cheek.sqlite3")))
cobra.OnInitialize(initConfig)
}

Expand Down Expand Up @@ -61,4 +64,8 @@ func initConfig() {
if err := viper.BindPFlag("homedir", rootCmd.PersistentFlags().Lookup("homedir")); err != nil {
fmt.Printf("error binding pflag %s", err)
}

if err := viper.BindPFlag("dbpath", rootCmd.PersistentFlags().Lookup("dbpath")); err != nil {
fmt.Printf("error binding pflag %s", err)
}
}
7 changes: 6 additions & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ var runCmd = &cobra.Command{
fmt.Println("cannot init configuration")
os.Exit(1)
}
l := cheek.NewLogger(logLevel, cheek.PrettyStdout())
if err := c.Init(); err != nil {
fmt.Println("cannot init configuration")
os.Exit(1)
}

l := cheek.NewLogger(logLevel, c.DB, cheek.PrettyStdout())
return cheek.RunSchedule(l, c, args[0])
},
}
Expand Down
6 changes: 5 additions & 1 deletion cmd/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ The name should be defined in your schedule specs. Usage:
if err := viper.Unmarshal(&c); err != nil {
return err
}
l := cheek.NewLogger(logLevel, cheek.PrettyStdout())
if err := c.Init(); err != nil {
return err
}

l := cheek.NewLogger(logLevel, c.DB, cheek.PrettyStdout())
_, err := cheek.RunJob(l, c, args[0], args[1])
return err
},
Expand Down
196 changes: 0 additions & 196 deletions coverage.out

This file was deleted.

Loading

0 comments on commit dbfa73b

Please sign in to comment.