Skip to content

Commit

Permalink
ci: support merge queue
Browse files Browse the repository at this point in the history
Signed-off-by: iGxnon <[email protected]>
  • Loading branch information
iGxnon committed Nov 24, 2023
1 parent 20f83df commit ceb59a7
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 160 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cache_clean.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: cleanup caches by a branch
name: Clean caches
on:
pull_request:
types:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ jobs:
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: codecov.info
fail_ci_if_error: true
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker
name: Push Docker Image

on:
workflow_dispatch: { }
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/gen_release_note.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Milestone Closure

# Trigger the workflow on milestone events
on:
milestone:
types: [closed]

name: Milestone Closure
jobs:
create-release-notes:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/merge_image.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Merge Multi-platform Image Manifests

on:
workflow_call:
inputs:
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/merge_queue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Validate Changes

on:
merge_group:
types: [checks_requested]

env:
XLINE_COMPILE_TOOLCHAIN: 1.70.0

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
config:
- { name: "Normal", args: "-- --nocapture", rustflags: "" }
- {
name: "Madsim",
args: "--package=simulation -- --nocapture",
rustflags: "--cfg madsim",
}
name: Test ${{ matrix.config.name }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- run: sudo bash ./.github/scripts/install_deps.sh
- uses: actions-rs/toolchain@v1
with:
profile: default
toolchain: ${{ env.XLINE_COMPILE_TOOLCHAIN }}
override: true
- uses: Swatinem/rust-cache@v2
with:
shared-key: "xline"
- name: ${{ matrix.config.name }}
uses: actions-rs/cargo@v1
with:
command: test
args: ${{ matrix.config.args }}
env:
RUSTFLAGS: ${{ matrix.config.rustflags }}

validation:
name: Validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- run: sudo bash ./.github/scripts/install_deps.sh
- uses: actions-rs/toolchain@v1
with:
profile: default
toolchain: ${{ env.XLINE_COMPILE_TOOLCHAIN }}
override: true
- uses: Swatinem/rust-cache@v2
with:
shared-key: "xline"
- run: cargo build --release --bin validation_lock_client --target x86_64-unknown-linux-gnu
- uses: actions-rs/cargo@v1
with:
command: build
args: --release
- run: |
cd scripts
cp ../target/release/{xline,benchmark} .
cp ../target/x86_64-unknown-linux-gnu/release/validation_lock_client .
cp ../xline-test-utils/{private,public}.pem .
docker build . -t ghcr.io/xline-kv/xline:latest
docker pull gcr.io/etcd-development/etcd:v3.5.5
bash ./validation_test.sh
150 changes: 59 additions & 91 deletions .github/workflows/ci.yml → .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: CI
name: Trivial Checks

on:
schedule:
- cron: "00 19 * * *" # run ci periodically at 3 am
pull_request:
branches: [ master ]
branches: [master]

env:
XLINE_COMPILE_TOOLCHAIN: 1.70.0
Expand Down Expand Up @@ -39,35 +39,6 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}

check:
runs-on: ubuntu-latest
strategy:
matrix:
config:
- { name: "Normal", args: "", rustflags: "" }
- { name: "Madsim", args: "--package=simulation", rustflags: "--cfg madsim" }
name: Check ${{ matrix.config.name }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- run: sudo bash ./.github/scripts/install_deps.sh
- uses: actions-rs/toolchain@v1
with:
profile: default
toolchain: ${{ env.XLINE_COMPILE_TOOLCHAIN }}
override: true
- uses: Swatinem/rust-cache@v2
with:
shared-key: "xline"
- name: ${{ matrix.config.name }}
uses: actions-rs/cargo@v1
with:
command: check
args: ${{ matrix.config.args }}
env:
RUSTFLAGS: ${{ matrix.config.rustflags }}

fmt:
name: Format
runs-on: ubuntu-latest
Expand All @@ -83,42 +54,76 @@ jobs:
command: fmt
args: --all -- --check

test:
spell-check:
name: Spell Check
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v2
- name: Check Spelling
uses: crate-ci/typos@master

cargo-sort:
name: Check Crate Sort
runs-on: ubuntu-latest
strategy:
matrix:
config:
- { name: "Normal", args: "-- --nocapture", rustflags: "" }
- { name: "Madsim", args: "--package=simulation -- --nocapture", rustflags: "--cfg madsim" }
name: Test ${{ matrix.config.name }}
steps:
- uses: actions/checkout@v2
- uses: actions-rs/[email protected]
with:
submodules: recursive
- run: sudo bash ./.github/scripts/install_deps.sh
- uses: actions-rs/toolchain@v1
crate: cargo-sort
version: latest
- run: cargo sort --check --workspace

hakari-fix:
name: Hakari fix
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- name: Install cargo-hakari
uses: taiki-e/install-action@v2
with:
profile: default
toolchain: ${{ env.XLINE_COMPILE_TOOLCHAIN }}
override: true
- uses: Swatinem/rust-cache@v2
tool: cargo-hakari
- name: Hakari generate
run: cargo hakari generate
- name: Show diff
run: git diff
- uses: stefanzweifel/git-auto-commit-action@v4
with:
shared-key: "xline"
- name: ${{ matrix.config.name }}
uses: actions-rs/cargo@v1
commit_message: "chore: fix workspace-hack"

commit:
name: Commit Message Validation
runs-on: ubuntu-latest
if: ${{ github.event_name != 'schedule' }}
steps:
- uses: actions/checkout@v2
with:
command: test
args: ${{ matrix.config.args }}
env:
RUSTFLAGS: ${{ matrix.config.rustflags }}
fetch-depth: 0
- run: git show-ref
- uses: actions-rs/[email protected]
with:
crate: git-cz
version: latest
- name: Validate commit messages
run: git-cz check ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}

