feat: setup CI with database service
This commit is contained in:
parent
8150aa9ca1
commit
6e38497bbb
7 changed files with 1055 additions and 5 deletions
22
.github/workflows/coverage.yml
vendored
22
.github/workflows/coverage.yml
vendored
|
@ -20,6 +20,22 @@ jobs:
|
|||
name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
|
||||
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:
|
||||
- uses: actions/checkout@v2
|
||||
- name: ⚡ Cache
|
||||
|
@ -38,12 +54,18 @@ jobs:
|
|||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: Apply migrations
|
||||
run: make migrate
|
||||
env:
|
||||
DATABASE_URL: "postgres://postgres:password@localhost:5432/postgres"
|
||||
|
||||
- name: Generate coverage file
|
||||
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
|
||||
uses: actions-rs/tarpaulin@v0.1
|
||||
with:
|
||||
args: '-t 1200'
|
||||
env:
|
||||
DATABASE_URL: "postgres://postgres:password@localhost:5432/postgres"
|
||||
# GIT_HASH is dummy value. I guess build.rs is skipped in tarpaulin
|
||||
# execution so this value is required for preventing meta tests from
|
||||
# panicking
|
||||
|
|
26
.github/workflows/linux.yml
vendored
26
.github/workflows/linux.yml
vendored
|
@ -22,6 +22,22 @@ jobs:
|
|||
name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
|
||||
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:
|
||||
- uses: actions/checkout@v2
|
||||
- name: ⚡ Cache
|
||||
|
@ -54,11 +70,15 @@ jobs:
|
|||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: build
|
||||
run: make
|
||||
- name: build and apply migrations
|
||||
run: make migrate
|
||||
env:
|
||||
DATABASE_URL="postgres://postgres:password@localhost:5432/postgres"
|
||||
|
||||
- name: run tests
|
||||
run: make test
|
||||
env:
|
||||
DATABASE_URL: "postgres://postgres:password@localhost:5432/postgres"
|
||||
|
||||
- name: make docker images
|
||||
run: make docker
|
||||
|
@ -79,6 +99,8 @@ jobs:
|
|||
run: make doc
|
||||
env:
|
||||
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||
DATABASE_URL: "postgres://postgres:password@localhost:5432/postgres"
|
||||
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
if: matrix.version == 'stable' && (github.repository == 'realaravinth/librepages')
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
/target
|
||||
tarpaulin-report.html
|
||||
.env
|
||||
.env.local
|
||||
|
|
995
Cargo.lock
generated
995
Cargo.lock
generated
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-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" }
|
||||
|
||||
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"
|
||||
git2 = "0.14.2"
|
||||
|
|
9
Makefile
9
Makefile
|
@ -32,12 +32,21 @@ lint: ## Lint codebase
|
|||
cargo fmt -v --all -- --emit files
|
||||
cargo clippy --workspace --tests --all-features
|
||||
|
||||
migrate: ## run migrations
|
||||
unset DATABASE_URL && cargo build
|
||||
cargo run -- migrate
|
||||
|
||||
release: ## Release build
|
||||
cargo build --release
|
||||
|
||||
run: default ## Run debug build
|
||||
cargo run
|
||||
|
||||
sqlx-offline-data: ## prepare sqlx offline data
|
||||
cargo sqlx prepare \
|
||||
--database-url=${DATABASE_URL} -- \
|
||||
--all-features
|
||||
|
||||
test: ## Run tests
|
||||
cargo test --all-features --no-fail-fast
|
||||
|
||||
|
|
3
sqlx-data.json
Normal file
3
sqlx-data.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"db": "PostgreSQL"
|
||||
}
|
Loading…
Reference in a new issue