Skip to content

Commit d6e741b

Browse files
committed
Added GitHub Actions
1 parent 2b2bc77 commit d6e741b

File tree

11 files changed

+217
-8
lines changed

11 files changed

+217
-8
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: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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: make install
35+
- name: Run Lint
36+
run: make lint
37+
- name: Run Test & Cover
38+
run: |
39+
make test-install
40+
make cover
41+
- name: Publish Coverage
42+
uses: codecov/codecov-action@v5
43+
with:
44+
token: ${{ secrets.CODECOV_TOKEN }}
45+
flags: worker
46+
files: worker/coverage.xml
47+
publish:
48+
if: ${{ (github.event_name == 'release' && github.event.action == 'published') || github.ref == 'refs/heads/master' }}
49+
needs: ci
50+
name: Publish Docker Image
51+
runs-on: ubuntu-latest
52+
defaults:
53+
run:
54+
working-directory: ./worker
55+
steps:
56+
- name: Git Checkout
57+
uses: actions/checkout@v4
58+
- name: Setup QEMU
59+
uses: docker/setup-qemu-action@v3
60+
- name: Setup Docker Buildx
61+
uses: docker/setup-buildx-action@v3
62+
- name: Login to Docker Hub
63+
uses: docker/login-action@v3
64+
with:
65+
username: ${{ secrets.DOCKER_USER }}
66+
password: ${{ secrets.DOCKER_PASSWORD }}
67+
- name: Docker Build and Push
68+
uses: docker/build-push-action@v6
69+
with:
70+
context: worker
71+
file: ./worker/Dockerfile
72+
push: true
73+
platforms: linux/amd64,linux/arm64/v8
74+
build-args: |
75+
GITSHA=${{ github.sha }}
76+
VERSION=${ github.ref_name }}
77+
tags: smritihq/worker:${{ github.ref_name }}

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/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM ubuntu:24.10 AS builder
2+
RUN apt-get update && apt-get install -y \
3+
build-essential \
4+
cmake \
5+
git \
6+
wget \
7+
autoconf \
8+
automake \
9+
libtool \
10+
pkg-config \
11+
curl \
12+
&& rm -rf /var/lib/apt/lists/*
13+
WORKDIR /opt
14+
RUN git clone --recurse-submodules -b v1.71.0 https://github.com/grpc/grpc.git && \
15+
cd grpc && \
16+
mkdir -p cmake/build && cd cmake/build && \
17+
cmake -DgRPC_INSTALL=ON \
18+
-DgRPC_BUILD_TESTS=OFF \
19+
-DCMAKE_INSTALL_PREFIX=/usr/local \
20+
../.. && \
21+
make -j$(nproc) && \
22+
make install
23+
WORKDIR /app
24+
COPY . /app
25+
RUN mkdir -p build && cd build && \
26+
cmake -DCMAKE_PREFIX_PATH=/usr/local .. && \
27+
make -j$(nproc)
28+
29+
FROM gcr.io/distroless/cc
30+
WORKDIR /app
31+
COPY --from=builder /app/build/worker .
32+
EXPOSE 5002
33+
EXPOSE 15002
34+
CMD ["/app/worker"]

worker/Makefile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
GRPC_VERSION ?= v1.71.0
2+
MY_INSTALL_DIR ?= ${HOME}/.local
3+
4+
.PHONY: install
5+
install:
6+
@if [ ! -d "grpc" ]; then \
7+
git clone --recurse-submodules -b ${GRPC_VERSION} --depth 1 --shallow-submodules https://github.com/grpc/grpc; \
8+
else \
9+
echo "grpc already downloaded"; \
10+
cd grpc && git checkout ${GRPC_VERSION}; \
11+
git submodule update --init --recursive; \
12+
fi
13+
@cd grpc && \
14+
mkdir -p cmake/build && \
15+
cd cmake/build && \
16+
cmake -DgRPC_INSTALL=ON \
17+
-DgRPC_BUILD_TESTS=OFF \
18+
-DCMAKE_CXX_STANDARD=17 \
19+
-DCMAKE_INSTALL_PREFIX=${MY_INSTALL_DIR} \
20+
../.. && \
21+
make -j 4 && \
22+
make install && \
23+
cd ../..
24+
@rm -rf grpc
25+
26+
.PHONY: build
27+
build:
28+
@mkdir -p build
29+
@cmake -DCMAKE_PREFIX_PATH=${MY_INSTALL_DIR} . -B build
30+
@cd build && make -j 4
31+
32+
.PHONY: run
33+
run:
34+
@./build/worker
35+
36+
.PHONY: test-install
37+
test-install:
38+
@git submodule update --init --recursive
39+
40+
.PHONY: test
41+
test:
42+
@./build/worker_tests
43+
@./build/worker_benchmarks
44+
45+
.PHONY: cover
46+
cover:
47+
@echo "TODO(omkar)"
48+
49+
.PHONY: cover-html
50+
cover-html: cover
51+
@echo "TODO(omkar)"
52+
53+
.PHONY: lint
54+
lint:
55+
@cpplint --recursive include/ src/ tests/
56+
@clang-tidy src/*.cc -- -std=c++17 -I./include -I/usr/local/include/ -I/opt/homebrew/include/
57+
58+
.PHONY: proto
59+
proto:
60+
@protoc -I../ --cpp_out=./generated ../protos/*.proto

0 commit comments

Comments
 (0)