From e42c0ec1237087326f4074421dfd1fd1b15d0204 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Fri, 3 Jan 2020 00:02:22 -0800 Subject: [PATCH 1/6] Clean up existing CI --- .github/workflows/rust.yml | 9 ++------- .github/workflows/rustfmt.yml | 7 +++---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 23536c16..8c9175b9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -34,11 +34,6 @@ jobs: path: target key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} - - name: Check - run: cargo check --all-features + - run: cargo check --all-features - - name: Build - run: cargo build --all-features - - - name: Unit Test - run: cargo test -p sqlx-core --all-features + - run: cargo test -p sqlx-core --all-features diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml index 9bae972d..571ee5d0 100644 --- a/.github/workflows/rustfmt.yml +++ b/.github/workflows/rustfmt.yml @@ -1,14 +1,13 @@ -name: Rust Format +name: Format on: [push] jobs: - build: + check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - name: Check Format - run: cargo fmt -- --check + - run: cargo fmt -- --check From 0b6be44fc0abc088965df4a022194c64f295388b Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Fri, 3 Jan 2020 00:02:34 -0800 Subject: [PATCH 2/6] Add initial CI workflow for Postgres --- .github/workflows/mariadb.yml | 55 +++++++++++++++++++++++++++++++++ .github/workflows/postgres.yml | 56 ++++++++++++++++++++++++++++++++++ .github/workflows/rust.yml | 16 +++++++--- 3 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/mariadb.yml create mode 100644 .github/workflows/postgres.yml diff --git a/.github/workflows/mariadb.yml b/.github/workflows/mariadb.yml new file mode 100644 index 00000000..bd76cdee --- /dev/null +++ b/.github/workflows/mariadb.yml @@ -0,0 +1,55 @@ +name: MariaDB + +on: [push] + +jobs: + test: + + runs-on: ubuntu-latest + + strategy: + matrix: + mariadb: [10.1.43, 10.4.11] + + services: + mariadb: + image: mariadb:${{ matrix.mariadb }} + env: + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: sqlx + ports: + # will assign a random free host port + - 3309/tcp + # needed because the container does not provide a healthcheck + options: --health-cmd "mysqladmin ping -h localhost" --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - uses: actions/checkout@v1 + + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-mysql-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-mysql-cargo-index-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo build + uses: actions/cache@v1 + with: + path: target + key: ${{ runner.os }}-mysql-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} + + - name: Setup rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - run: cargo test -p sqlx --no-default-features --features 'mysql macros chrono' + env: + DATABASE_URL: mariadb://root:password@localhost:${{ job.services.mariadb.ports[3309] }}/sqlx diff --git a/.github/workflows/postgres.yml b/.github/workflows/postgres.yml new file mode 100644 index 00000000..a8f9a0a6 --- /dev/null +++ b/.github/workflows/postgres.yml @@ -0,0 +1,56 @@ +name: Postgres + +on: [push] + +jobs: + test: + + runs-on: ubuntu-latest + + strategy: + matrix: + postgres: [9.4.25, 10.11, 12.1] + + services: + postgres: + image: postgres:${{ matrix.postgres }} + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + ports: + # will assign a random free host port + - 5432/tcp + # needed because the postgres container does not provide a healthcheck + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - uses: actions/checkout@v1 + + - name: Setup rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-postgres-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-postgres-cargo-index-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo build + uses: actions/cache@v1 + with: + path: target + key: ${{ runner.os }}-postgres-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} + + - run: cargo test -p sqlx --no-default-features --features 'postgres macros uuid chrono' + env: + DATABASE_URL: postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 8c9175b9..458072c9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -10,11 +10,12 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Setup rust - uses: actions-rs/toolchain@v1 + - name: Cache rust + id: cache_rust + uses: actions/cache@v1 with: - toolchain: stable - override: true + path: ~/.rustup/toolchains + key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }} - name: Cache cargo registry uses: actions/cache@v1 @@ -34,6 +35,13 @@ jobs: path: target key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} + - name: Setup rust + uses: actions-rs/toolchain@v1 + if: steps.cache_rust.outputs.cache-hit != 'true' + with: + toolchain: stable + override: true + - run: cargo check --all-features - run: cargo test -p sqlx-core --all-features From 8c92a179ca93ee252a5ace3714a3c4e2053026d5 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Fri, 3 Jan 2020 17:54:43 -0800 Subject: [PATCH 3/6] Fix health command for MariaDB --- .github/workflows/mariadb.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mariadb.yml b/.github/workflows/mariadb.yml index bd76cdee..41a4dff3 100644 --- a/.github/workflows/mariadb.yml +++ b/.github/workflows/mariadb.yml @@ -21,7 +21,7 @@ jobs: # will assign a random free host port - 3309/tcp # needed because the container does not provide a healthcheck - options: --health-cmd "mysqladmin ping -h localhost" --health-interval 10s --health-timeout 5s --health-retries 5 + options: --health-cmd "mysql --user=root --password=$MYSQL_PASSWORD -e 'show databases;'" --health-interval 10s --health-timeout 5s --health-retries 5 steps: - uses: actions/checkout@v1 From 2cc2fd5700d8229ba602ac99b3a226530015e8d8 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Fri, 3 Jan 2020 17:58:01 -0800 Subject: [PATCH 4/6] MariaDB takes longer to start than Postgres --- .github/workflows/mariadb.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mariadb.yml b/.github/workflows/mariadb.yml index 41a4dff3..6369f836 100644 --- a/.github/workflows/mariadb.yml +++ b/.github/workflows/mariadb.yml @@ -21,7 +21,7 @@ jobs: # will assign a random free host port - 3309/tcp # needed because the container does not provide a healthcheck - options: --health-cmd "mysql --user=root --password=$MYSQL_PASSWORD -e 'show databases;'" --health-interval 10s --health-timeout 5s --health-retries 5 + options: --health-cmd "mysql --user=root --password=$MYSQL_PASSWORD -e 'show databases;'" --health-interval 30s --health-timeout 30s --health-retries 10 steps: - uses: actions/checkout@v1 From cec532acb15b5895e5cf93fee19e61b9fdfc19cc Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Fri, 3 Jan 2020 17:59:23 -0800 Subject: [PATCH 5/6] Fix port reference for MariaDB --- .github/workflows/mariadb.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mariadb.yml b/.github/workflows/mariadb.yml index 6369f836..bd208d8c 100644 --- a/.github/workflows/mariadb.yml +++ b/.github/workflows/mariadb.yml @@ -19,7 +19,7 @@ jobs: MYSQL_DATABASE: sqlx ports: # will assign a random free host port - - 3309/tcp + - 3306/tcp # needed because the container does not provide a healthcheck options: --health-cmd "mysql --user=root --password=$MYSQL_PASSWORD -e 'show databases;'" --health-interval 30s --health-timeout 30s --health-retries 10 @@ -52,4 +52,4 @@ jobs: - run: cargo test -p sqlx --no-default-features --features 'mysql macros chrono' env: - DATABASE_URL: mariadb://root:password@localhost:${{ job.services.mariadb.ports[3309] }}/sqlx + DATABASE_URL: mariadb://root:password@localhost:${{ job.services.mariadb.ports[3306] }}/sqlx From 77fbe3dd9e962ef863171f19624d212eca012557 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Fri, 3 Jan 2020 18:01:52 -0800 Subject: [PATCH 6/6] Try a different health check for MariaDB --- .github/workflows/mariadb.yml | 2 +- .github/workflows/mysql.yml | 55 +++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/mysql.yml diff --git a/.github/workflows/mariadb.yml b/.github/workflows/mariadb.yml index bd208d8c..a9dc5c02 100644 --- a/.github/workflows/mariadb.yml +++ b/.github/workflows/mariadb.yml @@ -21,7 +21,7 @@ jobs: # will assign a random free host port - 3306/tcp # needed because the container does not provide a healthcheck - options: --health-cmd "mysql --user=root --password=$MYSQL_PASSWORD -e 'show databases;'" --health-interval 30s --health-timeout 30s --health-retries 10 + options: --health-cmd "mysqladmin ping --silent" --health-interval 30s --health-timeout 30s --health-retries 10 steps: - uses: actions/checkout@v1 diff --git a/.github/workflows/mysql.yml b/.github/workflows/mysql.yml new file mode 100644 index 00000000..8e54dff8 --- /dev/null +++ b/.github/workflows/mysql.yml @@ -0,0 +1,55 @@ +name: MySQL + +on: [push] + +jobs: + test: + + runs-on: ubuntu-latest + + strategy: + matrix: + mysql: [5.7.28, 8.0.18] + + services: + mysql: + image: mysql:${{ matrix.mysql }} + env: + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: sqlx + ports: + # will assign a random free host port + - 3306/tcp + # needed because the container does not provide a healthcheck + options: --health-cmd "mysqladmin ping --silent" --health-interval 30s --health-timeout 30s --health-retries 10 + + steps: + - uses: actions/checkout@v1 + + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-mysql-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-mysql-cargo-index-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo build + uses: actions/cache@v1 + with: + path: target + key: ${{ runner.os }}-mysql-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} + + - name: Setup rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - run: cargo test -p sqlx --no-default-features --features 'mysql macros chrono' + env: + DATABASE_URL: mysql://root:password@localhost:${{ job.services.mysql.ports[3306] }}/sqlx