From 95e7a7455961b5914a3ca323c025f53be5e0da68 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Wed, 11 May 2022 13:14:17 +0530 Subject: [PATCH] feat: setup CI to use .env_sample and postgres URI --- .env_sample | 2 +- .github/workflows/coverage.yml | 10 ++++++++-- .github/workflows/linux.yml | 14 ++++++++++---- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.env_sample b/.env_sample index 4aeb11c2..a5a10b0a 100644 --- a/.env_sample +++ b/.env_sample @@ -1 +1 @@ -export POSTGRES_DATABASE_URL="" +export POSTGRES_DATABASE_URL="postgres://postgres:password@localhost:5432/postgres" diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 624a0d41..b8a301a7 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -51,6 +51,12 @@ jobs: target key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: load env + run: | + source .env-sample \ + && echo "POSTGRES_DATABASE_URL=$POSTGRES_DATABASE_URL" >> $GITHUB_ENV + - uses: actions/setup-node@v2 with: node-version: "16.x" @@ -74,7 +80,7 @@ jobs: - name: Run migrations run: make migrate env: - DATABASE_URL: postgres://postgres:password@localhost:5432/postgres + POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}" - name: build frontend run: make frontend @@ -85,7 +91,7 @@ jobs: with: args: "-t 1200" env: - DATABASE_URL: postgres://postgres:password@localhost:5432/postgres + POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}" # 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 diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index c8e2a4b5..7fe7c8dd 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -55,6 +55,12 @@ jobs: target key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: load env + run: | + source .env-sample \ + && echo "POSTGRES_DATABASE_URL=$POSTGRES_DATABASE_URL" >> $GITHUB_ENV + - uses: actions/setup-node@v2 with: node-version: '16.x' @@ -72,12 +78,12 @@ jobs: - name: Run migrations run: make migrate env: - DATABASE_URL: postgres://postgres:password@localhost:5432/postgres + POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}" - name: build run: make env: - DATABASE_URL: postgres://postgres:password@localhost:5432/postgres + POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}" # - name: build frontend # run: make frontend @@ -88,13 +94,13 @@ jobs: - name: run tests run: make test env: - DATABASE_URL: postgres://postgres:password@localhost:5432/postgres + POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}" - name: generate documentation if: matrix.version == 'stable' && (github.repository == 'mCaptcha/mCaptcha') run: make doc env: - DATABASE_URL: postgres://postgres:password@localhost:5432/postgres + POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}" GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value COMPILED_DATE: "2021-07-21"