Enable builds on GitHub actions
This commit is contained in:
34
.github/workflows/main.yml
vendored
Normal file
34
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: nixbuild/nix-quick-install-action@v5
|
||||||
|
with:
|
||||||
|
nix_version: 2.4pre20201205_a5d85d0
|
||||||
|
nix_conf: experimental-features = nix-command flakes
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
# TODO reuse cache even when key changes and then do GC
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
id: cache-nix
|
||||||
|
with:
|
||||||
|
path: ~/nix
|
||||||
|
key: ${{ hashFiles('flake.nix') }}-${{ hashFiles('flake.lock') }}-${{ hashFiles('deps.nix') }}
|
||||||
|
- name: Extract the cache
|
||||||
|
if: steps.cache-nix.outputs.cache-hit
|
||||||
|
run: sudo mkdir -p /nix && sudo rsync --recursive --archive ~/nix/ /nix
|
||||||
|
- name: Build
|
||||||
|
run: 'outpath="$(nix build --print-build-logs --no-link --json .# | jq -r .[0].outputs.out)" && echo "tinyquiz-build=$outpath" >> $GITHUB_ENV'
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
path: ${{ env.tinyquiz-build }}/**
|
||||||
|
retention-days: 7
|
||||||
|
if-no-files-found: error
|
||||||
|
- name: Prepare /nix/store for caching
|
||||||
|
if: '!steps.cache-nix.outputs.cache-hit'
|
||||||
|
run: sudo rsync --recursive --archive /nix/ ~/nix
|
||||||
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -10,6 +9,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"vkane.cz/tinyquiz/pkg/model"
|
"vkane.cz/tinyquiz/pkg/model"
|
||||||
"vkane.cz/tinyquiz/pkg/model/ent"
|
"vkane.cz/tinyquiz/pkg/model/ent"
|
||||||
|
"vkane.cz/tinyquiz/pkg/model/ent/migrate"
|
||||||
rtcomm "vkane.cz/tinyquiz/pkg/rtcomm"
|
rtcomm "vkane.cz/tinyquiz/pkg/rtcomm"
|
||||||
|
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
@@ -20,8 +20,8 @@ type application struct {
|
|||||||
errorLog *log.Logger
|
errorLog *log.Logger
|
||||||
infoLog *log.Logger
|
infoLog *log.Logger
|
||||||
templateCache map[string]*template.Template
|
templateCache map[string]*template.Template
|
||||||
model *model.Model
|
model *model.Model
|
||||||
rtClients *rtcomm.Clients
|
rtClients *rtcomm.Clients
|
||||||
}
|
}
|
||||||
|
|
||||||
type templateData struct {
|
type templateData struct {
|
||||||
@@ -47,7 +47,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c, err := ent.Open("postgres", "host='127.0.0.1' sslmode=disable dbname=tinyquiz"); err == nil {
|
if c, err := ent.Open("postgres", "host='127.0.0.1' sslmode=disable dbname=tinyquiz"); err == nil {
|
||||||
if err := c.Schema.Create(context.Background()); err != nil {
|
if err := c.Schema.Create(context.Background(), migrate.WithDropIndex(true), migrate.WithDropColumn(true)); err != nil {
|
||||||
errorLog.Fatal(err)
|
errorLog.Fatal(err)
|
||||||
}
|
}
|
||||||
app.model = model.NewModel(c)
|
app.model = model.NewModel(c)
|
||||||
@@ -57,9 +57,9 @@ func main() {
|
|||||||
|
|
||||||
//TODO remove debug print
|
//TODO remove debug print
|
||||||
go func() {
|
go func() {
|
||||||
for range time.Tick(2*time.Second){
|
for range time.Tick(2 * time.Second) {
|
||||||
sessions, clients := app.rtClients.Count()
|
//sessions, clients := app.rtClients.Count()
|
||||||
fmt.Printf("There are %d sessions with total of %d clients\n", sessions, clients)
|
//fmt.Printf("There are %d sessions with total of %d clients\n", sessions, clients)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user