Skip to content

Commit 7b27807

Browse files
authored
Add strikes remote (#14)
1 parent f5434a4 commit 7b27807

File tree

21 files changed

+1690
-149
lines changed

21 files changed

+1690
-149
lines changed

.github/workflows/infrastructure.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,22 @@ jobs:
2424
- uses: actions/checkout@v4
2525
- uses: hashicorp/setup-terraform@v3
2626

27+
- name: Run docker-compose
28+
uses: hoverkraft-tech/compose-action@v2.0.1
29+
with:
30+
compose-file: "infrastructure/lambdas/tests/docker-compose.yml"
31+
2732
- name: Build & Test lambda
33+
env:
34+
AWS_DEFAULT_REGION: eu-central-1
35+
AWS_ACCESS_KEY_ID: 223344
36+
AWS_SECRET_ACCESS_KEY: wJalrXUtTHISI/DYNAMODB/bPxRfiCYEXAMPLEKEY
2837
run: |
2938
pip3 install cargo-lambda
3039
rustup update stable && rustup default stable
31-
cargo lambda build --arm64 --release
40+
cargo lambda build --release
3241
cargo test --verbose
33-
working-directory: infrastructure/health
42+
working-directory: infrastructure/lambdas
3443

3544
- name: Configure AWS credentials
3645
uses: aws-actions/configure-aws-credentials@v4

README.md

Lines changed: 75 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,94 @@ tar -xvzf strikes-0.0.1-alpha-x86_64-unknown-linux-musl.tar.gz -C <path-to-insta
1919
After extracting the binary, you may need to add the path to your PATH environment variable.
2020

2121
## Usage
22-
- Add a strike to a user
2322
```bash
24-
strikes strike <user>
25-
```
23+
Simple CLI tool to track and assign strikes
2624

27-
- List all strikes
28-
```bash
29-
strikes ls
30-
```
25+
Usage: strikes [OPTIONS] [COMMAND]
3126

32-
- Clear all strikes
33-
```bash
34-
strikes clear
27+
Commands:
28+
strike Add a strike
29+
ls List all strikes
30+
clear Clear strikes
31+
check-health Check health of the client
32+
help Print this message or the help of the given subcommand(s)
33+
34+
Options:
35+
-c, --config-path <CONFIG_PATH>
36+
Specify the path to the configuration file
37+
38+
-h, --help
39+
Print help (see a summary with '-h')
40+
41+
-V, --version
42+
Print version
3543
```
3644

37-
## Use locally only
45+
## Use with a remote server
46+
You can use a remote server to store the strikes. Either you get access to an existing server or you can deploy the infractructure to your AWS account yourself.
47+
Anyways you need to provide the URL to the server and an API key.
48+
49+
## Use locally
3850
You can use the local client without a remote server.
3951
It will generate a JSON file where the strikes are stored.
40-
The default path is in your home directory at '.strikes/db.json'.
41-
You can configure a different location by using the '--db-path' argument or by providing a configuration file.
42-
The argument has precedence over the configuration file.
4352

44-
### Configuration file
45-
The configuration file needs to be a yaml file.
53+
## Configuration file
54+
Provide a configuration file at ./strikes/configuration.yaml. The remote server configuration has precedence over the local configuration.
4655

4756
```yaml
57+
remote:
58+
base_rul: "https://strikes.example.com"
59+
api_key: "your-api-key"
4860
local:
49-
db_path: /path/to/db.json
61+
db_path: "/path/to/db.json"
5062
```
5163
64+
You can configure a different configuration file location by using the '--config-path' argument.
65+
The argument has precedence over the configuration file.
66+
5267
```bash
5368
strikes --config-path /path/to/configuration.yaml strike guenther
5469
```
70+
71+
## Development
72+
### Pre-requisites
73+
You'll need to install:
74+
- [Rust](https://www.rust-lang.org/tools/install)
75+
- [Docker](https://docs.docker.com/get-docker)
76+
- [Terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli)
77+
- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html)
78+
79+
### Deploy infrastructure to your AWS account
80+
First of all you need to create a S3 bucket to store the terraform state. Navigate to the infrastructure/remote-state directory and run:
81+
```bash
82+
terraform init
83+
terraform plan
84+
terraform apply
85+
```
86+
This will create a S3 bucket and a DynamoDB table to store the terraform state. Afterwards you can deploy the infrastructure by navigating to the infrastructure directory and running:
87+
88+
```bash
89+
terraform init
90+
terraform plan
91+
terraform apply
92+
```
93+
94+
### How to test the cli-client
95+
Navigate to cli-client and run:
96+
```bash
97+
cargo test
98+
```
99+
100+
### How to test the infrastructure lambdas
101+
Navigate to infrastructure/lambdas/tests and run:
102+
103+
```bash
104+
docker-compose up -d
105+
```
106+
107+
This will set up a DynamoDB local instance. Afterwards navigate back to infrastructure/lambdas and run:
108+
109+
110+
```bash
111+
cargo test
112+
```

0 commit comments

Comments
 (0)