Skip to content

Commit

Permalink
chore: test macros' offline mode in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
abonander committed Apr 8, 2022
1 parent 3fee232 commit 4c2ef77
Showing 1 changed file with 159 additions and 6 deletions.
165 changes: 159 additions & 6 deletions .github/workflows/sqlx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,47 @@ jobs:
target
key: ${{ runner.os }}-sqlite-${{ matrix.runtime }}-${{ matrix.tls }}-${{ hashFiles('**/Cargo.lock') }}

# Create data dir for offline mode
- run: mkdir .sqlx

- uses: actions-rs/cargo@v1
with:
command: test
args: >
--no-default-features
--features any,macros,migrate,sqlite,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
--
--test-threads=1
env:
DATABASE_URL: sqlite://tests/sqlite/sqlite.db

# Remove test artifacts
- run: cargo clean -p sqlx

# Build the macros-test in offline mode (omit DATABASE_URL)
- uses: actions-rs/cargo@v1
with:
command: build
args: >
--no-default-features
--test sqlite-macros
--features any,macros,migrate,sqlite,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
env:
SQLX_OFFLINE: true

# Test macros in offline mode (still needs DATABASE_URL to run)
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--no-default-features
--features any,macros,migrate,sqlite,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
--test sqlite-macros
--features any,macros,migrate,sqlite,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
--
--test-threads=1
env:
DATABASE_URL: sqlite://tests/sqlite/sqlite.db
SQLX_OFFLINE: true

postgres:
name: Postgres
Expand Down Expand Up @@ -207,6 +238,9 @@ jobs:
target
key: ${{ runner.os }}-postgres-${{ matrix.runtime }}-${{ matrix.tls }}-${{ hashFiles('**/Cargo.lock') }}

# Create data dir for offline mode
- run: mkdir .sqlx

- uses: actions-rs/cargo@v1
env:
# FIXME: needed to disable `ltree` tests in Postgres 9.6
Expand All @@ -226,7 +260,7 @@ jobs:
command: test
args: >
--no-default-features
--features any,postgres,macros,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
--features any,postgres,macros,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
# FIXME: needed to disable `ltree` tests in Postgres 9.6
Expand All @@ -238,13 +272,45 @@ jobs:
command: test
args: >
--no-default-features
--features any,postgres,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
--features any,postgres,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx?sslmode=verify-ca&sslrootcert=.%2Ftests%2Fcerts%2Fca.crt
# FIXME: needed to disable `ltree` tests in Postgres 9.6
# but `PgLTree` should just fall back to text format
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}

# Remove test artifacts
- run: cargo clean -p sqlx

# Build the macros-test in offline mode (omit DATABASE_URL)
- uses: actions-rs/cargo@v1
with:
command: build
args: >
--no-default-features
--test postgres-macros
--features any,postgres,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
env:
SQLX_OFFLINE: true
# FIXME: needed to disable `ltree` tests in Postgres 9.6
# but `PgLTree` should just fall back to text format
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}

# Test macros in offline mode (still needs DATABASE_URL to run)
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--no-default-features
--test postgres-macros
--features any,postgres,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
SQLX_OFFLINE: true
# FIXME: needed to disable `ltree` tests in Postgres 9.6
# but `PgLTree` should just fall back to text format
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}

mysql:
name: MySQL
runs-on: ubuntu-20.04
Expand All @@ -271,6 +337,9 @@ jobs:
target
key: ${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}-${{ hashFiles('**/Cargo.lock') }}

# Create data dir for offline mode
- run: mkdir .sqlx

- uses: actions-rs/cargo@v1
with:
command: build
Expand All @@ -285,10 +354,36 @@ jobs:
command: test
args: >
--no-default-features
--features any,mysql,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
--features any,mysql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
env:
DATABASE_URL: mysql://root:password@localhost:3306/sqlx

# Remove test artifacts
- run: cargo clean -p sqlx

# Build the macros-test in offline mode (omit DATABASE_URL)
- uses: actions-rs/cargo@v1
with:
command: build
args: >
--no-default-features
--test mysql-macros
--features any,mysql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
env:
SQLX_OFFLINE: true

# Test macros in offline mode (still needs DATABASE_URL to run)
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--no-default-features
--test mysql-macros
--features any,mysql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
env:
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
SQLX_OFFLINE: true

mariadb:
name: MariaDB
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -316,6 +411,9 @@ jobs:
target
key: ${{ runner.os }}-mysql-${{ matrix.runtime }}-${{ matrix.tls }}-${{ hashFiles('**/Cargo.lock') }}

# Create data dir for offline mode
- run: mkdir .sqlx

- uses: actions-rs/cargo@v1
with:
command: build
Expand All @@ -330,9 +428,35 @@ jobs:
command: test
args: >
--no-default-features
--features any,mysql,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
--features any,mysql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
env:
DATABASE_URL: mysql://root:password@localhost:3306/sqlx

# Remove test artifacts
- run: cargo clean -p sqlx

# Build the macros-test in offline mode (omit DATABASE_URL)
- uses: actions-rs/cargo@v1
with:
command: build
args: >
--no-default-features
--test mysql-macros
--features any,mysql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
env:
SQLX_OFFLINE: true

# Test macros in offline mode (still needs DATABASE_URL to run)
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--no-default-features
--test mysql-macros
--features any,mysql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
env:
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
SQLX_OFFLINE: true

mssql:
name: MSSQL
Expand Down Expand Up @@ -360,6 +484,9 @@ jobs:
target
key: ${{ runner.os }}-mssql-${{ matrix.runtime }}-${{ matrix.tls }}-${{ hashFiles('**/Cargo.lock') }}

# Create data dir for offline mode
- run: mkdir .sqlx

- uses: actions-rs/cargo@v1
with:
command: build
Expand All @@ -374,6 +501,32 @@ jobs:
command: test
args: >
--no-default-features
--features any,mssql,macros,migrate,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
--features any,mssql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
env:
DATABASE_URL: mssql://sa:Password123!@localhost/sqlx

# Remove test artifacts
- run: cargo clean -p sqlx

# Build the macros-test in offline mode (omit DATABASE_URL)
- uses: actions-rs/cargo@v1
with:
command: build
args: >
--no-default-features
--test mssql-macros
--features any,mssql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
env:
SQLX_OFFLINE: true

# Test macros in offline mode (still needs DATABASE_URL to run)
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--no-default-features
--test mssql-macros
--features any,mssql,macros,migrate,all-types,offline,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
env:
DATABASE_URL: mssql://sa:Password123!@localhost/sqlx
SQLX_OFFLINE: true

0 comments on commit 4c2ef77

Please sign in to comment.