feat: setup CI with database service
This commit is contained in:
parent
8150aa9ca1
commit
6e38497bbb
|
@ -20,6 +20,22 @@ jobs:
|
||||||
name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
|
name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres
|
||||||
|
env:
|
||||||
|
POSTGRES_PASSWORD: password
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_DB: postgres
|
||||||
|
options: >-
|
||||||
|
--health-cmd pg_isready
|
||||||
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 5
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: ⚡ Cache
|
- name: ⚡ Cache
|
||||||
|
@ -38,12 +54,18 @@ jobs:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
override: true
|
override: true
|
||||||
|
|
||||||
|
- name: Apply migrations
|
||||||
|
run: make migrate
|
||||||
|
env:
|
||||||
|
DATABASE_URL: "postgres://postgres:password@localhost:5432/postgres"
|
||||||
|
|
||||||
- name: Generate coverage file
|
- name: Generate coverage file
|
||||||
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
|
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
|
||||||
uses: actions-rs/tarpaulin@v0.1
|
uses: actions-rs/tarpaulin@v0.1
|
||||||
with:
|
with:
|
||||||
args: '-t 1200'
|
args: '-t 1200'
|
||||||
env:
|
env:
|
||||||
|
DATABASE_URL: "postgres://postgres:password@localhost:5432/postgres"
|
||||||
# GIT_HASH is dummy value. I guess build.rs is skipped in tarpaulin
|
# GIT_HASH is dummy value. I guess build.rs is skipped in tarpaulin
|
||||||
# execution so this value is required for preventing meta tests from
|
# execution so this value is required for preventing meta tests from
|
||||||
# panicking
|
# panicking
|
||||||
|
|
|
@ -22,6 +22,22 @@ jobs:
|
||||||
name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
|
name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres
|
||||||
|
env:
|
||||||
|
POSTGRES_PASSWORD: password
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_DB: postgres
|
||||||
|
options: >-
|
||||||
|
--health-cmd pg_isready
|
||||||
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 5
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: ⚡ Cache
|
- name: ⚡ Cache
|
||||||
|
@ -54,11 +70,15 @@ jobs:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
override: true
|
override: true
|
||||||
|
|
||||||
- name: build
|
- name: build and apply migrations
|
||||||
run: make
|
run: make migrate
|
||||||
|
env:
|
||||||
|
DATABASE_URL="postgres://postgres:password@localhost:5432/postgres"
|
||||||
|
|
||||||
- name: run tests
|
- name: run tests
|
||||||
run: make test
|
run: make test
|
||||||
|
env:
|
||||||
|
DATABASE_URL: "postgres://postgres:password@localhost:5432/postgres"
|
||||||
|
|
||||||
- name: make docker images
|
- name: make docker images
|
||||||
run: make docker
|
run: make docker
|
||||||
|
@ -79,6 +99,8 @@ jobs:
|
||||||
run: make doc
|
run: make doc
|
||||||
env:
|
env:
|
||||||
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||||
|
DATABASE_URL: "postgres://postgres:password@localhost:5432/postgres"
|
||||||
|
|
||||||
|
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
if: matrix.version == 'stable' && (github.repository == 'realaravinth/librepages')
|
if: matrix.version == 'stable' && (github.repository == 'realaravinth/librepages')
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
/target
|
/target
|
||||||
tarpaulin-report.html
|
tarpaulin-report.html
|
||||||
.env
|
.env
|
||||||
|
.env.local
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -17,7 +17,9 @@ actix-web = "4.0.1"
|
||||||
actix-http = "3.0.4"
|
actix-http = "3.0.4"
|
||||||
actix-rt = "2"
|
actix-rt = "2"
|
||||||
actix-web-codegen-const-routes = { version = "0.1.0", tag = "0.1.0", git = "https://github.com/realaravinth/actix-web-codegen-const-routes" }
|
actix-web-codegen-const-routes = { version = "0.1.0", tag = "0.1.0", git = "https://github.com/realaravinth/actix-web-codegen-const-routes" }
|
||||||
|
argon2-creds = { branch = "master", git = "https://github.com/realaravinth/argon2-creds"}
|
||||||
|
sqlx = { version = "0.6.1", features = [ "runtime-actix-rustls", "postgres", "time", "offline", "json"] }
|
||||||
|
clap = { vesrion = "3.2.20", features = ["derive"]}
|
||||||
|
|
||||||
config = "0.13"
|
config = "0.13"
|
||||||
git2 = "0.14.2"
|
git2 = "0.14.2"
|
||||||
|
|
9
Makefile
9
Makefile
|
@ -32,12 +32,21 @@ lint: ## Lint codebase
|
||||||
cargo fmt -v --all -- --emit files
|
cargo fmt -v --all -- --emit files
|
||||||
cargo clippy --workspace --tests --all-features
|
cargo clippy --workspace --tests --all-features
|
||||||
|
|
||||||
|
migrate: ## run migrations
|
||||||
|
unset DATABASE_URL && cargo build
|
||||||
|
cargo run -- migrate
|
||||||
|
|
||||||
release: ## Release build
|
release: ## Release build
|
||||||
cargo build --release
|
cargo build --release
|
||||||
|
|
||||||
run: default ## Run debug build
|
run: default ## Run debug build
|
||||||
cargo run
|
cargo run
|
||||||
|
|
||||||
|
sqlx-offline-data: ## prepare sqlx offline data
|
||||||
|
cargo sqlx prepare \
|
||||||
|
--database-url=${DATABASE_URL} -- \
|
||||||
|
--all-features
|
||||||
|
|
||||||
test: ## Run tests
|
test: ## Run tests
|
||||||
cargo test --all-features --no-fail-fast
|
cargo test --all-features --no-fail-fast
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"db": "PostgreSQL"
|
||||||
|
}
|
Loading…
Reference in New Issue