Skip to content

api: add initial implementation #1

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
91 changes: 91 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: testing

on:
push:
pull_request:
workflow_dispatch:

jobs:
tests:
# We want to run on external PRs, but not on our own internal
# PRs as they'll be run by the push to the branch.
#
# The main trick is described here:
# https://github.com/Dart-Code/Dart-Code/pull/2375
#
# Also we want to run it always for manually triggered workflows.
if: (github.event_name == 'push') ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository) ||
(github.event_name == 'workflow_dispatch')

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
golang:
- '1.13'
- '1.20'

steps:
- uses: actions/checkout@v3

- name: Setup golang ${{ matrix.golang }}
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.golang }}

- run: make test

master-build:
if: (github.event_name == 'push') ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository) ||
(github.event_name == 'workflow_dispatch')

runs-on: ubuntu-latest

strategy:
fail-fast: false

steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3

- run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH

- run: make deps

- run: TT_TAG=master make

golangci-lint:
if: (github.event_name == 'push') ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository) ||
(github.event_name == 'workflow_dispatch')

runs-on: ubuntu-latest

strategy:
fail-fast: false

steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
continue-on-error: true
with:
# The first run is for GitHub Actions error format.
args: -E goimports

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# The second run is for human-readable error format with a file name
# and a line number.
args: --out-${NO_FUTURE}format colored-line-number -E goimports
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
SHELL := /bin/bash

.PHONY: all
all: generate test

.PHONY: deps
deps:
go install golang.org/x/tools/cmd/goimports@latest
go install golang.org/x/tools/cmd/stringer@latest

.PHONY: format
format:
goimports -l -w .

.PHONY: generate
generate:
go generate ./...

.PHONY: test
test:
@echo "Running all packages tests"
go clean -testcache
go test -tags ./... -v -p 1
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
[![Go Reference][godoc-badge]][godoc-url]
[![Actions Status][actions-badge]][actions-url]
[![Telegram][telegram-badge]][telegram-url]
[![Telegram Russian][telegram-badge]][telegramru-url]

# iproto

## Import

```go
import "github.com/tarantool/go-iproto"
```

## Overview

Package `iproto` contains IPROTO constants.

The code generated from Tarantool code. Code generation is only supported for
an actual commit/release. We do not have a goal to support all versions of
Tarantool with a code generator.

## Example

```go
package main

import (
"fmt"

"github.com/tarantool/go-iproto"
)

func main() {
fmt.Printf("%s=%d\n", iproto.ER_READONLY, iproto.ER_READONLY)
fmt.Printf("%s=%d\n", iproto.IPROTO_FEATURE_WATCHERS, iproto.IPROTO_FEATURE_WATCHERS)
fmt.Printf("%s=%d\n", iproto.IPROTO_FLAG_COMMIT, iproto.IPROTO_FLAG_COMMIT)
fmt.Printf("%s=%d\n", iproto.IPROTO_SYNC, iproto.IPROTO_SYNC)
fmt.Printf("%s=%d\n", iproto.IPROTO_SELECT, iproto.IPROTO_SELECT)
}
```

## Development

You need to install `git` and `go1.13+` first. After that, you need to install
additional dependencies into `$GOBIN`:

```bash
make deps
```

You can generate the code with commands:

```bash
TT_TAG=master make
TT_TAG=2.10.6 make
TT_TAG=master TT_REPO=https://github.com/my/tarantool.git make
```

You need to specify a target branch/tag with the environment variable `TT_TAG`
and you could to specify a repository with the `TT_REPO`.

Makefile has additional targets that can be useful:

```bash
make format
TT_TAG=master make generate
make test
```

A good starting point is [generate.go](./generate.go).

[actions-badge]: https://github.com/tarantool/go-iproto/actions/workflows/test.yml/badge.svg
[actions-url]: https://github.com/tarantool/go-iproto/actions/workflows/test.yml
[godoc-badge]: https://pkg.go.dev/badge/github.com/tarantool/go-iproto.svg
[godoc-url]: https://pkg.go.dev/github.com/tarantool/go-iproto
[telegram-badge]: https://img.shields.io/badge/Telegram-join%20chat-blue.svg
[telegram-url]: http://telegram.me/tarantool
[telegramru-url]: http://telegram.me/tarantoolru
10 changes: 10 additions & 0 deletions doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading