-
Notifications
You must be signed in to change notification settings - Fork 1
Add a shared action for updating Rust version #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mulkieran
wants to merge
2
commits into
stratis-storage:master
Choose a base branch
from
mulkieran:issue_project_894
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| --- | ||
| name: Increase current Rust development version | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| fedora-container-image-number: | ||
| description: "Fedora Container Image Number" | ||
| required: true | ||
| type: number | ||
| caller-ref: | ||
| default: ${{ github.head_ref || github.ref_name }} | ||
| description: "The git/ref branch of the caller workflow" | ||
| required: false | ||
| type: string | ||
|
|
||
| jobs: | ||
| increase_rust_current_development_version: | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: quay.io/fedora/fedora:${{ inputs.fedora-container-image-number }} | ||
| steps: | ||
| - name: Install dependencies | ||
| run: dnf install -y curl git make rpmdevtools toml-cli | ||
| - uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a | ||
| with: | ||
| persist-credentials: false | ||
| repository: ${{ github.repository }} | ||
| ref: ${{ inputs.caller-ref }} | ||
| - name: Configure workspace as a safe directory | ||
| run: | | ||
| git config --global --add safe.directory "$GITHUB_WORKSPACE" | ||
| git config --global user.name "github-actions[bot]" | ||
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
| - name: Get remote manifest | ||
| run: curl --silent --fail --show-error --connect-timeout 20 --max-time 20 https://static.rust-lang.org/dist/channel-rust-stable.toml -o channel-rust-stable.toml | ||
| - name: Compare stable and current version | ||
| id: vercmp | ||
| run: | | ||
| CURRENT_VERSION=$(toml get --toml-path rust-toolchain.toml toolchain.channel) | ||
| STABLE_VERSION=$(toml get --toml-path channel-rust-stable.toml pkg.rust.version | cut -d " " -f 1) | ||
| rm channel-rust-stable.toml | ||
|
|
||
| set +e | ||
| rpmdev-vercmp "$CURRENT_VERSION" "$STABLE_VERSION" | ||
| CMP_RESULT=$? | ||
| set -e | ||
|
|
||
| if [ $CMP_RESULT -eq 12 ]; then | ||
| echo "needs_update=true" >> "$GITHUB_OUTPUT" | ||
| toml set --toml-path rust-toolchain.toml toolchain.channel "$STABLE_VERSION" | ||
| elif [ $CMP_RESULT -eq 11 ]; then | ||
| echo "Current version ($CURRENT_VERSION) > stable version ($STABLE_VERSION)" | ||
| exit 1 | ||
| elif [ $CMP_RESULT -eq 0 ]; then | ||
| echo "Current version ($CURRENT_VERSION) == stable version ($STABLE_VERSION)" | ||
| echo "needs_update=false" >> "$GITHUB_OUTPUT" | ||
| else | ||
| exit 1 | ||
| fi | ||
| - name: Commit toolchain update | ||
| if: steps.vercmp.outputs.needs_update == 'true' | ||
| id: commit | ||
| run: | | ||
| CURRENT_VERSION=$(toml get --toml-path rust-toolchain.toml toolchain.channel) | ||
| git add rust-toolchain.toml | ||
| git commit -m "Update CURRENT DEVELOPMENT RUST TOOLCHAIN to $CURRENT_VERSION" | ||
| echo "ver=($CURRENT_VERSION)" > "$GITHUB_OUTPUT" | ||
| - name: Install rust | ||
| if: steps.vercmp.outputs.needs_update == 'true' | ||
| uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 | ||
| with: | ||
| components: cargo, clippy | ||
| - name: Install stratisd dependencies | ||
| if: steps.vercmp.outputs.needs_update == 'true' | ||
| run: > | ||
| dnf install -y | ||
| clang | ||
| cryptsetup-devel | ||
| device-mapper-devel | ||
| libblkid-devel | ||
| systemd-devel | ||
| - name: Run clippy | ||
| if: steps.vercmp.outputs.needs_update == 'true' | ||
| id: clippy | ||
| run: | | ||
| set +e | ||
| CLIPPY_FIX=1 make clippy && make clippy | ||
| CLIPPY_RESULT=$? | ||
| set -e | ||
|
|
||
| if [ "$CLIPPY_RESULT" -eq 0 ]; then | ||
| git add -u | ||
| git commit --amend --no-edit | ||
|
|
||
| cat << 'EOF' > .git/pr_body.txt | ||
|
|
||
| ### Clippy automatically applied all fixes and exited with no errors. | ||
| Review all the changes before approving the PR. It is possible that | ||
| the changes introduce defects, e.g., shortened lifetimes, or are | ||
| otherwise erroneous. | ||
| EOF | ||
| else | ||
| cargo clean | ||
| git clean -xdf | ||
| cat << 'EOF' > .git/pr_body.txt | ||
|
|
||
| ### Clippy attempted to apply some fixes and exited with an error. | ||
| Check out the PR in your local copy, run 'make clippy' and resolve | ||
| the reported lints manually. | ||
| EOF | ||
| fi | ||
| - name: Create PR | ||
| if: steps.vercmp.outputs.needs_update == 'true' | ||
| uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 | ||
| with: | ||
| base: master | ||
| title: "Set CURRENT DEVELOPMENT RUST TOOLCHAIN to ${{ steps.commit.outputs.ver }}" | ||
| body-path: .git/pr_body.txt | ||
| branch: rust-toolchain-update-${{ github.run_id }} | ||
| draft: true | ||
|
mulkieran marked this conversation as resolved.
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.