Debian Codegraph @

.github/workflows/FixPR.yml

raw
1 name: FixPR
2
3 # spell-checker:ignore dedupe
4
5 # Trigger automated fixes for PRs being merged (with associated commits)
6
7 env:
8 BRANCH_TARGET: main
9
10 permissions:
11 contents: write # FixPR commits Cargo.lock back to main
12
13 on:
14 # * only trigger on pull request closed to specific branches
15 # ref: https://github.community/t/trigger-workflow-only-on-pull-request-merge/17359/9
16 pull_request:
17 branches:
18 - 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>)
19 types: [ closed ]
20
21 jobs:
22 code_deps:
23 # Refresh dependencies (ie, 'Cargo.lock') and show updated dependency tree
24 if: github.event.pull_request.merged == true ## only for PR merges
25 name: Update/dependencies
26 runs-on: ${{ matrix.job.os }}
27 strategy:
28 matrix:
29 job:
30 - { os: ubuntu-latest , features: feat_os_unix }
31 steps:
32 - uses: actions/[email protected]
33 with:
34 persist-credentials: false
35 - name: Initialize job variables
36 id: vars
37 shell: bash
38 run: |
39 # surface MSRV from CICD workflow
40 RUST_MIN_SRV=$(grep -P "^\s+RUST_MIN_SRV:" .github/workflows/CICD.yml | grep -Po "(?<=\x22)\d+[.]\d+(?:[.]\d+)?(?=\x22)" )
41 echo "RUST_MIN_SRV=${RUST_MIN_SRV}" >> $GITHUB_OUTPUT
42 - uses: dtolnay/rust-toolchain@master
43 with:
44 toolchain: ${{ steps.vars.outputs.RUST_MIN_SRV }}
45 - uses: Swatinem/rust-cache@v2
46 - name: Ensure updated 'Cargo.lock'
47 shell: bash
48 run: |
49 # Ensure updated '*/Cargo.lock'
50 # * '*/Cargo.lock' is required to be in a format that `cargo` of MinSRV can interpret (eg, v1-format for MinSRV < v1.38)
51 for dir in "." "fuzz"; do
52 ( cd "$dir" && (cargo fetch --locked --quiet --target $(rustc --print host-tuple) || cargo +${{ steps.vars.outputs.RUST_MIN_SRV }} update) )
53 done
54 - name: Info
55 shell: bash
56 run: |
57 # Info
58 ## environment
59 echo "## environment"
60 echo "CI='${CI}'"
61 ## tooling info display
62 echo "## tooling"
63 which gcc >/dev/null 2>&1 && (gcc --version | head -1) || true
64 rustup -V 2>/dev/null
65 rustup show active-toolchain
66 cargo -V
67 rustc -V
68 cargo tree -V
69 ## dependencies
70 echo "## dependency list"
71 cargo fetch --locked --quiet --target $(rustc --print host-tuple)
72 ## * using the 'stable' toolchain is necessary to avoid "unexpected '--filter-platform'" errors
73 cargo +stable tree --locked --no-dedupe -e=no-dev --prefix=none --features ${{ matrix.job.features }} | grep -vE "$PWD" | sort --unique
74 - name: Commit any changes (to '${{ env.BRANCH_TARGET }}')
75 uses: EndBug/add-and-commit@v11
76 with:
77 new_branch: ${{ env.BRANCH_TARGET }}
78 default_author: github_actions
79 message: "maint ~ refresh 'Cargo.lock' 'fuzz/Cargo.lock'"
80 add: Cargo.lock fuzz/Cargo.lock
81 env:
82 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}