Skip to content

Commit 388da73

Browse files
committed
publish image
1 parent 23b4d33 commit 388da73

File tree

6 files changed

+55
-22
lines changed

6 files changed

+55
-22
lines changed

.github/workflows/build.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ jobs:
3636
github_token: ${{ secrets.GH_PUBLISH_SECRETS }}
3737
version: v1.14.0
3838
args: release --skip-publish --rm-dist --snapshot
39+
- name: Image
40+
run: make build-image

.github/workflows/release.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
tags:
66
- '*'
77

8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
812
jobs:
913
goreleaser:
1014
runs-on: ubuntu-20.04
@@ -24,3 +28,33 @@ jobs:
2428
args: release --rm-dist
2529
env:
2630
GITHUB_TOKEN: ${{ secrets.GH_PUBLISH_SECRETS }}
31+
32+
image:
33+
runs-on: ubuntu-20.04
34+
steps:
35+
- name: Checkout
36+
uses: actions/[email protected]
37+
- name: Setup Docker buildx
38+
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
39+
- name: Log into registry ${{ env.REGISTRY }}
40+
if: github.event_name != 'pull_request'
41+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
42+
with:
43+
registry: ${{ env.REGISTRY }}
44+
username: ${{ github.actor }}
45+
password: ${{ secrets.GH_PUBLISH_SECRETS }}
46+
- name: Extract Docker metadata
47+
id: meta
48+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
49+
with:
50+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
51+
- name: Build and push Docker image
52+
id: build-and-push
53+
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
54+
with:
55+
context: .
56+
push: ${{ github.event_name != 'pull_request' }}
57+
tags: ${{ steps.meta.outputs.tags }}
58+
labels: ${{ steps.meta.outputs.labels }}
59+
cache-from: type=gha
60+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@ LABEL "maintainer"="Rick <[email protected]>"
2020

2121
LABEL "Name"="API testing"
2222

23-
ENV LC_ALL C.UTF-8
24-
ENV LANG en_US.UTF-8
25-
ENV LANGUAGE en_US.UTF-8
26-
27-
RUN apk add --no-cache \
28-
git \
29-
openssh-client \
30-
libc6-compat \
31-
libstdc++
32-
33-
COPY entrypoint.sh /entrypoint.sh
3423
COPY --from=builder /workspace/atest /usr/bin/atest
35-
COPY --from=hd /usr/local/bin/hd /usr/local/bin/hd
36-
RUN hd i kubernetes-sigs/kubectl && \
37-
hd i k3d
3824

39-
ENTRYPOINT ["/entrypoint.sh"]
25+
ENTRYPOINT [atest, server]

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ build:
44
go build -o bin/atest main.go
55
goreleaser:
66
goreleaser build --rm-dist --snapshot
7+
build-image:
8+
docker build -t ghcr.io/linuxsuren/api-testing:dev .
79
copy: build
810
sudo cp bin/atest /usr/local/bin/
911
test:

entrypoint.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

pkg/server/remote_server.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import (
55
"bytes"
66
context "context"
77
"fmt"
8+
"strings"
89

10+
"github.com/linuxsuren/api-testing/pkg/render"
911
"github.com/linuxsuren/api-testing/pkg/runner"
1012
"github.com/linuxsuren/api-testing/pkg/testing"
1113
)
@@ -45,12 +47,26 @@ func (s *server) Run(ctx context.Context, task *TestTask) (reply *HelloReply, er
4547
}
4648

4749
dataContext := map[string]interface{}{}
50+
51+
var result string
52+
if result, err = render.Render("base api", suite.API, dataContext); err == nil {
53+
suite.API = result
54+
suite.API = strings.TrimSuffix(suite.API, "/")
55+
} else {
56+
return
57+
}
58+
4859
buf := new(bytes.Buffer)
4960

5061
for _, testCase := range suite.Items {
5162
simpleRunner := runner.NewSimpleTestCaseRunner()
5263
simpleRunner.WithOutputWriter(buf)
5364

65+
// reuse the API prefix
66+
if strings.HasPrefix(testCase.Request.API, "/") {
67+
testCase.Request.API = fmt.Sprintf("%s%s", suite.API, testCase.Request.API)
68+
}
69+
5470
var output interface{}
5571
if output, err = simpleRunner.RunTestCase(&testCase, dataContext, ctx); err == nil {
5672
dataContext[testCase.Name] = output

0 commit comments

Comments
 (0)