Skip to content

Commit

Permalink
add workflow for checking for new rust-analyzer versions (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl committed Dec 22, 2023
1 parent c5680d0 commit 0922226
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 13 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/schema.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check update RA settings
name: Check/update RA settings

on:
pull_request:
Expand Down Expand Up @@ -46,27 +46,21 @@ jobs:
} >> "$GITHUB_OUTPUT"
- name: Find Comment
if: steps.new_settings.outputs.CHANGES != 'No changes'
uses: peter-evans/find-comment@v2
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'

- name: Create or update comment
if: steps.new_settings.outputs.CHANGES != 'No changes'
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Found the following changes in https://github.com/rust-lang/rust-analyzer/blob/${{ steps.tag-to.outputs.TAG }}/editors/code/package.json between tags ${{ steps.tag-from.outputs.TAG }} and ${{ steps.tag-to.outputs.TAG }}
Changes in https://github.com/rust-lang/rust-analyzer/blob/${{ steps.tag-to.outputs.TAG }}/editors/code/package.json between tags `${{ steps.tag-from.outputs.TAG }}` and `${{ steps.tag-to.outputs.TAG }}`:
<details>
<summary>New settings</summary>
```diff
${{ steps.new_settings.outputs.CHANGES }}
```
</details>
```diff
${{ steps.new_settings.outputs.CHANGES }}
```
edit-mode: replace
56 changes: 56 additions & 0 deletions .github/workflows/update-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Check/update to latest RA version

on:
schedule:
# Ru every day at 7:15
- cron: 15 7 * * *
workflow_dispatch:

jobs:
build:
name: Check RA version
runs-on: ubuntu-latest

steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y ripgrep
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.SUBLIMELSP_APP_ID }}
private-key: ${{ secrets.SUBLIMELSP_APP_PRIVATE_KEY }}

- name: Get latest release of rust-analyzer
uses: pozetroninc/[email protected]
id: latest_ra
with:
excludes: 'prerelease,draft'
repository: 'rust-lang/rust-analyzer'
token: ${{ steps.app-token.outputs.token }}

- uses: actions/checkout@v4
with:
ref: main

- name: Get current TAG from main
id: current_release
run: |
release=$(rg -o 'TAG = "([^"]+)"' -r \$1 "plugin.py")
echo "release=$release" >> "$GITHUB_OUTPUT"
- if: steps.current_release.outputs.release != steps.latest_ra.outputs.release
name: Update current version
run: sed -i 's/${{ steps.current_release.outputs.release }}/${{ steps.latest_ra.outputs.release }}/' plugin.py

- if: steps.current_release.outputs.release != steps.latest_ra.outputs.release
name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
commit-message: update rust-analyzer to ${{ steps.latest_ra.outputs.release }}
delete-branch: true
title: update rust-analyzer to ${{ steps.latest_ra.outputs.release }}
body: 'Update rust-analyzer server to [${{ steps.latest_ra.outputs.release }}](https://github.com/rust-lang/rust-analyzer/releases/tag/${{ steps.latest_ra.outputs.release }})'
token: ${{ steps.app-token.outputs.token }}
5 changes: 3 additions & 2 deletions scripts/new_settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function download_rust_by_tag {
exit "No tag provided"
fi

pushd "${LSP_REPO_DIR}" || exit
pushd "${LSP_REPO_DIR}" > /dev/null || exit

archive_url="${RA_REPO_URL}/archive/${tag}.zip"
temp_zip="src-${tag}.zip"
Expand All @@ -45,4 +45,5 @@ download_rust_by_tag "$tag_to"
settings_to=$(jq ".contributes.configuration.properties" "${RA_REPO_DIR}/editors/code/package.json")
rm -rf "${RA_REPO_DIR}"

diff -u <(echo "$settings_from") <(echo "$settings_to") || echo "No changes"
# This will exit with error code on changes. Make sure to not rely on anything running after it.
diff -u <(echo "$settings_from") <(echo "$settings_to") && echo "No changes"

0 comments on commit 0922226

Please sign in to comment.