Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 13 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ jobs:
uses: actions-rs/cargo@v1.0.3
with:
command: rustdoc
args: -p taskchampion-sync-server --all-features -- -Z unstable-options --check -Dwarnings
args: -p taskchampion-sync-server --bin taskchampion-sync-server --all-features -- -Z unstable-options --check -Dwarnings

- name: taskchampion-sync-server-postgres
uses: actions-rs/cargo@v1.0.3
with:
command: rustdoc
args: -p taskchampion-sync-server --bin taskchampion-sync-server-postgres --all-features -- -Z unstable-options --check -Dwarnings

- name: taskchampion-sync-server-core
uses: actions-rs/cargo@v1.0.3
Expand All @@ -80,6 +86,12 @@ jobs:
command: rustdoc
args: -p taskchampion-sync-server-storage-sqlite --all-features -- -Z unstable-options --check -Dwarnings

- name: taskchampion-sync-server-storage-postgres
uses: actions-rs/cargo@v1.0.3
with:
command: rustdoc
args: -p taskchampion-sync-server-storage-postgres --all-features -- -Z unstable-options --check -Dwarnings

fmt:
runs-on: ubuntu-latest
name: "Formatting"
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ for more on how to use this project.

## Repository Guide

The repository is comprised of three crates:
The repository is comprised of four crates:

- `taskchampion-sync-server-core` implements the core of the protocol
- `taskchampion-sync-server-storage-sqlite` implements an SQLite backend for the core
Expand Down Expand Up @@ -60,16 +60,34 @@ cargo build --release
After build the binary is located in
`target/release/taskchampion-sync-server`.

### Building the Container
#### Building the Postgres backend

To build the container, execute the following commands.
The storage backend is controlled by Cargo features `postres` and `sqlite`.
By default, only the `sqlite` feature is enabled.
To enable building the Postgres backend, add `--features postgres`.
The Postgres binary is located in
`target/release/taskchampion-sync-server-postgres`.

### Building the Docker Images

To build the images, execute the following commands.

SQLite:
```sh
source .env
docker build \
--build-arg RUST_VERSION=${RUST_VERSION} \
--build-arg ALPINE_VERSION=${ALPINE_VERSION} \
-t taskchampion-sync-server docker/sqlite
```

Postgres:
```sh
source .env
docker build \
--build-arg RUST_VERSION=${RUST_VERSION} \
--build-arg ALPINE_VERSION=${ALPINE_VERSION} \
-t taskchampion-sync-server .
-t taskchampion-sync-server-postgres docker/postgres
```

Now to run it, simply exec.
Expand Down
2 changes: 1 addition & 1 deletion postgres/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//! An external application may:
//! - Add additional tables to the database
//! - Add additional columns to the `clients` table. If those columns do not have default
//! values, calls to [`Txn::new_client`] will fail. It is possible to configure
//! values, calls to `Txn::new_client` will fail. It is possible to configure
//! `taskchampion-sync-server` to never call this method.
//! - Insert rows into the `clients` table, using default values for all columns except
//! `client_id` and application-specific columns.
Expand Down
18 changes: 17 additions & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,25 @@ authors = ["Dustin J. Mitchell <dustin@mozilla.com>"]
edition = "2021"
publish = false

[features]
# By default, only build the SQLite backend.
default = ["sqlite"]
sqlite = ["dep:taskchampion-sync-server-storage-sqlite"]
postgres = ["dep:taskchampion-sync-server-storage-postgres"]

[[bin]]
# The simple binary name is the SQLite build.
name = "taskchampion-sync-server"
required-features = ["sqlite"]

[[bin]]
name = "taskchampion-sync-server-postgres"
required-features = ["postgres"]

[dependencies]
taskchampion-sync-server-core = { path = "../core" }
taskchampion-sync-server-storage-sqlite = { path = "../sqlite" }
taskchampion-sync-server-storage-sqlite = { path = "../sqlite", optional = true }
taskchampion-sync-server-storage-postgres = { path = "../postgres", optional = true }
uuid.workspace = true
actix-web.workspace = true
anyhow.workspace = true
Expand Down
6 changes: 4 additions & 2 deletions server/src/api/add_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ pub(crate) async fn service(

#[cfg(test)]
mod test {
use crate::WebServer;
use crate::{api::CLIENT_ID_HEADER, WebConfig};
use crate::{
api::CLIENT_ID_HEADER,
web::{WebConfig, WebServer},
};
use actix_web::{http::StatusCode, test, App};
use pretty_assertions::assert_eq;
use taskchampion_sync_server_core::{InMemoryStorage, ServerConfig, Storage, NIL_VERSION_ID};
Expand Down
6 changes: 4 additions & 2 deletions server/src/api/add_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ pub(crate) async fn service(

#[cfg(test)]
mod test {
use crate::WebServer;
use crate::{api::CLIENT_ID_HEADER, WebConfig};
use crate::{
api::CLIENT_ID_HEADER,
web::{WebConfig, WebServer},
};
use actix_web::{http::StatusCode, test, App};
use pretty_assertions::assert_eq;
use taskchampion_sync_server_core::{InMemoryStorage, ServerConfig, Storage};
Expand Down
6 changes: 4 additions & 2 deletions server/src/api/get_child_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ pub(crate) async fn service(

#[cfg(test)]
mod test {
use crate::WebServer;
use crate::{api::CLIENT_ID_HEADER, WebConfig};
use crate::{
api::CLIENT_ID_HEADER,
web::{WebConfig, WebServer},
};
use actix_web::{http::StatusCode, test, App};
use pretty_assertions::assert_eq;
use taskchampion_sync_server_core::{InMemoryStorage, ServerConfig, Storage, NIL_VERSION_ID};
Expand Down
6 changes: 4 additions & 2 deletions server/src/api/get_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ pub(crate) async fn service(

#[cfg(test)]
mod test {
use crate::WebServer;
use crate::{api::CLIENT_ID_HEADER, WebConfig};
use crate::{
api::CLIENT_ID_HEADER,
web::{WebConfig, WebServer},
};
use actix_web::{http::StatusCode, test, App};
use chrono::{TimeZone, Utc};
use pretty_assertions::assert_eq;
Expand Down
4 changes: 3 additions & 1 deletion server/src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use actix_web::{error, web, HttpRequest, Result, Scope};
use taskchampion_sync_server_core::{ClientId, Server, ServerError};

use crate::WebConfig;
use crate::web::WebConfig;

mod add_snapshot;
mod add_version;
Expand Down Expand Up @@ -89,6 +89,7 @@ mod test {
web_config: WebConfig {
client_id_allowlist: None,
create_clients: true,
..WebConfig::default()
},
};
let req = actix_web::test::TestRequest::default()
Expand All @@ -106,6 +107,7 @@ mod test {
web_config: WebConfig {
client_id_allowlist: Some([client_id_ok].into()),
create_clients: true,
..WebConfig::default()
},
};
let req = actix_web::test::TestRequest::default()
Expand Down
Loading
Loading