mirror of
https://github.com/kataras/iris.git
synced 2025-03-14 08:16:28 +01:00
Merge pull request #1729 from kataras/travis-to-github-actions
From Travis CI to GitHub Actions
This commit is contained in:
commit
2ac4e5a119
13
.github/scripts/setup_examples_test.bash
vendored
Executable file
13
.github/scripts/setup_examples_test.bash
vendored
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
for f in ../../_examples/*; do
|
||||||
|
if [ -d "$f" ]; then
|
||||||
|
# Will not run if no directories are available
|
||||||
|
go mod init
|
||||||
|
go get -u github.com/kataras/iris/v12@master
|
||||||
|
go mod download
|
||||||
|
go run .
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# git update-index --chmod=+x ./.github/scripts/setup_examples_test.bash
|
37
.github/workflows/ci.yml
vendored
Normal file
37
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go_version: [1.15,1.16]
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Set up Go 1.x
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go_version }}
|
||||||
|
|
||||||
|
- name: Check out code into the Go module directory
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: go test -v ./...
|
||||||
|
|
||||||
|
- name: Setup examples for testing
|
||||||
|
run: ./.github/scripts/setup_examples_test.bash
|
||||||
|
|
||||||
|
- name: Test examples
|
||||||
|
continue-on-error: true
|
||||||
|
working-directory: _examples
|
||||||
|
run: go test -v -mod=mod -cover -race ./...
|
35
.travis.yml
35
.travis.yml
|
@ -1,35 +0,0 @@
|
||||||
sudo: false
|
|
||||||
language: go
|
|
||||||
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
- osx
|
|
||||||
go:
|
|
||||||
# We support the latest two major Go versions:
|
|
||||||
# https://golang.org/doc/devel/release.html
|
|
||||||
- 1.15.x
|
|
||||||
- 1.16.x
|
|
||||||
# - master
|
|
||||||
go_import_path: github.com/kataras/iris/v12
|
|
||||||
env:
|
|
||||||
global:
|
|
||||||
- GO111MODULE=on
|
|
||||||
addons:
|
|
||||||
hosts:
|
|
||||||
- mydomain.com
|
|
||||||
- www.mydomain.com
|
|
||||||
- myotherdomain.com
|
|
||||||
- mymy.com
|
|
||||||
- testdomain.com
|
|
||||||
- testdomain1.com
|
|
||||||
- testdomain2.com
|
|
||||||
install:
|
|
||||||
- go get ./...
|
|
||||||
script:
|
|
||||||
- go test -count=1 -v -cover -race ./...
|
|
||||||
after_script:
|
|
||||||
# examples
|
|
||||||
- cd ./_examples
|
|
||||||
- go get ./...
|
|
||||||
- go test -count=1 -v -cover -race ./...
|
|
||||||
- cd ../
|
|
32
README.md
32
README.md
|
@ -222,14 +222,44 @@ Venkatt Guhesan" title="vguhesan" with="75" style="width:75px;max-width:75px;hei
|
||||||
|
|
||||||
## 📖 Learning Iris
|
## 📖 Learning Iris
|
||||||
|
|
||||||
|
### Create a new project
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ mkdir myapp
|
$ mkdir myapp
|
||||||
$ cd myapp
|
$ cd myapp
|
||||||
$ go mod init myapp
|
$ go mod init myapp
|
||||||
$ go get github.com/kataras/iris/v12@master # or @v12.2.0-alpha2
|
$ go get github.com/kataras/iris/v12@master # or @v12.2.0-alpha2
|
||||||
$ go mod download
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<details><summary>Install on existing project</summary>
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ cd myapp
|
||||||
|
$ go get github.com/kataras/iris/v12@master
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details><summary>Install with a go.mod file</summary>
|
||||||
|
|
||||||
|
```txt
|
||||||
|
module myapp
|
||||||
|
|
||||||
|
go 1.16
|
||||||
|
|
||||||
|
require github.com/kataras/iris/v12 master # or v12.2.0-alpha2
|
||||||
|
```
|
||||||
|
|
||||||
|
**Run**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ go mod download
|
||||||
|
$ go run main.go
|
||||||
|
# OR go run -mod=mod main.go
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Iris contains extensive and thorough **[documentation](https://www.iris-go.com/docs)** making it easy to get started with the framework.
|
Iris contains extensive and thorough **[documentation](https://www.iris-go.com/docs)** making it easy to get started with the framework.
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
* [MySQL, Groupcache & Docker](database/mysql)
|
* [MySQL, Groupcache & Docker](database/mysql)
|
||||||
* [MongoDB](database/mongodb)
|
* [MongoDB](database/mongodb)
|
||||||
* [Sqlx](database/orm/sqlx/main.go)
|
* [Sqlx](database/orm/sqlx/main.go)
|
||||||
* [Xorm](database/orm/xorm/main.go)
|
|
||||||
* [Gorm](database/orm/gorm/main.go)
|
* [Gorm](database/orm/gorm/main.go)
|
||||||
* [Reform](database/orm/reform/main.go)
|
* [Reform](database/orm/reform/main.go)
|
||||||
* HTTP Server
|
* HTTP Server
|
||||||
|
|
|
@ -14,7 +14,7 @@ $ docker-compose up --build
|
||||||
|
|
||||||
### Install (Manually)
|
### Install (Manually)
|
||||||
|
|
||||||
Run `go build` or `go run main.go` and read below.
|
Run `go build -mod=mod` or `go run -mod=mod main.go` and read below.
|
||||||
|
|
||||||
#### MySQL
|
#### MySQL
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ $ docker-compose up --build
|
||||||
|
|
||||||
### Install (Manually)
|
### Install (Manually)
|
||||||
|
|
||||||
Run `go build` or `go run main.go` and read below.
|
Run `go build -mod=mod` or `go run -mod=mod main.go` and read below.
|
||||||
|
|
||||||
#### MySQL
|
#### MySQL
|
||||||
|
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
// Package main shows how an orm can be used within your web app
|
|
||||||
// it just inserts a column and select the first.
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/kataras/iris/v12"
|
|
||||||
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
|
||||||
"xorm.io/xorm"
|
|
||||||
)
|
|
||||||
|
|
||||||
/*
|
|
||||||
go get -u github.com/mattn/go-sqlite3
|
|
||||||
go get -u xorm.io/xorm
|
|
||||||
|
|
||||||
If you're on win64 and you can't install go-sqlite3:
|
|
||||||
1. Download: https://sourceforge.net/projects/mingw-w64/files/latest/download
|
|
||||||
2. Select "x86_x64" and "posix"
|
|
||||||
3. Add C:\Program Files\mingw-w64\x86_64-7.1.0-posix-seh-rt_v5-rev1\mingw64\bin
|
|
||||||
to your PATH env variable.
|
|
||||||
|
|
||||||
Docs: https://gitea.com/xorm/xorm
|
|
||||||
*/
|
|
||||||
|
|
||||||
// User is our user table structure.
|
|
||||||
type User struct {
|
|
||||||
ID int64 // auto-increment by-default by xorm
|
|
||||||
Version string `xorm:"varchar(200)"`
|
|
||||||
Salt string
|
|
||||||
Username string
|
|
||||||
Password string `xorm:"varchar(200)"`
|
|
||||||
Languages string `xorm:"varchar(200)"`
|
|
||||||
CreatedAt time.Time `xorm:"created"`
|
|
||||||
UpdatedAt time.Time `xorm:"updated"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
app := iris.New()
|
|
||||||
|
|
||||||
orm, err := xorm.NewEngine("sqlite3", "./test.db")
|
|
||||||
if err != nil {
|
|
||||||
app.Logger().Fatalf("orm failed to initialized: %v", err)
|
|
||||||
}
|
|
||||||
iris.RegisterOnInterrupt(func() {
|
|
||||||
orm.Close()
|
|
||||||
})
|
|
||||||
|
|
||||||
if err = orm.Sync2(new(User)); err != nil {
|
|
||||||
app.Logger().Fatalf("orm failed to initialized User table: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
app.Get("/insert", func(ctx iris.Context) {
|
|
||||||
user := &User{Username: "kataras", Salt: "hash---", Password: "hashed", CreatedAt: time.Now(), UpdatedAt: time.Now()}
|
|
||||||
orm.Insert(user)
|
|
||||||
|
|
||||||
ctx.Writef("user inserted: %#v", user)
|
|
||||||
})
|
|
||||||
|
|
||||||
app.Get("/get", func(ctx iris.Context) {
|
|
||||||
user := User{ID: 1}
|
|
||||||
found, err := orm.Get(&user) // fetch user with ID.
|
|
||||||
if err != nil {
|
|
||||||
ctx.StopWithError(iris.StatusInternalServerError, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !found {
|
|
||||||
ctx.StopWithText(iris.StatusNotFound, "User with ID: %d not found", user.ID)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.Writef("User Found: %#v", user)
|
|
||||||
})
|
|
||||||
|
|
||||||
// http://localhost:8080/insert
|
|
||||||
// http://localhost:8080/get
|
|
||||||
app.Listen(":8080")
|
|
||||||
}
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
const addr = "127.0.0.1:8080"
|
const addr = "127.0.0.1:8080"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$ go build -ldflags -H=windowsgui -o myapp.exe
|
$ go build -mod=mod -ldflags -H=windowsgui -o myapp.exe
|
||||||
$ ./myapp.exe # run the app
|
$ ./myapp.exe # run the app
|
||||||
*/
|
*/
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
const addr = "127.0.0.1:8080"
|
const addr = "127.0.0.1:8080"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$ go build -ldflags="-H windowsgui" -o myapp.exe # build for windows
|
$ go build -mod=mod -ldflags="-H windowsgui" -o myapp.exe # build for windows
|
||||||
$ ./myapp.exe # run
|
$ ./myapp.exe # run
|
||||||
*/
|
*/
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -13,7 +13,7 @@ const addr = "127.0.0.1:8080"
|
||||||
# http://tdm-gcc.tdragon.net/download
|
# http://tdm-gcc.tdragon.net/download
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
$ go build -ldflags="-H windowsgui" -o myapp.exe # build for windows
|
$ go build -mod=mod -ldflags="-H windowsgui" -o myapp.exe # build for windows
|
||||||
$ ./myapp.exe # run
|
$ ./myapp.exe # run
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,5 @@
|
||||||
|
html {
|
||||||
|
font-family: sans-serif;
|
||||||
|
-webkit-text-size-adjust: 100%;
|
||||||
|
-ms-text-size-adjust: 100%
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
|
@ -38,8 +38,8 @@ func newApp() *iris.Application {
|
||||||
func main() {
|
func main() {
|
||||||
app := newApp()
|
app := newApp()
|
||||||
|
|
||||||
// http://localhost:8080/static/css/bootstrap.min.css
|
// http://localhost:8080/static/css/main.css
|
||||||
// http://localhost:8080/static/js/jquery-2.1.1.js
|
// http://localhost:8080/static/js/main.js
|
||||||
// http://localhost:8080/static/favicon.ico
|
// http://localhost:8080/static/favicon.ico
|
||||||
app.Listen(":8080")
|
app.Listen(":8080")
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,8 @@ func (r resource) loadFromBase(dir string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var urls = []resource{
|
var urls = []resource{
|
||||||
"/static/css/bootstrap.min.css",
|
"/static/css/main.css",
|
||||||
"/static/js/jquery-2.1.1.js",
|
"/static/js/main.js",
|
||||||
"/static/favicon.ico",
|
"/static/favicon.ico",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ func TestEmbeddingFilesIntoApp(t *testing.T) {
|
||||||
|
|
||||||
e.GET(url).Expect().
|
e.GET(url).Expect().
|
||||||
Status(httptest.StatusOK).
|
Status(httptest.StatusOK).
|
||||||
ContentType(u.contentType(), app.ConfigurationReadOnly().GetCharset()).
|
ContentType(u.contentType()).
|
||||||
Body().Equal(contents)
|
Body().Equal(contents)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -10,7 +10,7 @@ import (
|
||||||
// # OR: go get -u github.com/go-bindata/go-bindata/v3/go-bindata
|
// # OR: go get -u github.com/go-bindata/go-bindata/v3/go-bindata
|
||||||
// # to save it to your go.mod file
|
// # to save it to your go.mod file
|
||||||
// $ go-bindata -prefix "../embedding-files-into-app/assets/" -fs ../embedding-files-into-app/assets/...
|
// $ go-bindata -prefix "../embedding-files-into-app/assets/" -fs ../embedding-files-into-app/assets/...
|
||||||
// $ go run .
|
// $ go run -mod=mod .
|
||||||
// Time to complete the compression and caching of [2/3] files: 31.9998ms
|
// Time to complete the compression and caching of [2/3] files: 31.9998ms
|
||||||
// Total size reduced from 156.6 kB to:
|
// Total size reduced from 156.6 kB to:
|
||||||
// br (22.9 kB) [85.37%]
|
// br (22.9 kB) [85.37%]
|
||||||
|
@ -45,8 +45,8 @@ func newApp() *iris.Application {
|
||||||
func main() {
|
func main() {
|
||||||
app := newApp()
|
app := newApp()
|
||||||
|
|
||||||
// http://localhost:8080/static/css/bootstrap.min.css
|
// http://localhost:8080/static/css/main.css
|
||||||
// http://localhost:8080/static/js/jquery-2.1.1.js
|
// http://localhost:8080/static/js/main.js
|
||||||
// http://localhost:8080/static/favicon.ico
|
// http://localhost:8080/static/favicon.ico
|
||||||
app.Listen(":8080")
|
app.Listen(":8080")
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,13 +56,14 @@ func (r resource) loadFromBase(dir string) string {
|
||||||
|
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
result = strings.ReplaceAll(result, "\n", "\r\n")
|
result = strings.ReplaceAll(result, "\n", "\r\n")
|
||||||
|
result = strings.ReplaceAll(result, "\r\r", "")
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
var urls = []resource{
|
var urls = []resource{
|
||||||
"/static/css/bootstrap.min.css",
|
"/static/css/main.css",
|
||||||
"/static/js/jquery-2.1.1.js",
|
"/static/js/main.js",
|
||||||
"/static/favicon.ico",
|
"/static/favicon.ico",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ func TestJSONLogger(t *testing.T) {
|
||||||
|
|
||||||
app.Get("/ping", ping)
|
app.Get("/ping", ping)
|
||||||
|
|
||||||
const expectedLogStr = `{"level":"debug","message":"Request path: /ping","fields":{"request_id":null},"stacktrace":[{"function":"json-logger/ping","source":"C:/mygopath/src/github.com/kataras/iris/_examples/logging/json-logger/main.go:78"}]}`
|
const expectedLogStr = `{"level":"debug","message":"Request path: /ping","fields":{"request_id":null},"stacktrace":[{"function":"json-logger/ping","source":"/home/runner/work/iris/iris/_examples/logging/json-logger/main.go:78"}]}` // gh actions-specific.
|
||||||
e := httptest.New(t, app, httptest.LogLevel("debug"))
|
e := httptest.New(t, app, httptest.LogLevel("debug"))
|
||||||
wg := new(sync.WaitGroup)
|
wg := new(sync.WaitGroup)
|
||||||
wg.Add(iters)
|
wg.Add(iters)
|
||||||
|
|
|
@ -15,8 +15,7 @@ import (
|
||||||
// 1. Install Redis:
|
// 1. Install Redis:
|
||||||
// 1.1 Windows: https://github.com/ServiceStack/redis-windows
|
// 1.1 Windows: https://github.com/ServiceStack/redis-windows
|
||||||
// 1.2 Other: https://redis.io/download
|
// 1.2 Other: https://redis.io/download
|
||||||
// 2. go mod download
|
// 2. Run command: go run -mod=mod main.go
|
||||||
// 3. go run main.go
|
|
||||||
//
|
//
|
||||||
// Tested with redis version 3.0.503.
|
// Tested with redis version 3.0.503.
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
// $ go get go.etcd.io/bbolt/...
|
// $ go get go.etcd.io/bbolt/...
|
||||||
// $ go get github.com/google/uuid
|
// $ go get github.com/google/uuid
|
||||||
// $ cd $GOPATH/src/github.com/kataras/iris/_examples/url-shortener
|
// $ cd $GOPATH/src/github.com/kataras/iris/_examples/url-shortener
|
||||||
// $ go build
|
// $ go build -mod=mod
|
||||||
// $ ./url-shortener
|
// $ ./url-shortener
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// GOARCH=wasm GOOS=js /home/$yourusername/go1.14/bin/go build -o hello.wasm hello_go114.go
|
// GOARCH=wasm GOOS=js /home/$yourusername/go1.16/bin/go build -mod=mod -o hello.wasm hello_go116.go
|
||||||
js.Global().Get("console").Call("log", "Hello Webassembly!")
|
js.Global().Get("console").Call("log", "Hello Webassembly!")
|
||||||
message := fmt.Sprintf("Hello, the current time is: %s", time.Now().String())
|
message := fmt.Sprintf("Hello, the current time is: %s", time.Now().String())
|
||||||
js.Global().Get("document").Call("getElementById", "hello").Set("innerText", message)
|
js.Global().Get("document").Call("getElementById", "hello").Set("innerText", message)
|
|
@ -5,8 +5,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
You need to build the hello.wasm first, download the go1.14 and execute the below command:
|
You need to build the hello.wasm first, download the go1.16 and execute the below command:
|
||||||
$ cd client && GOARCH=wasm GOOS=js /home/$yourname/go1.14/bin/go build -o hello.wasm hello_go114.go
|
$ cd client && GOARCH=wasm GOOS=js /home/$yourname/go1.16/bin/go build -mod=mod -o hello.wasm hello_go116.go
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user