Skip to content

Commit

Permalink
Merge branch 'master' into pr/84
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Dec 30, 2023
2 parents 6bddf8e + b469982 commit b25c184
Show file tree
Hide file tree
Showing 68 changed files with 2,126 additions and 1,156 deletions.
129 changes: 103 additions & 26 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,110 @@
name: goreleaser

name: Release
on:
pull_request:
push:
tags:
- 'v*'
env:
GO_VERSION: stable

jobs:
goreleaser:
build_for_linux:
name: Build for Linux
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v2
- name: Install build dependencies
run: |
sudo apt-get -qq update
sudo apt-get install -y --no-install-recommends \
build-essential
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Build amd64
env:
CGO_ENABLED: 1
GOOS: linux
GOARCH: amd64
run: make release
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: dist-linux
path: sqls-linux-*.zip

build_for_macos:
name: Build for MacOS
runs-on: macos-latest
steps:
- name: Install build dependencies
run: brew install coreutils
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Build amd64
env:
CGO_ENABLED: 1
GOOS: darwin
GOARCH: amd64
run: make release
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: dist-darwin
path: sqls-darwin-*.zip

build_for_windows:
name: Build for Windows
runs-on: windows-latest
steps:
- name: Install build dependencies
run: choco install zip
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Build amd64
shell: bash
env:
CGO_ENABLED: 1
GOOS: windows
GOARCH: amd64
run: make release
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: dist-windows
path: sqls-windows-*.zip

release:
name: Draft Release
needs:
- build_for_linux
- build_for_macos
- build_for_windows
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
go-version: 1.15
-
name: Run GoReleaser(xcgo) Snapshot
run: |
make snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Run GoReleaser(xcgo) Publish
if: startsWith(github.ref, 'refs/tags/v')
run: |
make publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: sqls ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
draft: true
generate_release_notes: true
files: dist-*/sqls*.*
22 changes: 7 additions & 15 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,16 @@ on:

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
go-version:
- 1.13.x
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout
uses: actions/checkout@v2
- name: Install golangci-lint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.43.0
go-version: 1.21
- name: Lint
run: /home/runner/go/bin/golangci-lint run
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
- name: Test
run: go test -coverprofile coverage.out -covermode atomic ./...
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ changelog:
- '^test:'
release:
github:
owner: lighttiger2505
owner: sqls-server
name: sqls
# If set to auto, will mark the release as not ready for production
# in case there is an indicator for this in the tag e.g. v1.0.0-rc1
Expand Down
98 changes: 51 additions & 47 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,51 +1,55 @@
NAME := sqls
VERSION := $(shell git describe --tags `git rev-list --tags --max-count=1`)
REVISION := $(shell git rev-parse --short HEAD)
GOVERSION := $(go version)
GITHUB_TOKEN := $(GITHUB_TOKEN)

SRCS := $(shell find . -type f -name '*.go')
LDFLAGS := -ldflags="-s -w -X \"main.version=$(VERSION)\" -X \"main.revision=$(REVISION)\""
DIST_DIRS := find * -type d -exec

.PHONY: test
test:
go test ./...
BIN := sqls
ifeq ($(OS),Windows_NT)
BIN := $(BIN).exe
endif
VERSION := $$(make -s show-version)
CURRENT_REVISION := $(shell git rev-parse --short HEAD)
BUILD_LDFLAGS := "-s -w -X main.revision=$(CURRENT_REVISION)"
GOOS := $(shell go env GOOS)
GOBIN ?= $(shell go env GOPATH)/bin
export GO111MODULE=on

.PHONY: all
all: clean build

.PHONY: build
build: $(SRCS)
go build $(LDFLAGS) ./...
build:
go build -ldflags=$(BUILD_LDFLAGS) -o $(BIN) .

.PHONY: release
release:
go build -ldflags=$(BUILD_LDFLAGS) -o $(BIN) .
zip -r sqls-$(GOOS)-$(VERSION).zip $(BIN)

.PHONY: install
install: $(SRCS)
go install $(LDFLAGS) ./...

