capstonelabs / slick Goto Github PK
View Code? Open in Web Editor NEWThis project forked from abourget/slick
Slick, a Slack bot in Go
This project forked from abourget/slick
Slick, a Slack bot in Go
A webpage that provides basic information about the connection and state.
N/A.
This is a first for a chatbot, I believe. Most chatbots do not have web interface.
Would be nice to run the tests on every change. We should add Travis CI and some code coverage platform.
Unfortunately, @abourget has not gotten back to me after the numerous times I've tried to reach him about taking over slick and even doing a forward from the old repository.
I think at this point I'm ready to hard-fork the repo. This comes with numerous advantages that a fork like this one does not afford us.
In doing this I think we should probably rename the repository to avoid confusion with the old repository and the old maintainers. I'd love to hear some suggestions for a new name.
It's my first issue ever, so hello everyone :) So..
I'm trying run slick
in Docker, so I write some code:
FROM golang:alpine as builder
RUN mkdir /build
RUN apk add --update gcc go git mercurial \
&& go get github.com/CapstoneLabs/slick
ADD . /build/
WORKDIR /build
RUN go install -v
FROM alpine
RUN apk --no-cache add ca-certificates
RUN adduser -S -D -H -h /app appuser
USER appuser
COPY --from=builder /build/main /app/
WORKDIR /app
EXPOSE 8080
CMD ["./main"]
But I get a Error:
github.com/CapstoneLabs/slick
src/github.com/CapstoneLabs/slick/bot.go:142:11: bot.Slack.SetDebug undefined (type *slack.Client has no field or method SetDebug)
src/github.com/CapstoneLabs/slick/updateable.go:29:105: cannot use u.newFormattedMessage() (type string) as type slack.MsgOption in argument to u.reply.bot.Slack.UpdateMessage
So my question is how to build this app correctly?
Part 1 is just getting a go.mod
file running.
There is a 302 that's occurring that modules seem not to play well with.
Fix import references to GitLab
This is an actual CI change. We need to cut a version branch and apply the version tag to its latest commit.
We need proper ..slick.conf
for example-bot, at this moment I use plotbot.sample.conf
but is invalid.
$ docker logs slick
time="2018-10-17T11:00:26Z" level=error msg="Error in config JSON syntax." error="invalid character '\"' after object key:value pair"
time="2018-10-17T11:00:26Z" level=fatal msg="Error loading config file." error="invalid character '\"' after object key:value pair"
To reproduce errors:
docker build -t slick .
docker run -d --name slick slick:latest
docker logs slick
Slack deprecated several ev.Info
API's which were used to determine channels, IM's, and groups. The nlopes/slack
package API's still work but return an empty struct.
Here's the functions that can be tested but are not:
func (msg *Message) String() string {
return fmt.Sprintf("%#v", msg)
}
func (msg *Message) applyMentionsMe(bot *Bot) {
if msg.IsPrivate() {
msg.MentionsMe = true
}
m := reAtMention.FindStringSubmatch(msg.Text)
if m != nil && m[1] == bot.Myself.ID {
msg.MentionsMe = true
}
}
func (msg *Message) applyFromMe(bot *Bot) {
if msg.User != "" && msg.User == bot.Myself.ID {
msg.FromMe = true
}
}
var reAtMention = regexp.MustCompile(`<@([A-Z0-9]+)(|([^>]+))>`)
// Format conditionally formats using fmt.Sprintf if there is more
// than one argument, otherwise returns the first parameter
// uninterpreted.
func Format(s string, v ...interface{}) string {
count := len(v)
if count == 0 {
return s
}
return fmt.Sprintf(s, v...)
}
dates.go
needs some tests. Use of the testify
package is not required, test tables are fine too.
I wrote some test cases for this plugin, but from the function GetTasksByAssignee
i need real Asana access.
Therefore, should I set up an Asana's account or leave tests at this stage?
This will give several different serialization options, specifically hitting the large ones (JSON, YAML, TOML)
Related to #28
Currently go test -short
, gofmt
, and go vet
are running for every pull request.
When a PR is merged to master we should:
Go Modules are based on repo tags in combination with semantic version. This process would support that.
This probably also means we need a VERSION file that can be updated and read from both by Go and CI tooling.
Duplicates #8
The testify package promotes some nice testing patterns. They are a bit more familiar to me coming from Python so maybe they'll help others too.
This is kind of an experiment so it may be not merged or removed in the future.
CI was implemented after merging the asana tests and have made master fail.
Currently the project has minimal code documentation and zero user documentation. readthedocs.io can help solve that.
Resources
https://docs.readthedocs.io/en/latest/intro/getting-started-with-sphinx.html
PR Template content should populate the PR body.
PR body is blank
Rename the file to pull_request_template.md
from generic.md
.
People are making PR's without creating issues first because the PR doesn't remind them to.
Plotly wrote a lot of plugins that are very specific to them and have no place in the core code. These could be easily attached using Slick's plugin system.
A list of plugins to remove:
Plugins to refactor:
This will probably be an issue that needs to be split out but we can use this issue to garner more attention.
Currently, the bot is nearly 100% untested, from its core functionality to the plugins.
logging.go
needs some tests. Using the testify
package or test tables is fine.
In order to do some of the integration tests I'd like to do in the future, we'll need a place to run Slick. A Kubernetes manifest not only serves as a form of documentation on how to run Slick but also gives us a start on integration tests.
This post is really here as a landing page for places like Reddit. While Capstone has donated a considerable amount of time to resurrecting Slick, it really needs a lot of TLC.
I bring this up because it's Hacktoberfest but there's also a lot opportunities for those that are still in the early stages of learning Go. I'm actually within my own first year.
We chose Slick because it's a very functional and extensible package, it's not another Javascript Slackbot, and because there didn't seem to be other Go chatbot packages out there.
Open a PR and let's start merging :)
Test the return functions of message.go
Some functions are action functions which do need to be tested but should be tested in integration testing.
Logrus will enable configurable logging
Trying to build the project, I'm getting the following error in master:
./bot.go:142:11: bot.Slack.SetDebug undefined (type *slack.Client has no field or method SetDebug)
./updateable.go:29:105: cannot use u.newFormattedMessage() (type string) as type slack.MsgOption in argument to u.reply.bot.Slack.UpdateMessage
FAIL github.com/jegutierrez/slick [build failed]
Am I doing something wrong? or is there another branch where this is not happening?
Thanks in advance,
Je
We need some contribution guidelines.
At this moment I have 3 basic test cases for parms.go:
func TestParsedTags(t *testing.T) {
var dp1 = DeployParams{
Tags: "version-1.12",
}
var dp2 = DeployParams{
Environment: "stage",
}
t1 := dp1.ParsedTags()
t2 := dp2.ParsedTags()
if t1 != "version-1.12" || t2 != "updt_streambed" {
t.Errorf("Function ParsedTags - ERROR")
}
}
func TestParsedDeploymentBranch(t *testing.T) {
var dp1 = DeployParams{
DeploymentBranch: "version-1.11",
}
var dp2 = DeployParams{
Environment: "stage",
}
t1 := dp1.ParsedDeploymentBranch("Develop")
t2 := dp2.ParsedDeploymentBranch("Develop")
if t1 != "version-1.12" || t2 != "Develop" {
t.Errorf("Function ParsedDeploymentBranch - ERROR")
}
}
func TestStringer(t *testing.T) {
var dp = DeployParams{
Environment: "STAGE",
DeploymentBranch: "Develop",
Tags: "ver-1.12",
InitiatedBy: "3sky",
}
if fmt.Sprintf("%s", &dp) != "env=STAGE branch=[default] tags=ver-1.12 deploy_branch=Develop by 3sky" {
t.Errorf("Function Stringer - ERROR")
}
}
The next step I want to do it's testing rest of deployer
functions. To do that some mock for exec
command is needed, any ideas how deal with that ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.