photo-album

master

A application for fetching photos by album id. Written in Rust.

This uses https://jsonplaceholder.typicode.com as the photo store.

Running Locally

There are multiple options for running this project. This will mostly depend on what tools you want to install.

Most commands will refer to make. If make is not installed, copy the commands in makefile, and run them directly in the terminal.

Pre-built Binary

Linux is the only current platform with a pre-built binary

  1. Go to latest release page and download the photo-album under assets.
  2. cd to download folder.
  3. chmod +x ./photo-album
  4. ./photo-album 1

Docker

This only requires that Docker be installed and running.

  1. make docker
  2. docker run --rm rcoy-v/photo-album 1

Building the Docker image runs linter, format check, and all tests before building a binary with release profile. This will take a few minutes the first time it is ran.

From Source

To run everything from source, the following tools need to be setup:

  1. Install rustup. rustup manages installations ofrustc and cargo.
  2. Add ~/.cargo/bin to $PATH, if not done so during rustup install.
  3. Verify everything is installed correctly.
    1. rustc --version
    2. cargo --version
  4. rustup component install clippy-preview. Installs the linter.
  5. rustup component install rustfmt. Install the formatter.

Now all tools are installed to run everything:

make

make
./target/debug/photo-album 1

Builds an unoptimized binary for testing. Much faster than building an actual release.

make release

make release
./target/release/photo-album 1

Builds a fully optimized binary with release profile. Can take a few minutes.

cargo run

cargo run -- 1

Direct way to run application without building and referencing binary. Everything after -- is passed directly as arguments to the application.

make test

make test

Runs the following:

  • Clippy linter
  • rustfmt format check
  • unit tests
  • integration tests

make fmt

make fmt

Fixes format issues in code.