Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate to gh actions #37

Merged
merged 6 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions .circleci/config.yml

This file was deleted.

66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: CI
on:
push:
branches:
- new
pull_request:

env:
go-version: "1.19.5"

jobs:
check-golangci-lint:
name: Check golangci-lint
runs-on: ubuntu-22.04
steps:
- name: Checkout mattermost-govet
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Setup Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: ${{ env.go-version }}
- name: Run golangci-lint
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: v1.52.2

build:
name: Build
runs-on: ubuntu-22.04
steps:
- name: Checkout mattermost-govet
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Setup Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@336e29918d653399e599bfca99fadc1d7ffbc9f7 # v4.3.0
with:
args: release --skip-sign --skip-publish --snapshot --rm-dist
lieut-data marked this conversation as resolved.
Show resolved Hide resolved

test:
name: Run Tests
runs-on: ubuntu-22.04
steps:
- name: Checkout mattermost-govet
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
path: mattermost-govet
- name: Setup Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: ${{ env.go-version }}
- name: Setup Node
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3.7.0
isacikgoz marked this conversation as resolved.
Show resolved Hide resolved
- name: Checkout mattermost
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
repository: mattermost/mattermost
path: mattermost
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific branch name ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should test with master ideally, though, this project will be removed to mattermost/mattermost.

- name: Build
run: |
cd mattermost/api
make build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels weird that we pick this one thing to build and test with mattermost-govet, but not all the other clients of the tool, e.g. the license checker, etc.

Do we actually need to test this on "both sides"? Should we just continue doing this in the monorepo? (Should mattermost-govet be part of the monorepo... 🤔)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make sense if we can collate tools like govet under tools directory in the monorepo. In fact, I believe it will be really helpful as I always lost the track what tools we have. Maybe a good item to discuss in the dev meeting?

- name: Run Tests
run: |
cd mattermost-govet
make test
5 changes: 2 additions & 3 deletions openApiSync/openApiSync.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func processRouterInit(pass *analysis.Pass, names []string, routerPrefixes map[s
if stringInSlice(handler, IgnoredCases, true) { // ignore special cases
continue
}
handler = strings.TrimPrefix(handler, "api/v4")
if !strings.HasPrefix(handler, "/") {
handler = "/" + handler
}
Expand Down Expand Up @@ -170,7 +169,7 @@ func parseInitFunction(pass *analysis.Pass, decl *ast.FuncDecl, routerPrefixes m
continue
}
subRouterName := formatNode(pass.Fset, node.Lhs[0])[15:]
if subRouterName == "ApiRoot" || subRouterName == "Root" {
if subRouterName == "APIRoot" || subRouterName == "APIRoot5" || subRouterName == "Root" {
continue
}

Expand All @@ -179,7 +178,7 @@ func parseInitFunction(pass *analysis.Pass, decl *ast.FuncDecl, routerPrefixes m
path := rhs[strings.Index(rhs, ".")+13 : strings.LastIndex(rhs, ".")-2]
prefix := ""
switch router {
case "ApiRoot":
case "APIRoot":
prefix = "api/v4"
case "Root":
prefix = ""
Expand Down
2 changes: 1 addition & 1 deletion openApiSync/openApiSync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ import (
func Test(t *testing.T) {
rand.Seed(1)
testdata := analysistest.TestData()
specFile = "../../mattermost-api-reference/v4/html/static/mattermost-openapi-v4.yaml"
specFile = "../../mattermost/api/v4/html/static/mattermost-openapi-v4.yaml"
analysistest.Run(t, testdata, Analyzer, "api")
}
8 changes: 4 additions & 4 deletions openApiSync/testdata/src/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

type Routes struct {
Root *mux.Router // ''
ApiRoot *mux.Router // 'api/v4'
APIRoot *mux.Router // 'api/v4'

Users *mux.Router // 'api/v4/userzs'
Groups *mux.Router // 'api/v4/groups'
Expand All @@ -30,10 +30,10 @@ func Init(root *mux.Router) *API {
BaseRoutes: &Routes{},
}
api.BaseRoutes.Root = root
api.BaseRoutes.ApiRoot = root.PathPrefix("api/v4").Subrouter()
api.BaseRoutes.APIRoot = root.PathPrefix("api/v4").Subrouter()

api.BaseRoutes.Users = api.BaseRoutes.ApiRoot.PathPrefix("/users").Subrouter() // want "PathPrefix doesn't match field comment for field 'Users': 'api/v4/users' vs 'api/v4/userzs'"
api.BaseRoutes.Groups = api.BaseRoutes.ApiRoot.PathPrefix("/gruops").Subrouter() // want "PathPrefix doesn't match field comment for field 'Groups': 'api/v4/gruops' vs 'api/v4/groups'"
api.BaseRoutes.Users = api.BaseRoutes.APIRoot.PathPrefix("/users").Subrouter() // want "PathPrefix doesn't match field comment for field 'Users': 'api/v4/users' vs 'api/v4/userzs'"
api.BaseRoutes.Groups = api.BaseRoutes.APIRoot.PathPrefix("/gruops").Subrouter() // want "PathPrefix doesn't match field comment for field 'Groups': 'api/v4/gruops' vs 'api/v4/groups'"
api.InitUsers()
return api
}
Expand Down
4 changes: 2 additions & 2 deletions openApiSync/testdata/src/api/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
)

func (a *API) InitUsers() {
a.BaseRoutes.Users.Handle("/ids", a.ApiSessionRequired(getUsersByIds)).Methods("POST") // want `Cannot find /userzs/ids method: POST in OpenAPI 3 spec. \(maybe you meant: \[/users/ids\]\)`
a.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}/{syncable_type:teams|channelz}/{syncable_id:[A-Za-z0-9]+}/link", a.ApiSessionRequired(getUsersByIds)).Methods("POST") // want `Cannot find /groups/{group_id}/channelz/{syncable_id}/link method: POST in OpenAPI 3 spec.`
a.BaseRoutes.Users.Handle("/ids", a.ApiSessionRequired(getUsersByIds)).Methods("POST") // want `Cannot find /api/v4/userzs/ids method: POST in OpenAPI 3 spec. \(maybe you meant: \[/api/v4/users/ids\]\)`
a.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}/{syncable_type:teams|channelz}/{syncable_id:[A-Za-z0-9]+}/link", a.ApiSessionRequired(getUsersByIds)).Methods("POST") // want `Cannot find /api/v4/groups/{group_id}/channelz/{syncable_id}/link method: POST in OpenAPI 3 spec.`

}
func getUsersByIds(c *context.Context, w http.ResponseWriter, r *http.Request) {
Expand Down
Loading