2021-06-06 18:24:40 +00:00
name : FixPR
2023-04-22 14:49:49 +00:00
# spell-checker:ignore Swatinem dtolnay
2022-02-19 20:26:34 +00:00
2021-06-06 18:24:40 +00:00
# Trigger automated fixes for PRs being merged (with associated commits)
env :
2022-01-22 02:43:02 +00:00
BRANCH_TARGET : main
2021-06-06 18:24:40 +00:00
on :
# * only trigger on pull request closed to specific branches
# ref: https://github.community/t/trigger-workflow-only-on-pull-request-merge/17359/9
pull_request :
branches :
2022-01-22 02:43:02 +00:00
- main # == env.BRANCH_TARGET ## unfortunately, env context variables are only available in jobs/steps (see <https://github.community/t/how-to-use-env-context/16975/2>)
2021-06-06 18:24:40 +00:00
types : [ closed ]
jobs :
code_deps :
# Refresh dependencies (ie, 'Cargo.lock') and show updated dependency tree
if : github.event.pull_request.merged == true ## only for PR merges
name : Update/dependencies
runs-on : ${{ matrix.job.os }}
strategy :
matrix :
job :
- { os: ubuntu-latest , features : feat_os_unix }
steps :
2022-05-06 06:38:11 +00:00
- uses : actions/checkout@v3
2021-06-06 18:24:40 +00:00
- name : Initialize job variables
id : vars
shell : bash
run : |
# surface MSRV from CICD workflow
RUST_MIN_SRV=$(grep -P "^\s+RUST_MIN_SRV:" .github/workflows/CICD.yml | grep -Po "(?<=\x22)\d+[.]\d+(?:[.]\d+)?(?=\x22)" )
2023-07-08 10:49:20 +00:00
echo "RUST_MIN_SRV=${RUST_MIN_SRV}" >> $GITHUB_OUTPUT
- uses : dtolnay/rust-toolchain@master
with :
toolchain : ${{ steps.vars.outputs.RUST_MIN_SRV }}
2022-11-19 06:37:47 +00:00
- uses : Swatinem/rust-cache@v2
2021-06-06 18:24:40 +00:00
- name : Ensure updated 'Cargo.lock'
shell : bash
run : |
# Ensure updated 'Cargo.lock'
# * 'Cargo.lock' is required to be in a format that `cargo` of MinSRV can interpret (eg, v1-format for MinSRV < v1.38)
cargo fetch --locked --quiet || cargo +${{ steps.vars.outputs.RUST_MIN_SRV }} update
- name : Info
shell : bash
run : |
# Info
## environment
echo "## environment"
echo "CI='${CI}'"
## tooling info display
echo "## tooling"
which gcc >/dev/null 2>&1 && (gcc --version | head -1) || true
2021-06-23 15:05:49 +00:00
rustup -V 2>/dev/null
2021-06-06 18:24:40 +00:00
rustup show active-toolchain
cargo -V
rustc -V
2022-09-12 11:22:33 +00:00
cargo tree -V
2021-06-06 18:24:40 +00:00
## dependencies
echo "## dependency list"
cargo fetch --locked --quiet
## * using the 'stable' toolchain is necessary to avoid "unexpected '--filter-platform'" errors
2022-09-12 11:22:33 +00:00
RUSTUP_TOOLCHAIN=stable cargo tree --locked --all --no-dev-dependencies --no-indent --features ${{ matrix.job.features }} | grep -vE "$PWD" | sort --unique
2021-06-06 18:24:40 +00:00
- name : Commit any changes (to '${{ env.BRANCH_TARGET }}')
2022-05-06 06:38:05 +00:00
uses : EndBug/add-and-commit@v9
2021-06-06 18:24:40 +00:00
with :
2023-07-08 10:49:20 +00:00
new_branch : ${{ env.BRANCH_TARGET }}
2021-06-06 18:24:40 +00:00
default_author : github_actions
message : "maint ~ refresh 'Cargo.lock'"
add : Cargo.lock
env :
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
code_format :
# Recheck/refresh code formatting
if : github.event.pull_request.merged == true ## only for PR merges
name : Update/format
runs-on : ${{ matrix.job.os }}
strategy :
fail-fast : false
matrix :
job :
- { os: ubuntu-latest , features : feat_os_unix }
steps :
2022-05-06 06:38:11 +00:00
- uses : actions/checkout@v3
2021-06-06 18:24:40 +00:00
- name : Initialize job variables
id : vars
shell : bash
run : |
# target-specific options
# * CARGO_FEATURES_OPTION
CARGO_FEATURES_OPTION='' ;
if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi
2023-07-08 10:49:20 +00:00
echo "CARGO_FEATURES_OPTION=${CARGO_FEATURES_OPTION}" >> $GITHUB_OUTPUT
2023-04-22 14:49:49 +00:00
- uses : dtolnay/rust-toolchain@master
with :
toolchain : stable
components : rustfmt
2022-11-19 06:37:47 +00:00
- uses : Swatinem/rust-cache@v2
2021-06-06 18:24:40 +00:00
- name : "`cargo fmt`"
shell : bash
run : |
cargo fmt
- name : "`cargo fmt` tests"
shell : bash
run : |
# `cargo fmt` of tests
find tests -name "*.rs" -print0 | xargs -0 cargo fmt --
- name : Commit any changes (to '${{ env.BRANCH_TARGET }}')
2022-05-06 06:38:05 +00:00
uses : EndBug/add-and-commit@v9
2021-06-06 18:24:40 +00:00
with :
2023-07-08 10:49:20 +00:00
new_branch : ${{ env.BRANCH_TARGET }}
2021-06-06 18:24:40 +00:00
default_author : github_actions
message : "maint ~ rustfmt (`cargo fmt`)"
env :
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}