Skip to content

Updates to support release #2

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

Merged
merged 8 commits into from
Feb 10, 2024
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
16 changes: 0 additions & 16 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,3 @@ jobs:
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all --check

vet:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Enable caching
uses: Swatinem/rust-cache@v2
- name: Install cargo vet
run: cargo install cargo-vet
- name: Vet thirdparty dependencies
run: cargo vet check
4 changes: 2 additions & 2 deletions Cargo.lock

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

9 changes: 2 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ categories = ["database"]
edition = "2021"
keywords = ["postgresql", "ffi", "database"]
license = "(Apache-2.0 OR MIT) AND PostgreSQL"
repository = "https://github.com/theseus-rs/postgresql_embedded"
version = "0.1.1"
repository = "https://github.com/theseus-rs/postgresql-embedded"
version = "0.1.2"

[workspace.dependencies]
anyhow = { version = "1.0" }
Expand Down Expand Up @@ -39,8 +39,3 @@ tracing = { version = "0.1", features = ["log"] }
shared-version = true
dependent-version = "upgrade"
tag-name = "v{{version}}"

# The profile that 'cargo dist' will build with
[profile.dist]
inherits = "release"
lto = "thin"
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<p align="center"><img width="256" height="256" src="images/logo.png"></p>
<p align="center"><img width="250" height="250" src="images/logo.png"></p>

# PostgreSQL Embedded

