Skip to content
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

rust: Initial implementation #497

Merged
merged 34 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8e2e718
rust: Initial implementation
eagletmt Aug 21, 2021
601d3a5
rust: Suppress clippy::float_cmp error
eagletmt Sep 4, 2021
cc1c4a0
rust: Add CI
eagletmt Sep 5, 2021
9334e6f
Merge remote-tracking branch 'origin/main' into rust/init
eagletmt Sep 6, 2021
d8ea95f
rust: Follow #596
eagletmt Sep 6, 2021
7a0e029
rust: Add workaround for sqlx bug
eagletmt Sep 6, 2021
446fa98
rust: Update workaround comment
eagletmt Sep 7, 2021
42f68fd
Merge remote-tracking branch 'origin/main' into rust/init
eagletmt Sep 8, 2021
c251bff
rust: Follow #602
eagletmt Sep 8, 2021
93f1da1
rust: Follow #609
eagletmt Sep 8, 2021
030614e
Merge remote-tracking branch 'origin/main' into rust/init
eagletmt Sep 9, 2021
9cdbf5e
rust: Follow #610
eagletmt Sep 9, 2021
5a0b336
rust: Follow #640
eagletmt Sep 9, 2021
e921580
rust: Follow #646
eagletmt Sep 9, 2021
91d873f
rust: Follow #634
eagletmt Sep 9, 2021
806dc9a
rust: cargo update
eagletmt Sep 9, 2021
d85041a
Merge remote-tracking branch 'origin/main' into rust/init
eagletmt Sep 10, 2021
346ed6d
rust: Follow #660
eagletmt Sep 10, 2021
e58b22b
rust: Setup CI with benchmarker
eagletmt Sep 11, 2021
a361772
rust: Fix CI job name
eagletmt Sep 11, 2021
5f63880
rust: Return JSON as application error message
eagletmt Sep 11, 2021
8c63253
Merge remote-tracking branch 'origin/main' into rust/init
eagletmt Sep 11, 2021
74da910
rust: Follow #662
eagletmt Sep 11, 2021
77d1e15
Merge remote-tracking branch 'origin/main' into rust/init
eagletmt Sep 13, 2021
d0525fb
Revert "rust: Return JSON as application error message"
eagletmt Sep 13, 2021
86363c3
rust: Follow #677
eagletmt Sep 13, 2021
c30b58e
rust: Follow #682
eagletmt Sep 13, 2021
1459d35
rust: Follow #685
eagletmt Sep 13, 2021
78519cb
rust: cargo update
eagletmt Sep 13, 2021
ec5d09c
rust: Run query outside of transactions when MYSQL_ERR_NUM_DUPLICATE_…
eagletmt Sep 14, 2021
2e1bfa0
rust: bcrypt result is always valid UTF-8 sequence
eagletmt Sep 14, 2021
7e95822
Merge remote-tracking branch 'origin/main' into rust/init
eagletmt Sep 14, 2021
2c28f6a
rust: Follow #722
eagletmt Sep 14, 2021
679e929
rust: Close all stdio when executing external commands
eagletmt Sep 14, 2021
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
56 changes: 56 additions & 0 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI for Rust backend

on:
push:
branches: [main]
paths:
- benchmarker/**/*
- webapp/rust/**/*
- .github/workflows/rust.yaml
pull_request:
paths:
- benchmarker/**/*
- webapp/rust/**/*
- .github/workflows/rust.yaml

jobs:
lint:
name: Lint
runs-on: self-hosted
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path webapp/rust/Cargo.toml -- --check
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --manifest-path webapp/rust/Cargo.toml

test:
name: Test
runs-on: self-hosted
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- name: Setup environment
run: make -C dev up TARGET=rust
- uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Run benchmarker with -no-load
run: |
make -C benchmarker
benchmarker/bin/benchmarker -no-load -exit-status
- name: Teardown environment
if: ${{ always() }}
run: make -C dev down TARGET=rust
49 changes: 49 additions & 0 deletions dev/docker-compose-rust.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: '3'

services:
frontend:
build:
context: ../webapp/frontend
dockerfile: ../../dev/frontend/Dockerfile
volumes:
- ./nginx:/etc/nginx/conf.d
ports:
- "8080:80"
depends_on:
- backend
backend:
build:
context: ../webapp/rust
dockerfile: ../../dev/rust/Dockerfile
restart: always
environment:
MYSQL_HOSTNAME: mysql
DEBUG: "true"
entrypoint: dockerize -timeout 60s -wait tcp://mysql:3306
command: /webapp/rust/target/debug/isucholar
ports:
- "7000:7000"
depends_on:
- mysql
volumes:
- ../webapp/data:/webapp/data:ro
- ../webapp/sql:/webapp/sql:ro
mysql:
image: mysql
restart: always
# setup.sqlの代替
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: isucon
MYSQL_PASSWORD: isucon
MYSQL_DATABASE: isucholar
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_bin
expose:
- "3306"
ports:
- "3306:3306"
volumes:
- mysql:/var/lib/mysql

volumes:
mysql:
18 changes: 18 additions & 0 deletions dev/rust/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM rust:1.55.0-buster

WORKDIR /webapp/rust

RUN apt-get update && apt-get install -y zip

ARG DOCKERIZE_VERSION=v0.6.1
RUN curl -sSfLO https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz

COPY Cargo.lock /Cargo.toml ./
RUN mkdir src && echo 'fn main() {}' > src/main.rs && cargo build --locked && rm src/main.rs target/debug/deps/isucholar-*

COPY . ./
RUN cargo build --locked --frozen

CMD ["/webapp/rust/target/debug/isucholar"]
1 change: 1 addition & 0 deletions webapp/rust/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
1 change: 1 addition & 0 deletions webapp/rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Loading