From 2cd72d9903bd71985a9451e24571696f6826fe6a Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 5 Jan 2023 15:47:17 +0000 Subject: [PATCH 1/5] Hello, world Created using: cargo init --- Cargo.toml | 8 ++++++++ src/main.rs | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..36bafbd --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "s3-active-storage" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} From 364de0bbe43fce37354789295b6bc6c1f5cf7fc8 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 5 Jan 2023 15:47:39 +0000 Subject: [PATCH 2/5] gitignore --- .gitignore | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 088ba6b..9fc3af8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,12 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk + +# Editors +*~ +.*.swp +.*sw? + +# Added by cargo + +/target From 2fe114c537d2ff13befe8f3efd2d1696a7fef904 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 5 Jan 2023 15:48:29 +0000 Subject: [PATCH 3/5] Build system: Dockerfile & Makefile --- Dockerfile | 12 ++++++++++++ Makefile | 7 +++++++ README.md | 15 ++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 Makefile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c1b25eb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +# Adapted from the multi-stage build example in https://hub.docker.com/_/rust + +# Stage 1: builder +FROM rust:1.66 as builder +WORKDIR /usr/src/s3-active-storage +COPY . . +RUN cargo install --path . + +# Stage 2: final image +FROM debian:bullseye-slim +COPY --from=builder /usr/local/cargo/bin/s3-active-storage /usr/local/bin/s3-active-storage +CMD ["s3-active-storage"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9879928 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY: build +build: + @docker build -t s3-active-storage . + +.PHONY: run +run: + @docker run -it --rm --name s3-active-storage s3-active-storage diff --git a/README.md b/README.md index 0db6b95..bd6e131 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,15 @@ -# rusty-s3-active-storage +# Rusty S3 Active Storage + S3 Active Storage server + +## Build + +```bash +make build +``` + +## Run + +```bash +make run +``` From faa50f4688c78541f10aa3fe19a327c5fcf0d409 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 5 Jan 2023 16:30:56 +0000 Subject: [PATCH 4/5] Add test Make target Runs cargo check and cargo test --- Dockerfile | 2 ++ Makefile | 8 +++++++- README.md | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c1b25eb..a72b8df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +# syntax=docker/dockerfile:1 + # Adapted from the multi-stage build example in https://hub.docker.com/_/rust # Stage 1: builder diff --git a/Makefile b/Makefile index 9879928..84c8b04 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,12 @@ .PHONY: build build: - @docker build -t s3-active-storage . + @docker buildx build -t s3-active-storage . + +.PHONY: test +test: + @docker buildx build --target builder -t s3-active-storage-test . + @docker run --rm s3-active-storage-test cargo check --color always + @docker run --rm s3-active-storage-test cargo test --color always .PHONY: run run: diff --git a/README.md b/README.md index bd6e131..36b5e08 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,12 @@ S3 Active Storage server make build ``` +## Test + +```bash +make test +``` + ## Run ```bash From 2837311b53d6a1a816d511721afcdd62eb4f055a Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 5 Jan 2023 16:32:10 +0000 Subject: [PATCH 5/5] CI: Add basic GitHub Actions workflow --- .github/workflows/pull-request.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..55b3470 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,22 @@ +--- +name: Pull request +on: + - push + - pull_request +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Build + run: make build + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Test + run: make test