mirror of https://github.com/realaravinth/gitpad
feat: CI: run tests against DB
parent
e10451f01f
commit
4858f050e7
|
@ -15,6 +15,21 @@ jobs:
|
|||
version:
|
||||
- stable
|
||||
|
||||
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
|
||||
|
||||
name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
|
@ -36,18 +51,25 @@ jobs:
|
|||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: load env
|
||||
run: |
|
||||
source .env-sample \
|
||||
&& echo "POSTGRES_DATABASE_URL=$POSTGRES_DATABASE_URL" >> $GITHUB_ENV \
|
||||
&& echo "SQLITE_DATABASE_URL=$SQLITE_DATABASE_URL" >> $GITHUB_ENV
|
||||
|
||||
- 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:
|
||||
version: '0.18.2'
|
||||
args: '-t 1200'
|
||||
env:
|
||||
# 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
|
||||
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61
|
||||
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||
SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||
with:
|
||||
args: "--all-features --no-fail-fast --workspace=database/db-sqlx-postgres,. -t 1200"
|
||||
|
||||
- name: Upload to Codecov
|
||||
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
|
||||
uses: codecov/codecov-action@v1
|
||||
uses: codecov/codecov-action@v2
|
||||
|
|
|
@ -19,6 +19,21 @@ 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
|
||||
|
@ -29,7 +44,8 @@ jobs:
|
|||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
key:
|
||||
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
# - name: Login to DockerHub
|
||||
# if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/gists'
|
||||
|
@ -45,11 +61,17 @@ jobs:
|
|||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: load env
|
||||
run: |
|
||||
source .env-sample \
|
||||
&& echo "POSTGRES_DATABASE_URL=$POSTGRES_DATABASE_URL" >> $GITHUB_ENV \
|
||||
&& echo "SQLITE_DATABASE_URL=$SQLITE_DATABASE_URL" >> $GITHUB_ENV
|
||||
|
||||
- name: build
|
||||
run: make
|
||||
|
||||
- name: run tests
|
||||
run: make test
|
||||
env:
|
||||
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||
SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||
|
||||
# - name: build docker images
|
||||
# if: matrix.version == 'stable'
|
||||
|
@ -59,11 +81,28 @@ jobs:
|
|||
# if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/gists'
|
||||
# run: make docker-publish
|
||||
|
||||
- name: run migrations
|
||||
run: make migrate
|
||||
env:
|
||||
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||
SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||
|
||||
- name: run tests
|
||||
timeout-minutes: 40
|
||||
run: make test
|
||||
env:
|
||||
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||
SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||
|
||||
- name: generate documentation
|
||||
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/gists'
|
||||
run: make doc
|
||||
env:
|
||||
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||
SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/gists'
|
||||
|
|
Loading…
Reference in New Issue