mirror of
https://github.com/qdm12/ddns-updater.git
synced 2026-04-05 00:43:44 -04:00
chore(ci): add mocks check step
This commit is contained in:
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
@@ -47,6 +47,9 @@ jobs:
|
|||||||
- name: Linting
|
- name: Linting
|
||||||
run: docker build --target lint .
|
run: docker build --target lint .
|
||||||
|
|
||||||
|
- name: Mocks check
|
||||||
|
run: docker build --target mocks .
|
||||||
|
|
||||||
- name: Build test image
|
- name: Build test image
|
||||||
run: docker build --target test -t test-container .
|
run: docker build --target test -t test-container .
|
||||||
|
|
||||||
|
|||||||
18
Dockerfile
18
Dockerfile
@@ -3,16 +3,20 @@ ARG ALPINE_VERSION=3.18
|
|||||||
ARG GO_VERSION=1.20
|
ARG GO_VERSION=1.20
|
||||||
ARG XCPUTRANSLATE_VERSION=v0.6.0
|
ARG XCPUTRANSLATE_VERSION=v0.6.0
|
||||||
ARG GOLANGCI_LINT_VERSION=v1.52.2
|
ARG GOLANGCI_LINT_VERSION=v1.52.2
|
||||||
|
ARG MOCKGEN_VERSION=v1.6.0
|
||||||
|
|
||||||
FROM --platform=${BUILDPLATFORM} qmcgaw/xcputranslate:${XCPUTRANSLATE_VERSION} AS xcputranslate
|
FROM --platform=${BUILDPLATFORM} qmcgaw/xcputranslate:${XCPUTRANSLATE_VERSION} AS xcputranslate
|
||||||
FROM --platform=${BUILDPLATFORM} qmcgaw/binpot:golangci-lint-${GOLANGCI_LINT_VERSION} AS golangci-lint
|
FROM --platform=${BUILDPLATFORM} qmcgaw/binpot:golangci-lint-${GOLANGCI_LINT_VERSION} AS golangci-lint
|
||||||
|
FROM --platform=${BUILDPLATFORM} qmcgaw/binpot:mockgen-${MOCKGEN_VERSION} AS mockgen
|
||||||
|
|
||||||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
|
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
|
||||||
WORKDIR /tmp/gobuild
|
WORKDIR /tmp/gobuild
|
||||||
ENV CGO_ENABLED=0
|
ENV CGO_ENABLED=0
|
||||||
RUN apk --update add git g++
|
# Note: findutils needed to have xargs support `-d` flag for mocks stage.
|
||||||
|
RUN apk --update add git g++ findutils
|
||||||
COPY --from=xcputranslate /xcputranslate /usr/local/bin/xcputranslate
|
COPY --from=xcputranslate /xcputranslate /usr/local/bin/xcputranslate
|
||||||
COPY --from=golangci-lint /bin /go/bin/golangci-lint
|
COPY --from=golangci-lint /bin /go/bin/golangci-lint
|
||||||
|
COPY --from=mockgen /bin /go/bin/mockgen
|
||||||
# Copy repository code and install Go dependencies
|
# Copy repository code and install Go dependencies
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
@@ -31,6 +35,18 @@ FROM --platform=$BUILDPLATFORM base AS lint
|
|||||||
COPY .golangci.yml ./
|
COPY .golangci.yml ./
|
||||||
RUN golangci-lint run --timeout=10m
|
RUN golangci-lint run --timeout=10m
|
||||||
|
|
||||||
|
FROM --platform=${BUILDPLATFORM} base AS mocks
|
||||||
|
RUN git init && \
|
||||||
|
git config user.email ci@localhost && \
|
||||||
|
git config user.name ci && \
|
||||||
|
git config core.fileMode false && \
|
||||||
|
git add -A && \
|
||||||
|
git commit -m "snapshot" && \
|
||||||
|
grep -lr -E '^// Code generated by MockGen\. DO NOT EDIT\.$' . | xargs -r -d '\n' rm && \
|
||||||
|
go generate -run "mockgen" ./... && \
|
||||||
|
git diff --exit-code && \
|
||||||
|
rm -rf .git/
|
||||||
|
|
||||||
FROM --platform=$BUILDPLATFORM base AS build
|
FROM --platform=$BUILDPLATFORM base AS build
|
||||||
ARG VERSION=unknown
|
ARG VERSION=unknown
|
||||||
ARG BUILD_DATE="an unknown date"
|
ARG BUILD_DATE="an unknown date"
|
||||||
|
|||||||
@@ -6,36 +6,37 @@ package mock_dns
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
gomock "github.com/golang/mock/gomock"
|
|
||||||
dns "github.com/miekg/dns"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
time "time"
|
time "time"
|
||||||
|
|
||||||
|
gomock "github.com/golang/mock/gomock"
|
||||||
|
dns "github.com/miekg/dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockClient is a mock of Client interface
|
// MockClient is a mock of Client interface.
|
||||||
type MockClient struct {
|
type MockClient struct {
|
||||||
ctrl *gomock.Controller
|
ctrl *gomock.Controller
|
||||||
recorder *MockClientMockRecorder
|
recorder *MockClientMockRecorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// MockClientMockRecorder is the mock recorder for MockClient
|
// MockClientMockRecorder is the mock recorder for MockClient.
|
||||||
type MockClientMockRecorder struct {
|
type MockClientMockRecorder struct {
|
||||||
mock *MockClient
|
mock *MockClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMockClient creates a new mock instance
|
// NewMockClient creates a new mock instance.
|
||||||
func NewMockClient(ctrl *gomock.Controller) *MockClient {
|
func NewMockClient(ctrl *gomock.Controller) *MockClient {
|
||||||
mock := &MockClient{ctrl: ctrl}
|
mock := &MockClient{ctrl: ctrl}
|
||||||
mock.recorder = &MockClientMockRecorder{mock}
|
mock.recorder = &MockClientMockRecorder{mock}
|
||||||
return mock
|
return mock
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXPECT returns an object that allows the caller to indicate expected use
|
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||||
func (m *MockClient) EXPECT() *MockClientMockRecorder {
|
func (m *MockClient) EXPECT() *MockClientMockRecorder {
|
||||||
return m.recorder
|
return m.recorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExchangeContext mocks base method
|
// ExchangeContext mocks base method.
|
||||||
func (m *MockClient) ExchangeContext(arg0 context.Context, arg1 *dns.Msg, arg2 string) (*dns.Msg, time.Duration, error) {
|
func (m *MockClient) ExchangeContext(arg0 context.Context, arg1 *dns.Msg, arg2 string) (*dns.Msg, time.Duration, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "ExchangeContext", arg0, arg1, arg2)
|
ret := m.ctrl.Call(m, "ExchangeContext", arg0, arg1, arg2)
|
||||||
@@ -45,7 +46,7 @@ func (m *MockClient) ExchangeContext(arg0 context.Context, arg1 *dns.Msg, arg2 s
|
|||||||
return ret0, ret1, ret2
|
return ret0, ret1, ret2
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExchangeContext indicates an expected call of ExchangeContext
|
// ExchangeContext indicates an expected call of ExchangeContext.
|
||||||
func (mr *MockClientMockRecorder) ExchangeContext(arg0, arg1, arg2 interface{}) *gomock.Call {
|
func (mr *MockClientMockRecorder) ExchangeContext(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExchangeContext", reflect.TypeOf((*MockClient)(nil).ExchangeContext), arg0, arg1, arg2)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExchangeContext", reflect.TypeOf((*MockClient)(nil).ExchangeContext), arg0, arg1, arg2)
|
||||||
|
|||||||
Reference in New Issue
Block a user