Skip to content

Commit 96ac921

Browse files
authored
Merge pull request #1 from LinuxSuRen/chore/import
from LinuxSuRen/chore/import-from-atest
2 parents fca7301 + 5f8f1f2 commit 96ac921

File tree

18 files changed

+1942
-0
lines changed

18 files changed

+1942
-0
lines changed

.github/release-drafter.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Configuration for Release Drafter: https://github.com/toolmantim/release-drafter
2+
name-template: 'v$NEXT_PATCH_VERSION 🌈'
3+
tag-template: 'v$NEXT_PATCH_VERSION'
4+
version-template: $MAJOR.$MINOR.$PATCH
5+
# Emoji reference: https://gitmoji.carloscuesta.me/
6+
categories:
7+
- title: '🚀 Features'
8+
labels:
9+
- 'feature'
10+
- 'enhancement'
11+
- 'kind/feature'
12+
- title: '🐛 Bug Fixes'
13+
labels:
14+
- 'fix'
15+
- 'bugfix'
16+
- 'bug'
17+
- 'regression'
18+
- 'kind/bug'
19+
- title: 📝 Documentation updates
20+
labels:
21+
- documentation
22+
- 'kind/doc'
23+
- title: 👻 Maintenance
24+
labels:
25+
- chore
26+
- dependencies
27+
- 'kind/chore'
28+
- 'kind/dep'
29+
- title: 🚦 Tests
30+
labels:
31+
- test
32+
- tests
33+
exclude-labels:
34+
- reverted
35+
- no-changelog
36+
- skip-changelog
37+
- invalid
38+
autolabeler:
39+
- label: 'documentation'
40+
title:
41+
- '/docs:/i'
42+
- label: 'chore'
43+
title:
44+
- '/chore:/i'
45+
- label: 'bug'
46+
title:
47+
- '/fix:/i'
48+
- label: 'enhancement'
49+
title:
50+
- '/feat:/i'
51+
change-template: '* $TITLE (#$NUMBER) @$AUTHOR'
52+
template: |
53+
## What’s Changed
54+
55+
$CHANGES
56+
57+
## Thanks to
58+
$CONTRIBUTORS

.github/workflows/build.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build
2+
3+
on:
4+
- pull_request
5+
6+
jobs:
7+
Test:
8+
runs-on: ubuntu-20.04
9+
steps:
10+
- name: Set up Go
11+
uses: actions/setup-go@v3
12+
with:
13+
go-version: 1.20.x
14+
- uses: actions/[email protected]
15+
- name: Unit Test
16+
run: |
17+
make test
18+
19+
Build:
20+
runs-on: ubuntu-20.04
21+
steps:
22+
- name: Set up Go
23+
uses: actions/setup-go@v3
24+
with:
25+
go-version: 1.20.x
26+
- uses: actions/[email protected]
27+
- name: Run GoReleaser
28+
uses: goreleaser/[email protected]
29+
with:
30+
github_token: ${{ secrets.GH_PUBLISH_SECRETS }}
31+
version: v1.14.0
32+
args: release --skip-publish --rm-dist --snapshot
33+
34+
BuildImage:
35+
runs-on: ubuntu-20.04
36+
steps:
37+
- name: Set up Go
38+
uses: actions/setup-go@v3
39+
with:
40+
go-version: 1.20.x
41+
- uses: actions/[email protected]
42+
- name: Image
43+
run: make build-image
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
UpdateReleaseDraft:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- uses: release-drafter/release-drafter@v5
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GH_PUBLISH_SECRETS }}

