mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 19:42:27 +08:00
ci: auto format code when formatting step fails and update Cargo.lock if changed (#2567)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
51
.github/workflows/CI-pr.yml
vendored
51
.github/workflows/CI-pr.yml
vendored
@ -41,7 +41,16 @@ jobs:
|
|||||||
name: Check formatting
|
name: Check formatting
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository with token
|
||||||
|
if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
ref: ${{ github.event.pull_request.head.ref }}
|
||||||
|
token: ${{ secrets.AUTO_FILE_UPDATE_PAT }}
|
||||||
|
|
||||||
|
- name: Checkout repository for fork
|
||||||
|
if: ${{ github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
@ -50,10 +59,25 @@ jobs:
|
|||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
components: rustfmt
|
components: rustfmt
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting for forked pull requests
|
||||||
|
if: ${{ github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: cargo +nightly fmt --all --check
|
run: cargo +nightly fmt --all --check
|
||||||
|
|
||||||
|
- name: Run formatter
|
||||||
|
if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cargo +nightly fmt --all
|
||||||
|
if ! git diff --exit-code --quiet -- crates; then
|
||||||
|
echo "::notice::Formatting check failed"
|
||||||
|
git config --local user.name 'github-actions[bot]'
|
||||||
|
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
||||||
|
git add crates
|
||||||
|
git commit --message 'chore: run formatter'
|
||||||
|
git push
|
||||||
|
fi
|
||||||
|
|
||||||
check-msrv:
|
check-msrv:
|
||||||
name: Check compilation on MSRV toolchain
|
name: Check compilation on MSRV toolchain
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@ -275,9 +299,18 @@ jobs:
|
|||||||
# - windows-latest
|
# - windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository for fork
|
||||||
|
if: ${{ (github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) }}
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Checkout repository with token
|
||||||
|
if: ${{ (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) }}
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
ref: ${{ github.event.pull_request.head.ref }}
|
||||||
|
token: ${{ secrets.AUTO_FILE_UPDATE_PAT }}
|
||||||
|
|
||||||
- name: "Fetch base branch"
|
- name: "Fetch base branch"
|
||||||
shell: bash
|
shell: bash
|
||||||
run: git fetch origin $GITHUB_BASE_REF --depth 1
|
run: git fetch origin $GITHUB_BASE_REF --depth 1
|
||||||
@ -322,6 +355,18 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: cargo clippy --all-features --all-targets
|
run: cargo clippy --all-features --all-targets
|
||||||
|
|
||||||
|
- name: Check Cargo.lock changed
|
||||||
|
if: ${{ (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if ! git diff --quiet --exit-code -- Cargo.lock ; then
|
||||||
|
git config --local user.name 'github-actions[bot]'
|
||||||
|
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
||||||
|
git add Cargo.lock
|
||||||
|
git commit --message 'chore: update Cargo.lock'
|
||||||
|
git push
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Check files changed
|
- name: Check files changed
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user