Skip to content

Commit 243f352

Browse files
committed
Added GitHub Actions
1 parent 2b2bc77 commit 243f352

File tree

16 files changed

+240
-9
lines changed

16 files changed

+240
-9
lines changed

.github/workflows/pyworker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
runs-on: ubuntu-latest
5555
defaults:
5656
run:
57-
working-directory: ./worker
57+
working-directory: ./pyworker
5858
steps:
5959
- name: Git Checkout
6060
uses: actions/checkout@v4

.github/workflows/worker.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Smriti Worker CI
2+
on:
3+
push:
4+
branches:
5+
- master
6+
paths:
7+
- worker/**
8+
- .github/workflows/worker.yaml
9+
pull_request:
10+
branches:
11+
- master
12+
paths:
13+
- worker/**
14+
- .github/workflows/worker.yaml
15+
release:
16+
types: [published]
17+
jobs:
18+
ci:
19+
name: Integration Check
20+
runs-on: ubuntu-latest
21+
defaults:
22+
run:
23+
working-directory: ./worker
24+
steps:
25+
- name: Git Checkout
26+
uses: actions/checkout@v4
27+
- name: Setup cmake
28+
uses: jwlawson/actions-setup-cmake@v2
29+
with:
30+
cmake-version: '3.30.x'
31+
- name: CMake Version
32+
run: cmake --version
33+
- name: Install Dependencies
34+
run: |
35+
sudo apt install libspdlog-dev
36+
- name: Install Lint
37+
run: |
38+
pip install cpplint
39+
sudo apt install -y clang-tidy clang-format
40+
cpplint --version
41+
clang-tidy --version
42+
clang-format --version
43+
- name: Run Lint
44+
run: make lint
45+
- name: Run Build
46+
run: make build
47+
- name: Run Test & Cover
48+
run: |
49+
make test-install
50+
make cover
51+
- name: Publish Coverage
52+
uses: codecov/codecov-action@v5
53+
with:
54+
token: ${{ secrets.CODECOV_TOKEN }}
55+
flags: worker
56+
files: worker/coverage.xml
57+
publish:
58+
if: ${{ (github.event_name == 'release' && github.event.action == 'published') || github.ref == 'refs/heads/master' }}
59+
needs: ci
60+
name: Publish Docker Image
61+
runs-on: ubuntu-latest
62+
defaults:
63+
run:
64+
working-directory: ./worker
65+
steps:
66+
- name: Git Checkout
67+
uses: actions/checkout@v4
68+
- name: Setup QEMU
69+
uses: docker/setup-qemu-action@v3
70+
- name: Setup Docker Buildx
71+
uses: docker/setup-buildx-action@v3
72+
- name: Login to Docker Hub
73+
uses: docker/login-action@v3
74+
with:
75+
username: ${{ secrets.DOCKER_USER }}
76+
password: ${{ secrets.DOCKER_PASSWORD }}
77+
- name: Docker Build and Push
78+
uses: docker/build-push-action@v6
79+
with:
80+
context: worker
81+
file: ./worker/Dockerfile
82+
push: true
83+
platforms: linux/amd64,linux/arm64/v8
84+
build-args: |
85+
GITSHA=${{ github.sha }}
86+
VERSION=${ github.ref_name }}
87+
tags: smritihq/worker:${{ github.ref_name }}

.gitmodules

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[submodule "worker/third_party/spdlog"]
2+
path = worker/third_party/spdlog
3+
url = https://github.com/gabime/spdlog.git
4+
[submodule "worker/third_party/googletest"]
5+
path = worker/third_party/googletest
6+
url = https://github.com/google/googletest.git
7+
[submodule "worker/third_party/benchmark"]
8+
path = worker/third_party/benchmark
9+
url = https://github.com/google/benchmark.git

Makefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
setup: setup-api setup-worker setup-docs setup-tests
1+
setup: setup-api setup-pyworker setup-docs setup-tests
2+
23
setup-api:
34
@cd api; \
45
echo "[setup-api]: Verifying go modules..."; \
@@ -7,32 +8,49 @@ setup-api:
78
make lint; \
89
echo "[setup-api]: Running unit tests..."; \
910
make test
11+
1012
setup-worker:
1113
@cd worker; \
12-
echo "[setup-worker]: Installing requirements"; \
14+
echo "[setup-worker]: Installing dependencies"; \
1315
make install; \
1416
make test-install; \
1517
echo "[setup-worker]: Running linter..."; \
1618
make lint; \
1719
echo "[setup-worker]: Running unit tests..."; \
1820
make test
21+
22+
setup-pyworker:
23+
@cd pyworker; \
24+
echo "[setup-pyworker]: Installing requirements"; \
25+
make install; \
26+
make test-install; \
27+
echo "[setup-pyworker]: Running linter..."; \
28+
make lint; \
29+
echo "[setup-pyworker]: Running unit tests..."; \
30+
make test
31+
1932
setup-docs:
2033
@cd docs; \
2134
echo "[setup-docs]: Installing dependencies"; \
2235
npm install
36+
2337
setup-tests:
2438
@cd tests; \
2539
echo "[setup-tests]: Installing dependencies"; \
2640
make setup
41+
2742
setup-models:
2843
@echo "Setting up models..."; \
2944
python3 scripts/setup_models.py
45+
3046
start: setup-models
3147
@echo "Starting smriti services..."; \
3248
docker compose up -d
49+
3350
stop:
3451
@echo "Stopping smriti services..."; \
3552
docker compose down
53+
3654
gen-test-data: start
3755
@echo "Generating test data"; \
3856
python3 scripts/generate_test_data.py

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Smarter Home for all your Photos and Videos
44

55
[![API](https://github.com/prabhuomkar/smriti/actions/workflows/api.yaml/badge.svg)](https://github.com/prabhuomkar/smriti/actions/workflows/api.yaml)
6-
[![Worker](https://github.com/prabhuomkar/smriti/actions/workflows/worker.yaml/badge.svg)](https://github.com/prabhuomkar/smriti/actions/workflows/worker.yaml)
6+
[![Worker](https://github.com/prabhuomkar/smriti/actions/workflows/pyworker.yaml/badge.svg)](https://github.com/prabhuomkar/smriti/actions/workflows/worker.yaml)
77
[![Coverage](https://codecov.io/gh/prabhuomkar/smriti/branch/master/graph/badge.svg?token=D32LxO5fIj)](https://codecov.io/gh/prabhuomkar/smriti)
88
[![License](https://img.shields.io/github/license/prabhuomkar/smriti)](LICENSE)
99
[![Twitter](https://img.shields.io/twitter/follow/smritihq?style=social)](https://twitter.com/smritihq)

api/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1+
.PHONY: build
12
build:
23
@go build -o api --ldflags="-X 'api/internal/models.DefaultVersion=$(VERSION)' -X 'api/internal/models.DefaultGitSHA=$(shell git rev-parse HEAD)'"
34

5+
.PHONY: run
46
run: build
57
@./api
68

9+
.PHONY: test
710
test:
811
@go test ./...
912

13+
.PHONY: cover
1014
cover:
1115
@go test $$(go list ./... | grep -v api/pkg/services) -race -coverprofile=coverage.txt -covermode=atomic ./...
1216
@go tool cover -func coverage.txt | grep total
1317

18+
.PHONY: cover-html
1419
cover-html: cover
1520
@go tool cover -html coverage.txt -o coverage.html
1621

22+
.PHONY: lint
1723
lint:
1824
@LOG_LEVEL=error golangci-lint run ./...
1925

26+
.PHONY: proto
2027
proto:
2128
@protoc --proto_path=../protos ../protos/*.proto --go_out=pkg/services --go-grpc_out=pkg/services --experimental_allow_proto3_optional

docs/docs/dev-guide/environment.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The following guide will help you in setting up the development environment to w
55
Make sure, before you start any development, following things are installed and available on your system of choice:
66
- [Git](https://git-scm.com/)
77
- [Docker](https://www.docker.com/)
8+
- [Protocol Buffers](https://protobuf.dev/installation/)
89
- [Common Sense](https://en.wikipedia.org/wiki/Common_sense)
910

1011
## Getting Codebase
@@ -24,11 +25,20 @@ make setup-api
2425
```
2526

2627
### Worker
28+
- Install [CMake 3.30](https://cmake.org/download/) or above
29+
- Install [cpplint 2.0.0](https://pypi.org/project/cpplint/) or above
30+
- Install [clang-tidy 19.1.7](https://clang.llvm.org/extra/clang-tidy/) or above
31+
- Install [clang-format 19.1.7](https://clang.llvm.org/docs/ClangFormat.html) or above
32+
```
33+
make setup-worker
34+
```
35+
36+
### PyWorker
2737
- Install [Python 3.12](https://www.python.org/downloads/) or above
2838
- Install [pylint 3.3.4](https://pypi.org/project/pylint/) or above
2939
- Run the following command to finish your Worker setup
3040
```
31-
make setup-worker
41+
make setup-pyworker
3242
```
3343

3444
### Docs

infra/deployments/docker-swarm/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ services:
2020
volumes:
2121
- ./storage:/storage:rw
2222
worker:
23-
image: smritihq/worker:master
23+
image: smritihq/pyworker:master
2424
ports:
2525
- '15002:15002'
2626
environment:

pyworker/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Smriti Worker
1+
# Smriti PyWorker
22

3-
Setup Guide is available [here](https://smriti.omkar.xyz/docs/dev-guide/environment#worker).
3+
Setup Guide is available [here](https://smriti.omkar.xyz/docs/dev-guide/environment#pyworker).

worker/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ execute_process(
1313
if(NOT GIT_SHA)
1414
set(GIT_SHA "-")
1515
endif()
16-
find_package(spdlog REQUIRED)
16+
add_subdirectory(third_party/spdlog)
1717
add_executable(worker
1818
src/main.cc
1919
src/metadata.cc

0 commit comments

Comments
 (0)