Skip to content

Commit

Permalink
update: dev env
Browse files Browse the repository at this point in the history
  • Loading branch information
kenkoooo committed Apr 22, 2023
1 parent b2e15eb commit f62ada1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.PHONY: help
help:
@awk -F ':|##' '/^[^\t].+?:.*?##/ { printf "\033[36m%-22s\033[0m %s\n", $$1, $$NF }' $(MAKEFILE_LIST)

.PHONY: up
up:
docker compose up

.PHONY: down
down:
docker compose down

.PHONY: test/backend
test/backend:
docker compose exec backend-development cargo test --workspace --no-fail-fast -- --test-threads=1
4 changes: 0 additions & 4 deletions atcoder-problems-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
FROM rust:1.63.0 AS development
RUN rustup component add rustfmt
RUN rustup component add clippy

# Using the official cargo-chef image
FROM lukemathwalker/cargo-chef:latest-rust-1.63.0 AS chef
WORKDIR /app
Expand Down
9 changes: 9 additions & 0 deletions atcoder-problems-backend/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM rust:1.63.0 AS development
RUN rustup component add rustfmt
RUN rustup component add clippy

# Install cargo-watch
RUN wget "https://github.com/watchexec/cargo-watch/releases/download/v8.4.0/cargo-watch-v8.4.0-$(uname -m)-unknown-linux-gnu.tar.xz" \
&& tar -xf "cargo-watch-v8.4.0-$(uname -m)-unknown-linux-gnu.tar.xz" \
&& cp "cargo-watch-v8.4.0-$(uname -m)-unknown-linux-gnu/cargo-watch" /usr/local/bin/ \
&& rm -rf "cargo-watch-v8.4.0-$(uname -m)-unknown-linux-gnu"
21 changes: 0 additions & 21 deletions atcoder-problems-backend/atcoder-client/src/atcoder/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,4 @@ mod tests {
let problems = client.fetch_problem_list("abc107").await.unwrap();
assert_eq!(problems.len(), 4);
}

#[tokio::test]
async fn test_fetch_submission_list() {
let client = AtCoderClient::default();
let response = client
.fetch_atcoder_submission_list("xmascon17", None)
.await
.unwrap();
assert_eq!(response.submissions.len(), 20);

let response = client
.fetch_atcoder_submission_list("xmascon17", Some(response.max_page))
.await
.unwrap();
assert!(!response.submissions.is_empty());

let response = client
.fetch_atcoder_submission_list("xmascon17", Some(response.max_page + 1))
.await;
assert!(response.is_err());
}
}
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ services:
- "15432:5432"

backend-development:
image: rust:1.63.0
build:
context: ./atcoder-problems-backend
dockerfile: Dockerfile.dev
environment:
SQL_URL: postgres://db_user:db_pass@postgresql:5432/test_db
DATABASE_URL: postgres://db_user:db_pass@postgresql:5432/test_db
Expand All @@ -28,7 +30,7 @@ services:
- cargo-cache:/usr/local/cargo/registry
- target-cache:/app/atcoder-problems-backend/target
working_dir: /app/atcoder-problems-backend
command: /bin/sh -c "while sleep 1000; do :; done"
command: /bin/sh -c "cargo watch -s 'cargo run --bin run_server'"

frontend-development:
image: node:16
Expand Down

0 comments on commit f62ada1

Please sign in to comment.