Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into FelixMcFelix-update-r…
Browse files Browse the repository at this point in the history
…a-version
  • Loading branch information
rchl committed Dec 14, 2023
2 parents 6a91ec5 + 1b3a634 commit fdc3b87
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
61 changes: 61 additions & 0 deletions .github/workflows/schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Check update RA settings

on:
pull_request:
branches:
- main

permissions:
pull-requests: write
repository-projects: write

jobs:
new_settings:
name: Check updated RA settings
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Get TAG from PR
id: tag-from
run: echo ::set-output name=TAG::$(rg -o 'TAG = "([^"]+)"' -r \$1 "plugin.py")

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

- name: Get TAG from main
id: tag-to
run: echo ::set-output name=TAG::$(rg -o 'TAG = "([^"]+)"' -r \$1 "plugin.py")

- name: Run new_settings.sh script
id: new_settings
run: echo ::set-output name=CHANGES::$(./scripts/new_settings.sh ${{ steps.tag-from.outputs.TAG }} ${{ steps.tag-to.outputs.TAG }})

- 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]'
body-includes: Build output

- 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: |
Changes in https://github.com/rust-lang/rust-analyzer/blob/master/editors/code/package.json
<details>
<summary>New settings</summary>
```diff
${{ steps.new_settings.outputs.CHANGES }}
```
</details>
edit-mode: replace
52 changes: 35 additions & 17 deletions scripts/new_settings.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,48 @@
#!/usr/bin/env bash

# The following script finds the keys that are in the `rust-analyzer`
# package.json, but not in `LSP-rust-analyzer`'s sublime-settings.
# The following script prints differences in `rust-analyzer` settings
# between two tags.

# exit when any command fails
set -e

RA_REPO_URL="https://github.com/rust-lang/rust-analyzer"
RA_REPO_DIR=$(echo "${RA_REPO_URL}" | command grep -oE '[^/]*$')

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LSP_REPO_DIR="$SCRIPT_DIR/.."

read -rp 'Provide directory path to the rust-analyzer repository (for example: /usr/local/github/rust-analyzer/): ' RA_REPO_DIR
if [ ! -d "$RA_REPO_DIR" ]; then
echo "Directory path '$RA_REPO_DIR' DOES NOT exist."
exit
if [ "$#" -ne 2 ]; then
echo 'You must provide 2 arguments - two tags between which to check for diffrences in settings.'
exit 1
fi

lsp_ra_settings=$(rg -o '"rust-analyzer.([^"]+)"' "${LSP_REPO_DIR}/LSP-rust-analyzer.sublime-settings" | sort)
ra_settings=$(jq '.contributes.configuration.properties
| to_entries
| map(.key)
| .[] | select(. != "$generated-start" and . != "$generated-end")' \
"${RA_REPO_DIR}/editors/code/package.json" | sort)
function download_rust_by_tag {
tag=$1

if [ ! "$tag" ]; then
exit "No tag provided"
fi

pushd "${LSP_REPO_DIR}" || exit

archive_url="${RA_REPO_URL}/archive/${tag}.zip"
temp_zip="src-${tag}.zip"
curl -L "${RA_REPO_URL}/archive/${tag}.zip" -o "${temp_zip}" --silent --show-error
unzip -q "${temp_zip}"
rm -f "${temp_zip}" || exit
mv "${RA_REPO_DIR}-"* "${RA_REPO_DIR}"
}

tag_from=$1
tag_to=$2

download_rust_by_tag "$tag_from"
settings_from=$(jq ".contributes.configuration.properties" "${RA_REPO_DIR}/editors/code/package.json")
rm -rf "${RA_REPO_DIR}"

# Missing settings in LSP-rust-analyzer
rg -vf <(echo "${lsp_ra_settings}") <(echo "${ra_settings}")
download_rust_by_tag "$tag_to"
settings_to=$(jq ".contributes.configuration.properties" "${RA_REPO_DIR}/editors/code/package.json")
rm -rf "${RA_REPO_DIR}"

# Settings in LSP-rust-analyzer that are no longer relevant
rg -vf <(echo "${ra_settings}") <(echo "${lsp_ra_settings}") \
| rg -v 'terminusAutoClose|terminusUsePanel'
diff -u <(echo "$settings_from") <(echo "$settings_to") || echo "No changes"

0 comments on commit fdc3b87

Please sign in to comment.