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