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

[TSK-28] - Unit Tests and Improvements #17

Merged
merged 55 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
490923e
makefile commands added for both linux and windows development
phrp720 Nov 20, 2024
b1adeb8
Update of Agent Documentation
phrp720 Nov 20, 2024
dd319a6
Update of Center Documentation
phrp720 Nov 20, 2024
2d24dec
Update of Agent Documentation
phrp720 Nov 20, 2024
15232e9
tests init
phrp720 Nov 20, 2024
06f905b
Merge remote-tracking branch 'origin/master' into phillip/TSK-28
phrp720 Nov 20, 2024
1fdab6d
documentation update
phrp720 Nov 20, 2024
640509b
documentation update
phrp720 Nov 20, 2024
692b437
documentation update
phrp720 Nov 20, 2024
0a532ec
documentation update
phrp720 Nov 20, 2024
dec1236
documentation update
phrp720 Nov 20, 2024
0880e94
documentation update
phrp720 Nov 20, 2024
5521120
documentation update
phrp720 Nov 20, 2024
2a5eeea
Testing fixes
phrp720 Nov 20, 2024
8bf3593
aggregation testing added
phrp720 Nov 21, 2024
a112de2
filter testings additions
phrp720 Nov 21, 2024
e886069
settings tests fixed
phrp720 Nov 21, 2024
d8c4d58
technology stack added
phrp720 Nov 21, 2024
d59a3fe
tests.yml impl
phrp720 Nov 23, 2024
a22d694
tests.yml impl
phrp720 Nov 23, 2024
7a9cbe9
wip
phrp720 Nov 23, 2024
f3b9bd4
wip
phrp720 Nov 23, 2024
024d19b
wip
phrp720 Nov 23, 2024
938c3cf
wip
phrp720 Nov 23, 2024
dc9e629
wip
phrp720 Nov 23, 2024
44dd253
wip
phrp720 Nov 23, 2024
5438f97
wip
phrp720 Nov 23, 2024
19131b3
wip
phrp720 Nov 23, 2024
da1b83a
wip
phrp720 Nov 23, 2024
dbbc848
wip
phrp720 Nov 23, 2024
da8daea
wip
phrp720 Nov 23, 2024
08bf994
wip
phrp720 Nov 23, 2024
10c214a
wip
phrp720 Nov 23, 2024
9d8ef2f
wip
phrp720 Nov 23, 2024
6fcd223
wip
phrp720 Nov 23, 2024
85844d1
wip
phrp720 Nov 23, 2024
5b4301a
wip
phrp720 Nov 23, 2024
92ab010
wip
phrp720 Nov 23, 2024
c067fd7
wip
phrp720 Nov 23, 2024
bab9f04
wip
phrp720 Nov 23, 2024
465de17
wip
phrp720 Nov 23, 2024
b946564
wip
phrp720 Nov 23, 2024
6cc894e
wip
phrp720 Nov 23, 2024
5b09f68
wip
phrp720 Nov 23, 2024
388d442
wip
phrp720 Nov 23, 2024
cadf98d
wip
phrp720 Nov 23, 2024
49a3856
wip
phrp720 Nov 23, 2024
962d903
wip
phrp720 Nov 23, 2024
c5d9e71
wip
phrp720 Nov 23, 2024
f8906de
wip
phrp720 Nov 23, 2024
0afae96
wip
phrp720 Nov 23, 2024
b6600ec
wip
phrp720 Nov 23, 2024
047066d
wip
phrp720 Nov 23, 2024
d5a28a2
readme update
phrp720 Nov 23, 2024
c4fc6f3
readme update
phrp720 Nov 23, 2024
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
21 changes: 21 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Tests

on: [push]

jobs:
test:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.23.2'

- name: Run Go tests
working-directory: aw-sync-agent
run: go test ./tests/
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,44 @@ Open-Source Solution for Securely Syncing and Visualizing Multiple ActivityWatch
</p>

<p align="center">

