Skip to content

Commit

Permalink
Merge pull request #149 from OdyseeTeam/cache-sf
Browse files Browse the repository at this point in the history
add some sort of caching/singleflight to comment list (replies count)
  • Loading branch information
nikooo777 authored Aug 25, 2023
2 parents d5a7d3a + a766d1e commit 8fa6596
Show file tree
Hide file tree
Showing 27 changed files with 282 additions and 348 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: CI

on: [ push, pull_request ]

jobs:
build:
runs-on: ubuntu-20.04 # equivalent to 'dist: focal'

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: start Default Ubuntu MySQL
run: sudo systemctl start mysql.service

- name: Before Install
run: |
sudo mysql -u root -proot -e 'CREATE DATABASE IF NOT EXISTS commentron;'
sudo mysql -u root -proot -e 'CREATE DATABASE IF NOT EXISTS social;'
sudo mysql -u root -proot -e "CREATE USER 'lbry-rw'@'localhost' IDENTIFIED BY 'lbry';"
sudo mysql -u root -proot -e "CREATE USER 'lbry-ro'@'localhost' IDENTIFIED BY 'lbry';"
sudo mysql -u root -proot -e "GRANT ALL ON commentron.* TO 'lbry-rw'@'localhost';"
sudo mysql -u root -proot -e "GRANT SELECT ON commentron.* TO 'lbry-ro'@'localhost';"
sudo mysql -u root -proot -e "GRANT ALL ON social.* TO 'lbry-rw'@'localhost';"
- name: Cache
uses: actions/cache@v2
with:
path: |
${{ runner.home }}/go/pkg/mod
${{ runner.home }}/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Add SSH Go Module Private Key
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.GO_MODULE_PRIVATE_KEY }}"
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV
- name: Setup access for private go modules
run: |
git config --global url."ssh://[email protected]/".insteadOf https://github.com/
- name: Run Scripts and Tests
env:
GOPRIVATE: github.com/OdyseeTeam
IS_TEST: true
SDK_URL: https://api.lbry.tv/api/v1/proxy
run: |
./scripts/build.sh
./scripts/lint.sh
source ./scripts/setup.sh
./bin/commentron serve &
sleep 5s
curl -i -H 'Accept: application/json' -H 'Content-Type: application/json' http://localhost:5900
go test ./...
go mod tidy
git diff --exit-code
./scripts/gen_models.sh
sqlboiler --version
git diff --exit-code
./bin/commentron test
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v7

- name: Deploy
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
BRANCH_NAME: ${{ steps.branch-name.outputs.current_branch }}
if: github.event_name == 'push'
run: |
bash docker/docker.sh
50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions docker/docker.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
## test ci
echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin
docker build --tag odyseeteam/commentron:$TRAVIS_BRANCH ./
docker push odyseeteam/commentron:$TRAVIS_BRANCH
docker build --tag odyseeteam/commentron:$BRANCH_NAME ./
docker push odyseeteam/commentron:$BRANCH_NAME
60 changes: 31 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
module github.com/OdyseeTeam/commentron

go 1.19
go 1.20

require (
github.com/Avalanche-io/counter v0.0.0-20180124180526-1336089e985a
github.com/OdyseeTeam/sockety v0.0.0-20230308052819-59d9a79cac89
github.com/OdyseeTeam/sockety v0.0.0-20230814192354-2d488f4b5af7
github.com/btcsuite/btcd v0.0.0-20190213025234-306aecffea32
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d
github.com/caarlos0/env v3.5.0+incompatible
github.com/coreos/go-oidc v2.2.1+incompatible
github.com/fatih/color v1.15.0
github.com/fatih/structs v1.1.0
github.com/friendsofgo/errors v0.9.2
github.com/go-co-op/gocron v1.19.0
github.com/go-sql-driver/mysql v1.7.0
github.com/go-co-op/gocron v1.32.1
github.com/go-sql-driver/mysql v1.7.1
github.com/gorilla/mux v1.8.0
github.com/gorilla/rpc v1.2.0
github.com/gorilla/websocket v1.5.0
Expand All @@ -27,65 +27,67 @@ require (
github.com/lbryio/ozzo-validation v3.0.3-0.20170512160344-202201e212ec+incompatible
github.com/mitchellh/mapstructure v1.5.0
github.com/pkg/profile v1.7.0
github.com/prometheus/client_golang v1.14.0
github.com/rs/cors v1.8.3
github.com/rubenv/sql-migrate v1.4.0
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.2
github.com/prometheus/client_golang v1.16.0
github.com/rs/cors v1.9.0
github.com/rubenv/sql-migrate v1.5.2
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cast v1.5.1
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.8.4
github.com/stripe/stripe-go v70.15.0+incompatible
github.com/volatiletech/null/v8 v8.1.2
github.com/volatiletech/sqlboiler/v4 v4.14.2
github.com/volatiletech/strmangle v0.0.4
github.com/volatiletech/sqlboiler/v4 v4.15.0
github.com/volatiletech/strmangle v0.0.5
github.com/ybbus/jsonrpc/v2 v2.1.7
golang.org/x/sync v0.3.0
)

require (
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/fgprof v0.9.3 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/gofrs/uuid v4.2.0+incompatible // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/johntdyer/slack-go v0.0.0-20230314151037-c5bf334f9b6e // indirect
github.com/lbryio/types v0.0.0-20220224142228-73610f6654a6 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pquerna/cachecontrol v0.1.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/slack-go/slack v0.12.1 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/volatiletech/inflect v0.0.1 // indirect
github.com/volatiletech/randomize v0.0.1 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/nullbio/null.v6 v6.0.0-20161116030900-40264a2e6b79 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
Expand Down
Loading

0 comments on commit 8fa6596

Please sign in to comment.