Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 60 additions & 16 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,48 +61,92 @@ jobs:
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: sync_test_db
POSTGRES_DB: replicant_server_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Install sqlx-cli
run: cargo install sqlx-cli --no-default-features --features postgres


- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo build
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

- name: Run migrations

# Set up Elixir/Phoenix server
- name: Clone Phoenix server
run: git clone --depth 1 https://github.com/replicant-sync/replicant-server.git /tmp/replicant-server

- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: '1.17'
otp-version: '27'

- name: Cache Elixir deps
uses: actions/cache@v3
with:
path: /tmp/replicant-server/deps
key: ${{ runner.os }}-mix-${{ hashFiles('/tmp/replicant-server/mix.lock') }}

- name: Install Phoenix dependencies
working-directory: /tmp/replicant-server
run: mix deps.get

- name: Set up Phoenix database
working-directory: /tmp/replicant-server
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/sync_test_db
DATABASE_URL: postgres://postgres:postgres@localhost:5432/replicant_server_test
SECRET_KEY_BASE: test-secret-key-base-that-is-at-least-64-characters-long-for-testing
run: |
cd replicant-server
sqlx migrate run

mix ecto.create
mix ecto.migrate

- name: Generate API credentials
id: credentials
working-directory: /tmp/replicant-server
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/replicant_server_test
SECRET_KEY_BASE: test-secret-key-base-that-is-at-least-64-characters-long-for-testing
run: |
OUTPUT=$(mix replicant.gen.credentials --name "CI Test")
API_KEY=$(echo "$OUTPUT" | grep "API Key:" | awk '{print $3}')
API_SECRET=$(echo "$OUTPUT" | grep "Secret:" | awk '{print $2}')
echo "api_key=$API_KEY" >> $GITHUB_OUTPUT
echo "api_secret=$API_SECRET" >> $GITHUB_OUTPUT

- name: Start Phoenix server
working-directory: /tmp/replicant-server
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/replicant_server_test
SECRET_KEY_BASE: test-secret-key-base-that-is-at-least-64-characters-long-for-testing
PHX_SERVER: true
run: |
mix phx.server &
sleep 5
curl -f http://localhost:4000/health || exit 1

- name: Run integration tests
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
RUN_INTEGRATION_TESTS: 1
run: cargo test integration --no-fail-fast -- --nocapture
REPLICANT_API_KEY: ${{ steps.credentials.outputs.api_key }}
REPLICANT_API_SECRET: ${{ steps.credentials.outputs.api_secret }}
run: cargo test --package replicant-client --test integration -- --nocapture

lint:
name: Lint
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading