From fe827a3337b7e9ef87c45f3ca94a8b6050b9a081 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Mon, 6 Jan 2020 23:55:11 -0800 Subject: [PATCH] Tweak CI and enable for PRs * Tweak cache strategy for Rust * Tweak cache strategy some more * ci: trigger * Tweak the rest of the CI tasks --- .github/workflows/mariadb.yml | 48 ++++++++++++++++++-------------- .github/workflows/mysql.yml | 48 ++++++++++++++++++-------------- .github/workflows/postgres.yml | 42 ++++++++++++++++------------ .github/workflows/rust.yml | 50 +++++++++++++++++----------------- .github/workflows/rustfmt.yml | 8 ++++-- 5 files changed, 112 insertions(+), 84 deletions(-) diff --git a/.github/workflows/mariadb.yml b/.github/workflows/mariadb.yml index a9dc5c02..a8421fad 100644 --- a/.github/workflows/mariadb.yml +++ b/.github/workflows/mariadb.yml @@ -1,9 +1,13 @@ name: MariaDB -on: [push] +on: + pull_request: + push: + branches: + - master jobs: - test: + mariadb: runs-on: ubuntu-latest @@ -26,30 +30,34 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Cache cargo registry - uses: actions/cache@v1 + # Rust ------------------------------------------------ + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + if: steps.cache_rust.outputs.cache-hit != 'true' 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 + toolchain: stable + profile: minimal + override: true + + - name: Cache target/ uses: actions/cache@v1 with: path: target - key: ${{ runner.os }}-mysql-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-build-target-mariadb-${{ 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[3306] }}/sqlx + + # Rust ------------------------------------------------ + + - name: Prepare build directory for cache + run: | + find ./target/debug -maxdepth 1 -type f -delete \ + && rm -fr ./target/debug/{deps,.fingerprint}/*sqlx* \ + && rm -f ./target/.rustc_info.json + + # ----------------------------------------------------- diff --git a/.github/workflows/mysql.yml b/.github/workflows/mysql.yml index 8e54dff8..97cd9b09 100644 --- a/.github/workflows/mysql.yml +++ b/.github/workflows/mysql.yml @@ -1,9 +1,13 @@ name: MySQL -on: [push] +on: + pull_request: + push: + branches: + - master jobs: - test: + mysql: runs-on: ubuntu-latest @@ -26,30 +30,34 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Cache cargo registry - uses: actions/cache@v1 + # Rust ------------------------------------------------ + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + if: steps.cache_rust.outputs.cache-hit != 'true' 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 + toolchain: stable + profile: minimal + override: true + + - name: Cache target/ uses: actions/cache@v1 with: path: target - key: ${{ runner.os }}-mysql-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-build-target-mysql-${{ 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 + + # Rust ------------------------------------------------ + + - name: Prepare build directory for cache + run: | + find ./target/debug -maxdepth 1 -type f -delete \ + && rm -fr ./target/debug/{deps,.fingerprint}/*sqlx* \ + && rm -f ./target/.rustc_info.json + + # ----------------------------------------------------- diff --git a/.github/workflows/postgres.yml b/.github/workflows/postgres.yml index a8f9a0a6..6eca7eb6 100644 --- a/.github/workflows/postgres.yml +++ b/.github/workflows/postgres.yml @@ -1,9 +1,13 @@ name: Postgres -on: [push] +on: + pull_request: + push: + branches: + - master jobs: - test: + postgres: runs-on: ubuntu-latest @@ -27,30 +31,34 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Setup rust + # Rust ------------------------------------------------ + + - name: Install Rust toolchain uses: actions-rs/toolchain@v1 + if: steps.cache_rust.outputs.cache-hit != 'true' with: toolchain: stable + profile: minimal 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 + - name: Cache target/ uses: actions/cache@v1 with: path: target - key: ${{ runner.os }}-postgres-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-build-target-postgres-${{ 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 + + # Rust ------------------------------------------------ + + - name: Prepare build directory for cache + run: | + find ./target/debug -maxdepth 1 -type f -delete \ + && rm -fr ./target/debug/{deps,.fingerprint}/*sqlx* \ + && rm -f ./target/.rustc_info.json + + # ----------------------------------------------------- diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 458072c9..1af5892a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,6 +1,10 @@ name: Rust -on: [push] +on: + pull_request: + push: + branches: + - master jobs: build: @@ -10,38 +14,34 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Cache rust - id: cache_rust - uses: actions/cache@v1 - with: - path: ~/.rustup/toolchains - key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }} + # Rust ------------------------------------------------ - - name: Cache cargo registry - uses: actions/cache@v1 + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + if: steps.cache_rust.outputs.cache-hit != 'true' with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} - - - name: Cache cargo index - uses: actions/cache@v1 - with: - path: ~/.cargo/git - key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} - - - name: Cache cargo build + toolchain: stable + profile: minimal + override: true + + - name: Cache target/ uses: actions/cache@v1 with: 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 + + # Rust ------------------------------------------------ + + - name: Prepare build directory for cache + run: | + find ./target/debug -maxdepth 1 -type f -delete \ + && rm -fr ./target/debug/{deps,.fingerprint}/*sqlx* \ + && rm -f ./target/.rustc_info.json + + # ----------------------------------------------------- diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml index 571ee5d0..1e817346 100644 --- a/.github/workflows/rustfmt.yml +++ b/.github/workflows/rustfmt.yml @@ -1,9 +1,13 @@ name: Format -on: [push] +on: + pull_request: + push: + branches: + - master jobs: - check: + format: runs-on: ubuntu-latest