Skip to content

Commit ac21ec2

Browse files
committed
refactor: use turbo also for the backend and ci fixed
1 parent 5926ed6 commit ac21ec2

10 files changed

Lines changed: 69 additions & 44 deletions

File tree

.github/workflows/backend.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Backend Build and Test
1+
name: Backend CI
22

33
on:
44
push:
@@ -7,15 +7,17 @@ on:
77
branches: [main]
88

99
jobs:
10-
build-and-test:
10+
backend:
1111
runs-on: ubuntu-latest
1212

1313
steps:
1414
- name: Checkout code
1515
uses: actions/checkout@v6
16-
17-
- name: cd to backend
18-
run: cd apps/backend
16+
17+
- name: Setup Bun
18+
uses: oven-sh/setup-bun@v2
19+
with:
20+
bun-version: latest
1921

2022
- name: Install Rust toolchain
2123
uses: dtolnay/rust-toolchain@stable
@@ -25,11 +27,8 @@ jobs:
2527
- name: Rust Cache
2628
uses: Swatinem/rust-cache@v2
2729

28-
- name: Check formatting
29-
run: cargo fmt -- --check
30-
31-
- name: Run clippy
32-
run: cargo clippy -- -D warnings
30+
- name: Install dependencies
31+
run: bun install
3332

34-
- name: Run tests
35-
run: cargo test
33+
- name: Run backend tasks with Turborepo
34+
run: bunx turbo run lint check-types test build --filter=@sourcemaps/backend

.github/workflows/biome.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,34 @@ on:
77
workflow_dispatch:
88

99
jobs:
10-
build-and-start:
10+
build:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v6
1414
- uses: oven-sh/setup-bun@v2
1515
with:
1616
bun-version: latest
17+
- uses: dtolnay/rust-toolchain@stable
18+
- uses: Swatinem/rust-cache@v2
1719
- uses: actions/cache@v5
1820
with:
1921
key: bun-install-${{ runner.os }}-${{ hashFiles('bun.lock') }}
2022
path: ~/.bun/install/cache
2123
- run: bun install
2224
- run: bun run build
2325

24-
typecheck:
26+
check-types:
2527
runs-on: ubuntu-latest
2628
steps:
2729
- uses: actions/checkout@v6
2830
- uses: oven-sh/setup-bun@v2
2931
with:
3032
bun-version: latest
33+
- uses: dtolnay/rust-toolchain@stable
34+
- uses: Swatinem/rust-cache@v2
3135
- uses: actions/cache@v5
3236
with:
3337
key: bun-install-${{ runner.os }}-${{ hashFiles('bun.lock') }}
3438
path: ~/.bun/install/cache
3539
- run: bun install
36-
- run: bun turbo run typecheck
40+
- run: bun run check-types

.github/workflows/quality.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Quality Checks
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
quality:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: read
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v6
14+
with:
15+
persist-credentials: false
16+
- name: Setup Bun
17+
uses: oven-sh/setup-bun@v2
18+
with:
19+
bun-version: latest
20+
- name: Install Rust toolchain
21+
uses: dtolnay/rust-toolchain@stable
22+
with:
23+
components: clippy, rustfmt
24+
- name: Rust Cache
25+
uses: Swatinem/rust-cache@v2
26+
- name: Install dependencies
27+
run: bun install
28+
- name: Run quality tasks with Turborepo
29+
run: bun run lint

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ jobs:
1515
- uses: oven-sh/setup-bun@v2
1616
with:
1717
bun-version: latest
18+
- uses: dtolnay/rust-toolchain@stable
19+
- uses: Swatinem/rust-cache@v2
1820
- run: bun install
19-
- run: bun test
21+
- run: bun run test

apps/backend/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "@sourcemaps/backend",
3+
"private": true,
4+
"scripts": {
5+
"build": "cargo build --release",
6+
"lint": "cargo fmt -- --check && cargo clippy -- -D warnings",
7+
"check-types": "cargo check",
8+
"test": "cargo test"
9+
}
10+
}

apps/backend/src/auth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn header_value<'a>(headers: &'a HeaderMap, key: &str) -> Result<&'a str, AppErr
8787
.ok_or(AppError::Unauthorized)
8888
}
8989

90-
fn bearer_token<'a>(headers: &'a HeaderMap) -> Result<&'a str, AppError> {
90+
fn bearer_token(headers: &HeaderMap) -> Result<&str, AppError> {
9191
header_value(headers, HEADER_AUTHORIZATION)?
9292
.strip_prefix(BEARER_PREFIX)
9393
.ok_or(AppError::Unauthorized)

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
"build": "turbo run build",
66
"dev": "turbo run dev",
77
"lint": "turbo run lint",
8+
"test": "turbo run test",
89
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
9-
"check-types": "turbo run check-types"
10+
"check-types": "turbo run check-types",
11+
"ci": "turbo run lint check-types test build"
1012
},
1113
"devDependencies": {
1214
"@biomejs/biome": "2.4.4",

packages/bundler-plugin/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
},
4949
"scripts": {
5050
"build": "tsdown",
51+
"lint": "biome check .",
5152
"check-types": "tsc --noEmit",
5253
"test": "vitest run"
5354
},

turbo.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
"build": {
66
"dependsOn": ["^build"],
77
"inputs": ["$TURBO_DEFAULT$", ".env*"],
8-
"outputs": ["dist/**"]
8+
"outputs": ["dist/**", "target/release/**"]
99
},
1010
"lint": {
1111
"dependsOn": ["^lint"]
1212
},
1313
"check-types": {
1414
"dependsOn": ["^check-types"]
1515
},
16+
"test": {
17+
"dependsOn": ["^build"]
18+
},
1619
"dev": {
1720
"cache": false,
1821
"persistent": true

0 commit comments

Comments
 (0)