.github/workflows/release.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
branches:
8+
- master
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
REGISTRY_DOCKERHUB: docker.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
goreleaser:
17+
runs-on: ubuntu-20.04
18+
steps:
19+
- name: Checkout
20+
uses: actions/[email protected]
21+
- name: Unshallow
22+
run: git fetch --prune --unshallow
23+
- name: Set up Go
24+
uses: actions/setup-go@v3
25+
with:
26+
go-version: 1.20.x
27+
- name: Run GoReleaser
28+
uses: goreleaser/[email protected]
29+
with:
30+
version: latest
31+
args: release --rm-dist
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GH_PUBLISH_SECRETS }}
34+
35+
image:
36+
runs-on: ubuntu-20.04
37+
steps:
38+
- name: Checkout
39+
uses: actions/[email protected]
40+
- name: Setup Docker buildx
41+
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
42+
- name: Log into registry ${{ env.REGISTRY }}
43+
if: github.event_name != 'pull_request'
44+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
45+
with:
46+
registry: ${{ env.REGISTRY }}
47+
username: ${{ github.actor }}
48+
password: ${{ secrets.GH_PUBLISH_SECRETS }}
49+
- name: Extract Docker metadata
50+
id: meta
51+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
52+
with:
53+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
54+
- name: Build and push Docker image
55+
id: build-and-push
56+
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
57+
with:
58+
context: .
59+
push: ${{ github.event_name != 'pull_request' }}
60+
tags: ${{ steps.meta.outputs.tags }}
61+
labels: ${{ steps.meta.outputs.labels }}
62+
platforms: linux/amd64,linux/arm64
63+
cache-from: type=gha
64+
cache-to: type=gha,mode=max
65+
66+
image-dockerhub:
67+
runs-on: ubuntu-20.04
68+
steps:
69+
- name: Checkout
70+
uses: actions/[email protected]
71+
- name: Setup Docker buildx
72+
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
73+
- name: Log into registry ${{ env.REGISTRY_DOCKERHUB }}
74+
if: github.event_name != 'pull_request'
75+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
76+
with:
77+
registry: ${{ env.REGISTRY_DOCKERHUB }}
78+
username: linuxsuren
79+
password: ${{ secrets.DOCKER_HUB_PUBLISH_SECRETS }}
80+
- name: Extract Docker metadata
81+
id: meta
82+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
83+
with:
84+
images: ${{ env.REGISTRY_DOCKERHUB }}/${{ env.IMAGE_NAME }}
85+
- name: Build and push Docker image
86+
id: build-and-push
87+
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
88+
with:
89+
context: .
90+
push: ${{ github.event_name != 'pull_request' }}
91+
tags: ${{ steps.meta.outputs.tags }}
92+
labels: ${{ steps.meta.outputs.labels }}
93+
platforms: linux/amd64,linux/arm64
94+
cache-from: type=gha
95+
cache-to: type=gha,mode=max

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
coverage.out
2+
bin/

.goreleaser.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
before:
4+
hooks:
5+
# You may remove this if you don't use go modules.
6+
- go mod tidy
7+
builds:
8+
- env:
9+
- CGO_ENABLED=0
10+
id: atest-store-git
11+
binary: atest-store-git
12+
goos:
13+
- linux
14+
- windows
15+
- darwin
16+
ldflags:
17+
- -w
18+
- -s
19+
archives:
20+
- name_template: "{{ .Binary }}-{{ .Os }}-{{ .Arch }}"
21+
builds:
22+
- atest-store-git
23+
format_overrides:
24+
- goos: windows
25+
format: zip
26+
files:
27+
- README.md
28+
checksum:
29+
name_template: 'checksums.txt'
30+
snapshot:
31+
name_template: "{{ incpatch .Version }}-next"
32+
changelog:
33+
sort: asc
34+
filters:
35+
exclude:
36+
- '^docs:'
37+
- '^test:'

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM golang:1.20 AS builder
2+
3+
LABEL org.opencontainers.image.source=https://github.com/LinuxSuRen/atest-ext-store-git
4+
LABEL org.opencontainers.image.description="Git Store Extension of the API Testing."
5+
6+
ARG VERSION
7+
ARG GOPROXY
8+
WORKDIR /workspace
9+
COPY cmd/ cmd/
10+
COPY pkg/ pkg/
11+
COPY go.mod go.mod
12+
COPY go.sum go.sum
13+
COPY main.go main.go
14+
COPY README.md README.md
15+
16+
RUN GOPROXY=${GOPROXY} go mod download
17+
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s" -o atest-store-git .
18+
19+
FROM alpine:3.12
20+
21+
COPY --from=builder /workspace/atest-store-git /usr/local/bin/atest-store-git
22+
23+
CMD [ "atest-store-git" ]

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
fmt:
2+
go mod tidy
3+
go fmt ./...
4+
build:
5+
go build -o bin/atest-store-orm .
6+
test:
7+
go test ./... -cover -v -coverprofile=coverage.out
8+
go tool cover -func=coverage.out
9+
build-image:
10+
docker build .
11+
hd:
12+
curl https://linuxsuren.github.io/tools/install.sh|bash
13+
init-env: hd
14+
hd i cli/cli
15+
gh extension install linuxsuren/gh-dev

cmd/root.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
*
3+
MIT License
4+
5+
Copyright (c) 2023 API Testing Authors.
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.
24+
*/
25+
package cmd
26+
27+
import (
28+
ext "github.com/linuxsuren/api-testing/pkg/extension"
29+
"github.com/linuxsuren/atest-ext-store-orm/pkg"
30+
"github.com/spf13/cobra"
31+
)
32+
33+
func NewRootCommand() (c *cobra.Command) {
34+
opt := &option{
35+
Extension: ext.NewExtension("orm", "store", 7071),
36+
}
37+
c = &cobra.Command{
38+
Use: opt.GetFullName(),
39+
Short: "Storage extension of api-testing",
40+
RunE: opt.runE,
41+
}
42+
opt.AddFlags(c.Flags())
43+
return
44+
}
45+
46+
func (o *option) runE(c *cobra.Command, args []string) (err error) {
47+
remoteServer := pkg.NewRemoteServer()
48+
err = ext.CreateRunner(o.Extension, c, remoteServer)
49+
return
50+
}
51+
52+
type option struct {
53+
*ext.Extension
54+
}

0 commit comments

Comments
 (0)