Skip to content

Commit 1bc7c4d

Browse files
authored
Updated CONTRIBUTING.md docs and added pre commit hook (#336)
1 parent 9797d75 commit 1bc7c4d

3 files changed

Lines changed: 60 additions & 12 deletions

File tree

.githooks/pre-commit

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
set -e
3+
4+
echo "Running frontend lint..."
5+
docker exec Lingarr.Client npm run lint
6+
7+
echo "Running backend tests..."
8+
dotnet test Lingarr.slnx --verbosity quiet

CONTRIBUTING.md

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ cd lingarr
6161
git remote add upstream https://github.com/lingarr-translate/lingarr.git
6262
```
6363

64-
4. Create a new branch for your feature or bugfix following [Conventional Commits](https://www.conventionalcommits.org/):
64+
4. Enable the pre-commit hooks (runs lint within the client container + tests before each commit):
65+
```bash
66+
git config core.hooksPath .githooks
67+
```
68+
69+
5. Create a new branch for your feature or bugfix following [Conventional Commits](https://www.conventionalcommits.org/):
6570
```bash
6671
git checkout -b feat/your-feature-name
6772
# or
@@ -80,6 +85,18 @@ The project is organized into several key components:
8085

8186
## Building and Testing
8287

88+
### Running Tests
89+
```bash
90+
dotnet test
91+
```
92+
93+
Frontend lint:
94+
```bash
95+
cd Lingarr.Client && npm run lint
96+
```
97+
98+
These run automatically on each commit if you enabled the pre-commit hooks (step 4 above).
99+
83100
### Development
84101
Navigate to the root directory and start up the project:
85102
```bash
@@ -98,22 +115,42 @@ The frontend supports hot reload while the backend needs to be rebuilt each time
98115
| sonarr | http://localhost:8989 |
99116
| radarr | http://localhost:7878 |
100117

101-
102-
### Docker Build
103-
To build and push the Docker image (if logged into a Docker registry):
104-
```powershell
105-
./build-and-push.ps1 -Tag dev
106-
```
107-
108118
## Database Migrations
109119

120+
Lingarr uses [FluentMigrator](https://fluentmigrator.github.io/) with a single shared migration project (`Lingarr.Migrations`) that supports SQLite, MySQL, and PostgreSQL.
121+
110122
### Creating New Migrations
111-
Use the provided PowerShell script to create migrations:
112-
```powershell
113-
./create-migrations.ps1 -MigrationName "YourMigrationName"
123+
Add a new file to `Lingarr.Migrations/Migrations/` following the naming convention:
124+
125+
```
126+
M{NNNN}_{MigrationName}.cs
127+
```
128+
129+
Example — `M0006_AddMyTable.cs`:
130+
```csharp
131+
using FluentMigrator;
132+
133+
namespace Lingarr.Migrations.Migrations;
134+
135+
[Migration(6)]
136+
public class M0006_AddMyTable : Migration
137+
{
138+
public override void Up()
139+
{
140+
Create.Table("my_table")
141+
.WithColumn("id").AsInt32().PrimaryKey().Identity()
142+
.WithColumn("name").AsCustom("TEXT").NotNullable();
143+
}
144+
145+
public override void Down()
146+
{
147+
Delete.Table("my_table");
148+
}
149+
}
114150
```
115151

116-
This will create migrations for both SQLite and MySQL providers.
152+
- The `[Migration(N)]` version number must be unique and sequential
153+
- Always implement `Down()` to make migrations reversible
117154

118155
### Applying Migrations
119156
Migrations are automatically applied when the application starts.

Lingarr.slnx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
<File Path=".github/dependabot.yml" />
2222
<File Path=".github/FUNDING.yml" />
2323
</Folder>
24+
<Folder Name="/Lingarr.Root/.githooks/">
25+
<File Path=".githooks/pre-commit" />
26+
</Folder>
2427
<Folder Name="/Lingarr.Root/.github/ISSUE_TEMPLATE/">
2528
<File Path=".github/ISSUE_TEMPLATE/bug_report.yml" />
2629
<File Path=".github/ISSUE_TEMPLATE/config.yml" />

0 commit comments

Comments
 (0)