From 3d2c1758b46d2e0c617c1d586f6a9a042e60249a Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Thu, 22 Sep 2022 14:24:06 -0700 Subject: [PATCH 1/8] Remove no longer needed hack https://github.com/ruby-syntax-tree/syntax_tree-rbs/pull/34#issuecomment-1251394959 --- test/formatters/installers/prettier-ruby.bash | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/formatters/installers/prettier-ruby.bash b/test/formatters/installers/prettier-ruby.bash index 611f5c63..0be3df07 100644 --- a/test/formatters/installers/prettier-ruby.bash +++ b/test/formatters/installers/prettier-ruby.bash @@ -4,12 +4,6 @@ apt-get install -y ruby ruby-dev gcc # Install the plugin npm install -g prettier @prettier/plugin-ruby -# Have to install from source because release not tagged yet -# https://github.com/ruby-syntax-tree/syntax_tree-rbs/pull/34 -# https://stackoverflow.com/a/11767563 -gem install specific_install -gem specific_install -l https://github.com/ruby-syntax-tree/syntax_tree-rbs.git - # These are required dependencies documented at # https://www.npmjs.com/package/@prettier/plugin-ruby gem install prettier_print syntax_tree syntax_tree-haml syntax_tree-rbs From 82709ef31f24d74e80deb1f44d7cab1687fdfcb8 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Thu, 22 Sep 2022 14:44:40 -0700 Subject: [PATCH 2/8] Fix linting to actually run --- test/formatters/apheleia-ft.el | 36 +++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/test/formatters/apheleia-ft.el b/test/formatters/apheleia-ft.el index b560441b..01fad8c8 100755 --- a/test/formatters/apheleia-ft.el +++ b/test/formatters/apheleia-ft.el @@ -56,6 +56,37 @@ already in memory on the current branch." (goto-char (point-min)) (read (current-buffer))))) +(defun apheleia-ft--get-changed-files-for-pull-request () + "Return list of files (relative to repo root) changed in this PR. +This means added, removed, or changed compared to main." + (let ((stderr-file (make-temp-file "apheleia-ft-stderr-"))) + (with-temp-buffer + (let ((exit-status + (call-process + "git" nil (list (current-buffer) stderr-file) nil + "diff" "--name-only" "main...HEAD"))) + (unless (zerop exit-status) + (with-temp-buffer + (insert-file-contents stderr-file) + (princ (buffer-string))) + (error + "Failed to 'git diff --name-only main...HEAD', got exit status %S" + exit-status))) + (split-string (buffer-string))))) + +(defun apheleia-ft--get-formatters-with-changed-scripts () + "Return list of formatter symbols whose scripts were touched in this PR. +This means their install scripts are different from how they +appear on main. This may include formatters that were removed +relative to main." + (save-match-data + (let ((formatters nil)) + (dolist (file (apheleia-ft--get-changed-files-for-pull-request)) + (when (string-match + "\\`test/formatters/installers/\\([^./]+\\)\\.bash\\'" file) + (push (intern (match-string 1 file)) formatters))) + formatters))) + (defun apheleia-ft--get-formatters-for-pull-request () "Return list of formatter string names that were touched in this PR. This means their commands in `apheleia-formatters' are different @@ -63,10 +94,13 @@ from how they appear on main, or they were added relative to main." (let ((old-formatters (apheleia-ft--get-formatters-from-ref "origin/main")) (new-formatters apheleia-formatters) + (formatters-with-changed-scripts + (apheleia-ft--get-formatters-with-changed-scripts)) (touched-formatters nil)) (map-do (lambda (formatter command) - (unless (equal command (alist-get formatter old-formatters)) + (unless (and (equal command (alist-get formatter old-formatters)) + (not (memq formatter formatters-with-changed-scripts))) (push (symbol-name formatter) touched-formatters))) new-formatters) touched-formatters)) From e959e32f4849da986e72f6789437baa1d54e991f Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Thu, 22 Sep 2022 14:46:32 -0700 Subject: [PATCH 3/8] Use origin/main instead of main --- test/formatters/apheleia-ft.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/formatters/apheleia-ft.el b/test/formatters/apheleia-ft.el index 01fad8c8..cfae7772 100755 --- a/test/formatters/apheleia-ft.el +++ b/test/formatters/apheleia-ft.el @@ -64,13 +64,15 @@ This means added, removed, or changed compared to main." (let ((exit-status (call-process "git" nil (list (current-buffer) stderr-file) nil - "diff" "--name-only" "main...HEAD"))) + "diff" "--name-only" "origin/main...HEAD"))) (unless (zerop exit-status) (with-temp-buffer (insert-file-contents stderr-file) (princ (buffer-string))) (error - "Failed to 'git diff --name-only main...HEAD', got exit status %S" + (concat + "Failed to 'git diff --name-only " + "origin/main...HEAD', got exit status %S") exit-status))) (split-string (buffer-string))))) From e53f19d676df6fa121e1f03925203e54168e7996 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Thu, 22 Sep 2022 14:50:05 -0700 Subject: [PATCH 4/8] Fix unrelated bug --- test/formatters/apheleia-ft.el | 1 + 1 file changed, 1 insertion(+) diff --git a/test/formatters/apheleia-ft.el b/test/formatters/apheleia-ft.el index cfae7772..77f8115e 100755 --- a/test/formatters/apheleia-ft.el +++ b/test/formatters/apheleia-ft.el @@ -309,6 +309,7 @@ environment variable, defaulting to all formatters." out-temp-file) ((guard (stringp arg)) arg) + (`npx arg) (_ (eval arg)))) command)) (setq command (delq 'npx command)) From cde18fe48d826bab60c41cef8b89e8d8c0846d77 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Thu, 22 Sep 2022 14:54:52 -0700 Subject: [PATCH 5/8] Add support for --no-cache --- test/formatters/build-image.bash | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/formatters/build-image.bash b/test/formatters/build-image.bash index a118d12b..3c3d4612 100755 --- a/test/formatters/build-image.bash +++ b/test/formatters/build-image.bash @@ -17,6 +17,11 @@ if [[ "$OSTYPE" != darwin* ]] && [[ "$EUID" != 0 ]]; then docker=(sudo -E "${docker[@]}") fi -exec "${docker[@]}" build . \ - -t "apheleia-formatters:${TAG:-latest}" \ - --build-arg "FORMATTERS=${FORMATTERS:-}" +no_cache=() +if [[ -n "${NO_CACHE:-}" ]]; then + no_cache=("--no-cache") +fi + +exec "${docker[@]}" build . \ + -t "apheleia-formatters:${TAG:-latest}" \ + --build-arg "FORMATTERS=${FORMATTERS:-}" "${no_cache[@]}" From d31f73ae5e3acabd26784bb65574cfe3e26c74d7 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Fri, 14 Oct 2022 17:53:37 -0700 Subject: [PATCH 6/8] Use checkout v3 --- .github/workflows/formatters.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/formatters.yml b/.github/workflows/formatters.yml index b114eea2..a63a27f7 100644 --- a/.github/workflows/formatters.yml +++ b/.github/workflows/formatters.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout pull request - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} - name: Fetch master From 080e254be0c87a404549e1a402053dab6a4941fa Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Fri, 14 Oct 2022 17:55:06 -0700 Subject: [PATCH 7/8] fetch_depth: 0 --- .github/workflows/formatters.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/formatters.yml b/.github/workflows/formatters.yml index a63a27f7..a7c8405d 100644 --- a/.github/workflows/formatters.yml +++ b/.github/workflows/formatters.yml @@ -8,6 +8,7 @@ jobs: uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} + fetch_depth: 0 # compare against main - name: Fetch master run: | git fetch From c4f3edca970abea58db97eabee3255e607bc75a4 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Fri, 14 Oct 2022 17:57:16 -0700 Subject: [PATCH 8/8] oops --- .github/workflows/formatters.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/formatters.yml b/.github/workflows/formatters.yml index a7c8405d..4df38b69 100644 --- a/.github/workflows/formatters.yml +++ b/.github/workflows/formatters.yml @@ -8,7 +8,7 @@ jobs: uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} - fetch_depth: 0 # compare against main + fetch-depth: 0 # compare against main - name: Fetch master run: | git fetch