blob: 91a75cb401c4e024959a3fcca04d63596d47e73c [file]
name: Diff Check (Common)
on:
workflow_call:
inputs:
clone_url:
description: 'Git url of a rustfmt fork to compare against the latest rustfmt'
type: string
required: true
branch_name:
description: 'Name of the feature branch on the forked repo'
type: string
required: true
language_edition:
description: 'Rust language `edition` used to parse code'
type: string
required: true
style_edition:
description: 'rustfmt `style_edition` used when formatting code.'
type: string
required: true
commit_hash:
description: 'Optional commit hash from the feature branch'
type: string
required: false
rustfmt_configs:
description: 'Optional comma separated list of rustfmt config options to pass when running the feature branch'
type: string
required: false
release_channel:
description: 'Configure which release channel to use when compiling rustfmt'
type: string
required: false
default: stable
permissions:
contents: read
jobs:
diff_check:
name: "Diff Check {Edition ${{ inputs.language_edition }}, Style Edition ${{ inputs.style_edition }}}"
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Build diff_check binary
working-directory: ./diff_check
run: cargo build --release --locked
- name: Run Diff Check
working-directory: ./diff_check
env:
DIFF_CHECK_LOG: info
GITHUB_EVENT_INPUTS_COMMIT_HASH: ${{ inputs.commit_hash }}
GITHUB_EVENT_INPUTS_RUSTFMT_CONFIGS: ${{ inputs.rustfmt_configs }}
GITHUB_EVENT_INPUTS_CLONE_URL: ${{ inputs.clone_url }}
GITHUB_EVENT_INPUTS_BRANCH_NAME: ${{ inputs.branch_name }}
GITHUB_EVENT_INPUTS_LANGUAGE_EDITION: ${{ inputs.language_edition }}
GITHUB_EVENT_INPUTS_STYLE_EDITION: ${{ inputs.style_edition }}
shell: bash
run: |
OPTIONS=()
if [[ -n "${GITHUB_EVENT_INPUTS_COMMIT_HASH}" ]]; then
OPTIONS+=(--commit-hash "${GITHUB_EVENT_INPUTS_COMMIT_HASH}")
fi
if [[ -n "${GITHUB_EVENT_INPUTS_RUSTFMT_CONFIGS}" ]]; then
OPTIONS+=(--rustfmt-config "${GITHUB_EVENT_INPUTS_RUSTFMT_CONFIGS}")
fi
target/release/diff_check \
"${GITHUB_EVENT_INPUTS_CLONE_URL}" \
"${GITHUB_EVENT_INPUTS_BRANCH_NAME}" \
--edition "${GITHUB_EVENT_INPUTS_LANGUAGE_EDITION}" \
--style-edition "${GITHUB_EVENT_INPUTS_STYLE_EDITION}" \
"${OPTIONS[@]}"