[![ci](https://github.com/theseus-rs/postgresql-embedded/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/theseus-rs/postgresql-embedded/actions/workflows/ci.yml)
[![Latest version](https://img.shields.io/crates/v/postgresql_embedded.svg)](https://crates.io/crates/postgresql_embedded)
[![Documentation](https://docs.rs/postgresql_embedded/badge.svg)](https://docs.rs/postgresql_embedded)
[![License](https://img.shields.io/crates/p/postgresql_embedded.svg)](https://github.com/theseus-rs/postgresql_embedded#license)
[![License](https://img.shields.io/crates/l/postgresql_embedded)](https://github.com/theseus-rs/postgresql-embedded#license)
[![Semantic Versioning](https://img.shields.io/badge/%E2%9A%99%EF%B8%8F_SemVer-2.0.0-blue)](https://semver.org/spec/v2.0.0.html)

---

Install and run a PostgreSQL database locally on Linux, MacOS or Windows. PostgreSQL can be
bundled with your application, or downloaded on demand.

Expand Down
2 changes: 1 addition & 1 deletion postgresql_archive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition.workspace = true
keywords.workspace = true
license.workspace = true
name = "postgresql_archive"
repository.workspace = true
repository = "https://github.com/theseus-rs/postgresql-embedded/tree/main/postgresql_archive"
version.workspace = true

[dependencies]
Expand Down
69 changes: 33 additions & 36 deletions postgresql_archive/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# PostgreSQL Archive

[![ci](https://github.com/theseus-rs/postgresql-embedded/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/theseus-rs/postgresql-embedded/actions/workflows/ci.yml)
[![Latest version](https://img.shields.io/crates/v/postgresql_embedded.svg)](https://crates.io/crates/postgresql_embedded)
[![Documentation](https://docs.rs/postgresql_embedded/badge.svg)](https://docs.rs/postgresql_embedded)
[![License](https://img.shields.io/crates/p/postgresql_embedded.svg)](https://github.com/theseus-rs/postgresql_embedded#license)
[![Latest version](https://img.shields.io/crates/v/postgresql_archive.svg)](https://crates.io/crates/postgresql_embedded)
[![Documentation](https://docs.rs/postgresql_archive/badge.svg)](https://docs.rs/postgresql_embedded)
[![License](https://img.shields.io/crates/l/postgresql_archive?)](https://github.com/theseus-rs/postgresql-embedded/tree/main/postgresql_archive#license)
[![Semantic Versioning](https://img.shields.io/badge/%E2%9A%99%EF%B8%8F_SemVer-2.0.0-blue)](https://semver.org/spec/v2.0.0.html)

---

A library for downloading and extracting PostgreSQL archives from
[theseus-rs/postgresql-binaries](https://github.com/theseus-rs/postgresql-binaries).

## Examples

### Asynchronous API
**Note**: The following example requires the `tokio` runtime.

```rust
use postgresql_archive::{extract, get_archive, LATEST};
Expand All @@ -23,7 +20,7 @@ use postgresql_archive::{extract, get_archive, LATEST};
async fn main() {
let (archive_version, archive, hash) = get_archive(&LATEST).await.unwrap();
let out_dir = std::env::temp_dir();
let result = extract(&archive, &out_dir).await;
let result = extract(&archive, &out_dir).await.unwrap();
}
```

Expand All @@ -35,7 +32,7 @@ use postgresql_archive::blocking::{extract, get_archive};
fn main() {
let (archive_version, archive, hash) = get_archive(&LATEST).unwrap();
let out_dir = std::env::temp_dir();
let result = extract(&archive, &out_dir);
let result = extract(&archive, &out_dir).unwrap();
}
```

Expand All @@ -46,41 +43,41 @@ uses.

The following features are available:

Name | Description | Default?
---|---|---
`blocking` | Enables the blocking API | No
| Name | Description | Default? |
|---|---|---|
| `blocking` | Enables the blocking API | No |

## Supported platforms

`postgresql_archive` supports all platforms provided by [theseus-rs/postgresql-binaries](https://github.com/theseus-rs/postgresql-binaries).

Currently supported platforms are:

OS | [Target](https://doc.rust-lang.org/nightly/rustc/platform-support.html)
---|---
Linux | aarch64-unknown-linux-gnu
Linux | aarch64-unknown-linux-musl
Linux | arm-unknown-linux-gnueabi
Linux | arm-unknown-linux-gnueabihf
Linux | arm-unknown-linux-musleabi
Linux | arm-unknown-linux-musleabihf
Linux | armv5te-unknown-linux-gnueabi
Linux | armv7-unknown-linux-gnueabihf
Linux | armv7-unknown-linux-musleabihf
Linux | i586-unknown-linux-gnu
Linux | i586-unknown-linux-musl
Linux | i686-unknown-linux-gnu
Linux | i686-unknown-linux-musl
Linux | mips64-unknown-linux-gnuabi64
Linux | powerpc64le-unknown-linux-gnu
Linux | powerpc64le-unknown-linux-musl
Linux | s390x-unknown-linux-gnu
Linux | s390x-unknown-linux-musl
Linux | x86_64-unknown-linux-gnu
Linux | x86_64-unknown-linux-musl
MacOS | aarch64-apple-darwin
MacOS | x86_64-apple-darwin
Windows | x86_64-pc-windows-msvc
| OS | [Target](https://doc.rust-lang.org/nightly/rustc/platform-support.html) |
|---|---|
| Linux | aarch64-unknown-linux-gnu |
| Linux | aarch64-unknown-linux-musl |
| Linux | arm-unknown-linux-gnueabi |
| Linux | arm-unknown-linux-gnueabihf |
| Linux | arm-unknown-linux-musleabi |
| Linux | arm-unknown-linux-musleabihf |
| Linux | armv5te-unknown-linux-gnueabi |
| Linux | armv7-unknown-linux-gnueabihf |
| Linux | armv7-unknown-linux-musleabihf |
| Linux | i586-unknown-linux-gnu |
| Linux | i586-unknown-linux-musl |
| Linux | i686-unknown-linux-gnu |
| Linux | i686-unknown-linux-musl |
| Linux | mips64-unknown-linux-gnuabi64 |
| Linux | powerpc64le-unknown-linux-gnu |
| Linux | powerpc64le-unknown-linux-musl |
| Linux | s390x-unknown-linux-gnu |
| Linux | s390x-unknown-linux-musl |
| Linux | x86_64-unknown-linux-gnu |
| Linux | x86_64-unknown-linux-musl |
| MacOS | aarch64-apple-darwin |
| MacOS | x86_64-apple-darwin |
| Windows | x86_64-pc-windows-msvc |

## Safety

Expand Down
5 changes: 2 additions & 3 deletions postgresql_archive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
//! ## Examples
//!
//! ### Asynchronous API
//! **Note**: The following example requires the `tokio` runtime.
//!
//! ```rust, ignore
//! use postgresql_archive::{extract, get_archive, LATEST};
Expand All @@ -29,7 +28,7 @@
//! async fn main() {
//! let (archive_version, archive, hash) = get_archive(&LATEST).await.unwrap();
//! let out_dir = std::env::temp_dir();
//! let result = extract(&archive, &out_dir).await;
//! let result = extract(&archive, &out_dir).await.unwrap();
//! }
//! ```
//!
Expand All @@ -40,7 +39,7 @@
//!
//! let (archive_version, archive, hash) = get_archive(&LATEST).unwrap();
//! let out_dir = std::env::temp_dir();
//! let result = extract(&archive, &out_dir);
//! let result = extract(&archive, &out_dir).unwrap();
//! ```
//!
//! ## Feature flags
Expand Down
6 changes: 3 additions & 3 deletions postgresql_embedded/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ edition.workspace = true
keywords.workspace = true
license.workspace = true
name = "postgresql_embedded"
repository.workspace = true
repository = "https://github.com/theseus-rs/postgresql-embedded/tree/main/postgresql_embedded"
version.workspace = true

[build-dependencies]
anyhow = { workspace = true }
hex = { workspace = true }
postgresql_archive = { path = "../postgresql_archive", version = "0.1.1" }
postgresql_archive = { path = "../postgresql_archive", version = "0.1.2" }
sha2 = { workspace = true }
tokio = { workspace = true }

Expand All @@ -23,7 +23,7 @@ bytes = { workspace = true }
hex = { workspace = true }
home = { workspace = true }
lazy_static = { workspace = true }
postgresql_archive = { path = "../postgresql_archive", version = "0.1.1" }
postgresql_archive = { path = "../postgresql_archive", version = "0.1.2" }
rand = { workspace = true }
sha2 = { workspace = true }
tempfile = { workspace = true }
Expand Down
28 changes: 18 additions & 10 deletions postgresql_embedded/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
[![ci](https://github.com/theseus-rs/postgresql-embedded/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/theseus-rs/postgresql-embedded/actions/workflows/ci.yml)
[![Latest version](https://img.shields.io/crates/v/postgresql_embedded.svg)](https://crates.io/crates/postgresql_embedded)
[![Documentation](https://docs.rs/postgresql_embedded/badge.svg)](https://docs.rs/postgresql_embedded)
[![License](https://img.shields.io/crates/p/postgresql_embedded.svg)](https://github.com/theseus-rs/postgresql_embedded#license)
[![License](https://img.shields.io/crates/l/postgresql_embedded)](https://github.com/theseus-rs/postgresql-embedded/tree/main/postgresql_embedded#license)
[![Semantic Versioning](https://img.shields.io/badge/%E2%9A%99%EF%B8%8F_SemVer-2.0.0-blue)](https://semver.org/spec/v2.0.0.html)

---

Install and run a PostgreSQL database locally on Linux, MacOS or Windows. PostgreSQL can be
bundled with your application, or downloaded on demand.

Expand Down Expand Up @@ -53,7 +51,17 @@ fn main() {

## Information

The downloaded postgresql binaries are cached in the following directories:
During the build process, when the `bundled` feature is enabled, the PostgreSQL binaries are
downloaded and included in the resulting binary. The version of the PostgreSQL binaries is
determined by the `POSTGRESQL_VERSION` environment variable. If the `POSTGRESQL_VERSION`
environment variable is not set, then `postgresql_archive::LATEST` will be used to determine the
version of the PostgreSQL binaries to download.

When downloading the PostgreSQL binaries, either during build, or at runtime, the `GITHUB_TOKEN`
environment variable can be set to a GitHub personal access token to increase the rate limit for
downloading the PostgreSQL binaries. The `GITHUB_TOKEN` environment variable is not required.

At runtime, the PostgreSQL binaries are cached by default in the following directories:

- Unix: `$HOME/.theseus/postgresql`
- Windows: `%USERPROFILE%\.theseus\postgresql`
Expand All @@ -65,15 +73,15 @@ uses.

The following features are available:

Name | Description | Default?
---|---|---
`bundled` | Bundles the PostgreSQL archive into the resulting binary | Yes
`blocking` | Enables the blocking API; requires `tokio` | No
`tokio` | Enables using tokio for async | No
| Name | Description | Default? |
|------------|---|---|
| `bundled` | Bundles the PostgreSQL archive into the resulting binary | Yes |
| `blocking` | Enables the blocking API; requires `tokio` | No |
| `tokio` | Enables using tokio for async | No |

## Safety

These crates use `#![forbid(unsafe_code)]` to ensure everything is implemented in 100% safe Rust.
This crate uses `#![forbid(unsafe_code)]` to ensure everything is implemented in 100% safe Rust.

## License

Expand Down
4 changes: 4 additions & 0 deletions postgresql_embedded/src/command/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ impl CommandToString for tokio::process::Command {
}
}

/// Interface for executing a command
pub trait CommandExecutor {
/// Execute the command and return the stdout and stderr
async fn execute(&mut self, timeout: Option<Duration>) -> Result<(String, String)>;
}

/// Implement the [`CommandExecutor`] trait for [`Command`](std::process::Command)
impl CommandExecutor for std::process::Command {
/// Execute the command and return the stdout and stderr
async fn execute(&mut self, _timeout: Option<Duration>) -> Result<(String, String)> {
debug!("Executing command: {}", self.to_command_string());
self.stdout(Stdio::piped());
Expand Down Expand Up @@ -108,6 +111,7 @@ impl CommandExecutor for std::process::Command {
#[cfg(feature = "tokio")]
/// Implement the [`CommandExecutor`] trait for [`Command`](tokio::process::Command)
impl CommandExecutor for tokio::process::Command {
/// Execute the command and return the stdout and stderr
async fn execute(&mut self, timeout: Option<Duration>) -> Result<(String, String)> {
debug!("Executing command: {}", self.to_command_string());
self.stdout(Stdio::piped());
Expand Down
13 changes: 11 additions & 2 deletions postgresql_embedded/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
//! ## Examples
//!
//! ### Asynchronous API
//! **Note**: The following example requires the `tokio` runtime.
//!
//! ```rust, ignore
//! use postgresql_embedded::PostgreSQL;
Expand Down Expand Up @@ -59,7 +58,17 @@
//!
//! ## Information
//!
//! The downloaded postgresql binaries are cached in the following directories:
//! During the build process, when the `bundled` feature is enabled, the PostgreSQL binaries are
//! downloaded and included in the resulting binary. The version of the PostgreSQL binaries is
//! determined by the `POSTGRESQL_VERSION` environment variable. If the `POSTGRESQL_VERSION`
//! environment variable is not set, then `postgresql_archive::LATEST` will be used to determine the
//! version of the PostgreSQL binaries to download.
//!
//! When downloading the PostgreSQL binaries, either during build, or at runtime, the `GITHUB_TOKEN`
//! environment variable can be set to a GitHub personal access token to increase the rate limit for
//! downloading the PostgreSQL binaries. The `GITHUB_TOKEN` environment variable is not required.
//!
//! At runtime, the PostgreSQL binaries are cached by default in the following directories:
//!
//! - Unix: `$HOME/.theseus/postgresql`
//! - Windows: `%USERPROFILE%\.theseus\postgresql`
Expand Down
4 changes: 0 additions & 4 deletions supply-chain/audits.toml

This file was deleted.

Loading