<a href="https://github.com/phrp720/aw-sync-suite/actions/workflows/tests.yaml?query=branch%3Amaster">
<img title="Tests" src="https://github.com/phrp720/aw-sync-suite/actions/workflows/tests.yaml/badge.svg?branch=master" alt="tests"/>
</a>
<a href="https://github.com/phrp720/aw-sync-suite/actions/workflows/build.yml?query=branch%3Amaster">
<img title="Build Status GitHub" src="https://github.com/phrp720/aw-sync-suite/actions/workflows/build.yml/badge.svg?branch=master" alt="build"/>
</a>
<a href="https://github.com/phrp720/aw-sync-suite/actions/workflows/agent-docker-image.yml?query=branch%3Amaster">
<img title="Docker Build" src="https://github.com/phrp720/aw-sync-suite/actions/workflows/build.yml/badge.svg?branch=master" alt="docker build">
<img title="Docker Build" src="https://github.com/phrp720/aw-sync-suite/actions/workflows/agent-docker-image.yml/badge.svg?branch=master" alt="docker build">
</a>

<a href="https://github.com/phrp720/aw-sync-suite/releases">
<img title="Latest release" src="https://img.shields.io/github/v/release/phrp720/aw-sync-suite" alt="release">
</a>
</p>

<p align="center">
If you’ve ever wished for <strong> a simple, centralized solution </strong> to sync and visualize data from multiple instances of ActivityWatch, you’re in the right place.

</p>

<details>

<summary>Table of Contents</summary>

