Skip to content

Commit

Permalink
try add reuse about workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
flaneur2020 committed Dec 2, 2021
1 parent 88c467e commit c8939fb
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 79 deletions.
23 changes: 23 additions & 0 deletions .github/actions/cache-cargo-registry/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'Cache cargo registry'
description: 'Cache the cargo registry'
inputs:
cache_reset_key:
description: 'the key for cargo cache'
required: true
runs:
using: "composite"
steps:
- name: Cache cargo registry
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-buildcache-${{ inputs.cache_reset_key }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-buildcache-${{ inputs.cache_reset_key }}-
${{ runner.os }}-cargo-buildcache-
${{ runner.os }}-cargo-
12 changes: 12 additions & 0 deletions .github/actions/setup-rust/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: 'Setup rust'
description: 'Setup rust environment for databend'
runs:
using: "composite"
steps:
- name: Install Protoc
uses: arduino/setup-protoc@v1

- name: Rust setup
shell: bash
run: |
bash ./scripts/setup/dev_setup.sh
22 changes: 3 additions & 19 deletions .github/workflows/databend-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,11 @@ jobs:
file_or_dir: ./
config_file: .yamllint.yml

- name: Install Protoc
uses: arduino/setup-protoc@v1
- uses: ./.github/actions/setup-rust

- name: Rust setup
run: |
bash ./scripts/setup/dev_setup.sh
- name: Cache cargo registry
uses: actions/cache@v2
- uses: ./.github/actions/cache-cargo-registry
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-basecache-${{ secrets.CACHE_RESET_KEY }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-basecache-${{ secrets.CACHE_RESET_KEY }}-
${{ runner.os }}-cargo-basecache-
${{ runner.os }}-cargo-
cache_reset_key: ${{ secrets.CACHE_RESET_KEY }}

- name: Run clippy
uses: actions-rs/cargo@v1
Expand Down
21 changes: 3 additions & 18 deletions .github/workflows/stateful-tests-standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Install Protoc
uses: arduino/setup-protoc@v1
- uses: ./.github/actions/setup-rust

- name: Rust setup
run: |
bash ./scripts/setup/dev_setup.sh -o -t
- name: Cache cargo registry
uses: actions/cache@v2
- uses: ./.github/actions/cache-cargo-registry
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-buildcache-${{ secrets.CACHE_RESET_KEY }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-buildcache-${{ secrets.CACHE_RESET_KEY }}-
${{ runner.os }}-cargo-buildcache-
${{ runner.os }}-cargo-
cache_reset_key: ${{ secrets.CACHE_RESET_KEY }}

- name: Build
run: cargo build --verbose
Expand Down
21 changes: 3 additions & 18 deletions .github/workflows/stateless-tests-cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,11 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v2

- name: Install Protoc
uses: arduino/setup-protoc@v1
- uses: ./.github/actions/setup-rust

- name: Rust setup
run: |
bash ./scripts/setup/dev_setup.sh -o -t
- name: Cache cargo registry
uses: actions/cache@v2
- uses: ./.github/actions/cache-cargo-registry
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-buildcache-${{ secrets.CACHE_RESET_KEY }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-buildcache-${{ secrets.CACHE_RESET_KEY }}-
${{ runner.os }}-cargo-buildcache-
${{ runner.os }}-cargo-
cache_reset_key: ${{ secrets.CACHE_RESET_KEY }}

- name: Build
run: cargo build --verbose
Expand Down
21 changes: 3 additions & 18 deletions .github/workflows/stateless-tests-standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Install Protoc
uses: arduino/setup-protoc@v1
- uses: ./.github/actions/setup-rust

- name: Rust setup
run: |
bash ./scripts/setup/dev_setup.sh -o -t
- name: Cache cargo registry
uses: actions/cache@v2
- uses: ./.github/actions/cache-cargo-registry
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-buildcache-${{ secrets.CACHE_RESET_KEY }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-buildcache-${{ secrets.CACHE_RESET_KEY }}-
${{ runner.os }}-cargo-buildcache-
${{ runner.os }}-cargo-
cache_reset_key: ${{ secrets.CACHE_RESET_KEY }}

- name: Build
run: cargo build --verbose
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v2

- name: Install Protoc
uses: arduino/setup-protoc@v1

- name: Rust setup
run: |
bash ./scripts/setup/dev_setup.sh
- uses: ./.github/actions/setup-rust

- name: Cache Rust
uses: Swatinem/rust-cache@v1
Expand Down

0 comments on commit c8939fb

Please sign in to comment.