Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

chore: refactor automation pt.2 #150

Merged
merged 6 commits into from
Jun 17, 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
8 changes: 8 additions & 0 deletions .github/workflows/build-and-publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ jobs:
- name: Build argo-watcher binary
run: make build VERSION=${{ github.ref_name }}

- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: '17'

- name: Build argo-watcher UI
run: make build-ui

- name: Build and publish argo-watcher image
uses: docker/build-push-action@v4
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/run-tests-and-sonar-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
- name: Generate swagger docs
run: make docs

- name: Install mockgen
run: go install github.com/golang/mock/mockgen@v1.6.0

- name: Run tests
env:
DB_HOST: localhost
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ bin/
# code coverage files
**/coverage.*

# docs that are generated automatically
# dynamicly generated files
cmd/argo-watcher/docs
cmd/argo-watcher/mock
22 changes: 1 addition & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
#######################
# Frontend build
#######################
FROM node:17.7-alpine3.15 as builder-frontend

WORKDIR /app

COPY web/package.json .
COPY web/package-lock.json .

RUN npm ci --silent
RUN npm install react-scripts --silent

COPY web/ .

RUN npm run build

#######################
# Final image
#######################
FROM alpine:3.18

COPY ./bin/argo-watcher /argo-watcher
COPY --from=builder-frontend /app/build /static
COPY ./web/build /static

RUN addgroup -S argo-watcher && adduser -S argo-watcher -G argo-watcher
RUN apk add --no-cache ca-certificates
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ help: ## Print this help
@grep -E '^[a-z.A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: test
test: ## Run tests
@ARGO_TIMEOUT=1 go test -v ./... -count=1 -coverprofile coverage.out `go list ./... | egrep -v '(test|mocks)'`
test: mocks ## Run tests
@ARGO_TIMEOUT=1 go test -v ./... -count=1 -coverprofile coverage.out `go list ./... | egrep -v '(test|mock)'`

.PHONY: ensure-dirs
ensure-dirs:
Expand All @@ -24,13 +24,20 @@ build: ensure-dirs docs ## Build the binaries
@CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=${VERSION}" -o bin/argo-watcher ./cmd/argo-watcher
@echo "===> Done"

.PHONY: build-ui
build-ui: ## Build the UI
@echo "===> Building UI"
@cd web && npm ci --silent && npm install react-scripts --silent && npm run build
@echo "===> Done"

.PHONY: docs
docs: ## Generate swagger docs
@echo "===> Generating swagger docs"
@cd cmd/argo-watcher && swag init --parseDependency --parseInternal

.PHONY: mocks
mocks:
@echo "===> Generating mocks"
# generate API mock
@mockgen --source=cmd/argo-watcher/argo_api.go --destination=cmd/argo-watcher/mock/argo_api.go --package=mock
# generate State mock
Expand Down
4 changes: 2 additions & 2 deletions cmd/argo-watcher/argo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestArgoCheck(t *testing.T) {

// mock calls
state.EXPECT().Check().Return(true)
api.EXPECT().GetUserInfo().Return(nil, fmt.Errorf("Unexpected login error"))
api.EXPECT().GetUserInfo().Return(nil, fmt.Errorf("unexpected login error"))
metrics.EXPECT().SetArgoUnavailable(true)

// argo manager
Expand All @@ -127,7 +127,7 @@ func TestArgoAddTask(t *testing.T) {

// mock calls
state.EXPECT().Check().Return(true)
api.EXPECT().GetUserInfo().Return(nil, fmt.Errorf("Unexpected login error"))
api.EXPECT().GetUserInfo().Return(nil, fmt.Errorf("unexpected login error"))
metrics.EXPECT().SetArgoUnavailable(true)

// argo manager
Expand Down
80 changes: 0 additions & 80 deletions cmd/argo-watcher/mock/argo_api.go

This file was deleted.

82 changes: 0 additions & 82 deletions cmd/argo-watcher/mock/metrics.go

This file was deleted.

1 change: 0 additions & 1 deletion cmd/argo-watcher/mock/mock.go

This file was deleted.

Loading