1. [About](#about)
2. [Features](#features)
3. [Flow Diagrams](#flow-diagrams)
- [Without Bearer Token Authentication](#1-activitywatch-sync-suite-flow-diagram-without-bearer-token-authentication)
- [With Bearer Token Authentication](#2-activitywatch-sync-suite-flow-diagram-with-bearer-token-authentication)
- [Without Bearer Token Authentication](#1-sync-suite-without-bearer-token-authentication)
- [With Bearer Token Authentication](#2-sync-suite-with-bearer-token-authentication)
4. [Quick Start](#quick-start)
- [Download the Latest Release](#1-download-the-latest-release)
- [Deploy aw-sync-center (Cloud Setup)](#2-deploy-aw-sync-center-cloud-setup)
- [Configure and Run aw-sync-agent (On Each Computer)](#3-configure-and-run-aw-sync-agent-on-each-computer)
- [Visualize in Grafana](#4-visualize-in-grafana)
5. [Components](#components)
- [aw-sync-agent](#aw-sync-agent)
- [aw-sync-center](#aw-sync-center)
6. [Requirements](#requirements)
7. [Contributing](#contributing)
</details>
Expand All @@ -42,7 +55,7 @@ This project operates independently of **ActivityWatch** and is compatible with
- **[aw-sync-agent](https://github.com/phrp720/aw-sync-suite/tree/master/aw-sync-agent):** A lightweight agent that runs on each computer you want to sync data from. It connects to ActivityWatch, retrieves the data,filter them, and pushes it to Prometheus.
- **[aw-sync-center](https://github.com/phrp720/aw-sync-suite/tree/master/aw-sync-center):** A cloud-based setup containing Prometheus and Grafana for centralized data storage and visualization. It is set up once to handle the aggregation and visualization of data from all agents.

This repository simplifies the deployment and integration process, making it easy to get started with ActivityWatch-based analytics.
This repository simplifies the deployment and integration process, making it easy to get started with ActivityWatch-based user analytics.

## Features
- Sync data from multiple ActivityWatch instances to a centralized Prometheus database.
Expand All @@ -53,10 +66,10 @@ This repository simplifies the deployment and integration process, making it eas
## Flow Diagrams


### 1. Sync-Suite Flow Diagram without Bearer Token Authentication
### 1. Sync-Suite without Bearer Token Authentication
![aw-sync-diagram.png](aw-sync-diagram.png)

### 2. Sync-Suite Flow Diagram with Bearer Token Authentication
### 2. Sync-Suite with Bearer Token Authentication
![aw-sync-diagram-nginx.png](aw-sync-diagram-nginx.png)

## Quick Start
Expand Down Expand Up @@ -95,7 +108,7 @@ Once configured, you can run the **aw-sync-agent** in one of two ways:
````
- As a Docker container: Use the Docker image to run the agent in a container. Here’s an example:
```bash
docker run -v /path/to/aw-sync-agent.yaml:/opt/aw-sync-agent/aw-sync-agent.yaml phrp720/aw-sync-agent:latest
docker run -v /path/to/aw-sync-agent.yaml:/opt/aw-sync-agent/aw-sync-agent.yaml phrp5/aw-sync-agent:latest
```
> [!CAUTION]
> Make sure to replace `/path/to/aw-sync-agent.yaml` with the path to your configuration file.
Expand Down
47 changes: 31 additions & 16 deletions aw-sync-agent/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,25 @@ MAKEFLAGS += --no-print-directory
OS := $(shell go run scripts/detect_os.go)
ifeq ($(OS), windows)
BUILD := go build -o aw-sync-agent.exe main.go
CLEAN := rm -rf $(HOME)/AwSyncAgent
CLEAN := rm -rf aw-sync-agent.exe
CLEAN-SERVICE := rm -rf $(HOME)/AwSyncAgent

SERVICE-START := $(HOME)/AwSyncAgent/nssm.exe start aw-sync-agent
SERVICE-STOP := $(HOME)/AwSyncAgent/nssm.exe stop aw-sync-agent
SERVICE-REMOVE := $(HOME)/AwSyncAgent/nssm.exe remove aw-sync-agent confirm && $(CLEAN-SERVICE)
SERVICE-RESTART := $(HOME)/AwSyncAgent/nssm.exe restart aw-sync-agent
SERVICE-STATUS := $(HOME)/AwSyncAgent/nssm.exe status aw-sync-agent

else
BUILD := go build -o aw-sync-agent main.go
CLEAN := rm -rf $(HOME)/.config/aw

CLEAN := rm -rf aw-sync-agent
CLEAN-SERVICE := rm -rf $(HOME)/.config/aw

SERVICE-START := systemctl --user start aw-sync-agent
SERVICE-STOP := systemctl --user stop aw-sync-agent
SERVICE-REMOVE := rm $(HOME)/.config/systemd/user/aw-sync-agent.service && systemctl --user daemon-reload
SERVICE-RESTART := systemctl --user restart aw-sync-agent
SERVICE-STATUS := systemctl --user status aw-sync-agent
endif

##General commands
Expand All @@ -19,15 +32,22 @@ run:
build:
@$(BUILD)

clean:
@$(CLEAN)

check-os:
@go run scripts/detect_os.go

clean:
@$(CLEAN)
clean-service:
@echo "Cleaning ActivityWatch Sync Agent service files..."
@$(CLEAN-SERVICE)

format:
@gofmt -s -w .

test:
@go test ./tests/

##(from linux only) Build executables for both windows and linux
build-all:
@GOOS=windows GOARCH=amd64 go build -o aw-sync-agent.exe main.go
Expand All @@ -49,28 +69,23 @@ service-install:

service-start:
@echo "Starting ActivityWatch Sync Agent service..."
@systemctl --user start aw-sync-agent
@$(SERVICE-START)

service-stop:
@echo "Stopping ActivityWatch Sync Agent service..."
@systemctl --user stop aw-sync-agent
@$(SERVICE-STOP)

service-status:
@echo "ActivityWatch Sync Agent service status:"
@systemctl --user status aw-sync-agent
@$(SERVICE-STATUS)

service-remove:
@$(MAKE) service-stop
@echo "Deleting ActivityWatch Sync Agent service..."
@rm $(HOME)/.config/systemd/user/aw-sync-agent.service
@systemctl --user daemon-reload
@$(CLEAN)
@$(SERVICE-REMOVE)
@$(CLEAN-SERVICE)

service-restart:
@echo "Restarting ActivityWatch Sync Agent service..."
@systemctl --user restart aw-sync-agent
@$(SERVICE-RESTART)

service-update:
@echo "Re-Building ActivityWatch Sync Agent application..."
@go build -o $(HOME)/.config/aw/aw-sync-agent main.go
@$(MAKE) service-restart
Loading
Loading