.PHONY: lint
lint: $(SRCS)
golangci-lint run

.PHONY: coverage
coverage:
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out

.PHONY: stringer
stringer:
stringer -type Kind ./token/kind.go

.PHONY: snapshot
snapshot: $(SRCS)
docker run --rm --privileged \
-v ${PWD}:/go/src/github.com/lighttiger2505/sqls \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/github.com/lighttiger2505/sqls \
mailchain/goreleaser-xcgo --snapshot --rm-dist

.PHONY: publish
publish: $(SRCS)
docker run --rm --privileged \
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
-v ${PWD}:/go/src/github.com/lighttiger2505/sqls \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/github.com/lighttiger2505/sqls \
mailchain/goreleaser-xcgo --rm-dist
install:
go install -ldflags=$(BUILD_LDFLAGS) .

.PHONY: show-version
show-version: $(GOBIN)/gobump
gobump show -r .

$(GOBIN)/gobump:
go install github.com/x-motemen/gobump/cmd/gobump@latest

.PHONY: test
test: build
go test -v ./...

.PHONY: clean
clean:
go clean

.PHONY: bump
bump: $(GOBIN)/gobump
ifneq ($(shell git status --porcelain),)
$(error git workspace is dirty)
endif
ifneq ($(shell git rev-parse --abbrev-ref HEAD),master)
$(error current branch is not master)
endif
@gobump up -w .
git commit -am "bump up version to $(VERSION)"
git tag "v$(VERSION)"
git push origin master
git push origin "refs/tags/v$(VERSION)"
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# sqls

![test](https://github.com/lighttiger2505/sqls/workflows/test/badge.svg)
![test](https://github.com/sqls-server/sqls/workflows/test/badge.svg)

An implementation of the Language Server Protocol for SQL.

Expand Down Expand Up @@ -35,10 +35,15 @@ sqls aims to provide advanced intelligence for you to edit sql in your own edito
- DDL(Data Definition Language)
- [ ] CREATE TABLE
- [ ] ALTER TABLE

#### Join completion
If the tables are connected with a foreign key sqls can complete ```JOIN``` statements

![join_completion](imgs/sqls-fk_joins.gif)

#### CodeAction

![code_actions](https://github.com/lighttiger2505/sqls.vim/blob/master/imgs/sqls_vim_demo.gif)
![code_actions](https://github.com/sqls-server/sqls.vim/blob/master/imgs/sqls_vim_demo.gif)

- [x] Execute SQL
- [ ] Explain SQL
Expand All @@ -60,14 +65,15 @@ sqls aims to provide advanced intelligence for you to edit sql in your own edito
## Installation

```shell
go get github.com/lighttiger2505/sqls
go install github.com/sqls-server/sqls@latest
```

## Editor Plugins

- [sqls.vim](https://github.com/lighttiger2505/sqls.vim)
- [sqls.vim](https://github.com/sqls-server/sqls.vim)
- [vscode-sqls](https://github.com/lighttiger2505/vscode-sqls)
- [sqls.nvim](https://github.com/nanotee/sqls.nvim)
- [Emacs LSP mode](https://emacs-lsp.github.io/lsp-mode/page/lsp-sqls/)

## DB Configuration

Expand Down Expand Up @@ -117,7 +123,7 @@ connections:
port: 22
user: sshuser
passPhrase: ssspass
privateKey: /home/lighttiger2505/.ssh/id_rsa
privateKey: /home/sqls-server/.ssh/id_rsa
```
### Workspace configuration Sample
Expand Down Expand Up @@ -257,8 +263,8 @@ See also.
## Contributors

This project exists thanks to all the people who contribute.
<a href="https://github.com/lighttiger2505/sqls/graphs/contributors">
<img src="https://contrib.rocks/image?repo=lighttiger2505/sqls" />
<a href="https://github.com/sqls-server/sqls/graphs/contributors">
<img src="https://contrib.rocks/image?repo=sqls-server/sqls" />
</a>

## Inspired
Expand Down
Loading

0 comments on commit b25c184

Please sign in to comment.