clippy:
runs-on: ubuntu-latest
strategy:
matrix:
config:
- { name: "Normal", args: "--all-targets --all-features -- -D warnings", rustflags: "" }
- { name: "Madsim", args: "--package=simulation --all-targets --all-features -- -D warnings", rustflags: "--cfg madsim" }
- {
name: "Normal",
args: "--all-targets --all-features -- -D warnings",
rustflags: "",
}
- {
name: "Madsim",
args: "--package=simulation --all-targets --all-features -- -D warnings",
rustflags: "--cfg madsim",
}
name: Clippy ${{ matrix.config.name }}
steps:
- uses: actions/checkout@v2
Expand All @@ -140,40 +145,3 @@ jobs:
args: ${{ matrix.config.args }}
env:
RUSTFLAGS: ${{ matrix.config.rustflags }}

commit:
name: Commit Message Validation
runs-on: ubuntu-latest
if: ${{ github.event_name != 'schedule' }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: git show-ref
- uses: actions-rs/[email protected]
with:
crate: git-cz
version: latest
- name: Validate commit messages
run: git-cz check ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}

spell-check:
name: Spell Check
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v2

- name: Check Spelling
uses: crate-ci/typos@master

cargo-sort:
name: Check Crate Sort
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/[email protected]
with:
crate: cargo-sort
version: latest
- run: cargo sort --check --workspace
39 changes: 0 additions & 39 deletions .github/workflows/validation.yml

This file was deleted.

33 changes: 6 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,40 +29,19 @@ repos:
entry: bash -c 'cargo fmt -- --check'
language: rust
files: ^(?!abi)\.rs$
args: [ ]
- id: cargo-check
name: cargo check
description: Check the package for errors.
entry: bash -c 'cargo check --all'
language: rust
files: \.rs$
pass_filenames: false
- id: cargo-clippy
name: cargo clippy
description: Lint rust sources
entry: bash -c 'cargo clippy --all-targets --all-features --tests --benches -- -D warnings'
language: rust
files: \.rs$
pass_filenames: false
- id: cargo-test
name: cargo test
description: unit test for the project
entry: bash -c 'cargo test --all-features --all --lib'
language: rust
files: \.rs$
pass_filenames: false
args: []
- id: conventional-commit-msg-validation
name: commit message conventional validation
language: pygrep
entry: '^(breaking|build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w `])+([\s\S]*)'
args: [ --multiline, --negate ]
stages: [ commit-msg ]
args: [--multiline, --negate]
stages: [commit-msg]
- id: commit-msg-needs-to-be-signed-off
name: commit message needs to be signed off
language: pygrep
entry: '^Signed-off-by:'
args: [ --multiline, --negate ]
stages: [ commit-msg ]
entry: "^Signed-off-by:"
args: [--multiline, --negate]
stages: [commit-msg]
- id: cargo-sort
name: Check Cargo.toml is sorted
description: Ensure Cargo.toml is sorted
Expand Down

0 comments on commit ceb59a7

Please sign in to comment.