branch: externals/polymode
commit b394faef2704167bc7d2c0def0a8a311d9e5000f
Author: Vitalie Spinu <[email protected]>
Commit: Vitalie Spinu <[email protected]>

    Improve CI
---
 .github/workflows/test.yml       | 125 +++++++++++++++++++++++----------------
 Makefile                         |   2 +-
 polymode-test-utils.el           |   6 +-
 targets/deps                     |   4 +-
 targets/poly-targets.el          |  17 ++++--
 template/Makefile                |   6 +-
 template/targets/poly-targets.el |  19 +++++-
 tests/compat-tests.el            |   2 +-
 tests/define-tests.el            |   4 +-
 tests/poly-modes-tests.el        |   6 +-
 10 files changed, 120 insertions(+), 71 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 853a51081b..e75df5eaca 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -1,52 +1,73 @@
-name: CI
-on:
-  pull_request:
-    paths-ignore:
-    - '**.md'
-    - '**.org'
-    - '.dir-locals.el'
-    - '.elpaignore'
-    - '.gitignore'
-    - 'doc/**'
-    branches:
-      - master
-  push:
-    paths-ignore:
-    - '**.md'
-    - '**.org'
-    - '.dir-locals.el'
-    - '.elpaignore'
-    - '.gitignore'
-    - 'doc/**'
-permissions: {}
-jobs:
-  build:
-    runs-on: ubuntu-latest
-    strategy:
-      fail-fast: false
-      matrix:
-        emacs_version:
-          - 28.2
-          - 29.4
-          - 30.1
-          - snapshot
-
-    steps:
-    - uses: purcell/setup-emacs@master
-      with:
-        version: ${{ matrix.emacs_version }}
-
-    - uses: actions/checkout@v4
-      with:
-        persist-credentials: false
-
-    - name: Check Emacs version
-      run: emacs --version
-
-    - name: Build
-      run: |
-        make elpa
-        make build
-
-    - name: Test
-      run: make test-local
+name: CI
+
+on:
+  pull_request:
+    paths-ignore:
+    - '**.md'
+    - '**.org'
+    - '.dir-locals.el'
+    - '.elpaignore'
+    - '.gitignore'
+    - 'doc/**'
+    branches: [main, master]
+  push:
+    paths-ignore:
+    - '**.md'
+    - '**.org'
+    - '.dir-locals.el'
+    - '.elpaignore'
+    - '.gitignore'
+    - 'doc/**'
+    branches: [main, master]
+
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+
+    strategy:
+      fail-fast: false
+      matrix:
+        emacs_version:
+          # - 28.2
+          # - 29.4
+          - 30.1
+          - snapshot
+
+    steps:
+    - uses: purcell/setup-emacs@master
+      with:
+        version: ${{ matrix.emacs_version }}
+
+    - name: Pull polymode
+      uses: actions/checkout@v4
+
+    - name: Pull poly-markdown
+      uses: actions/checkout@v4
+      with:
+        repository: polymode/poly-markdown
+        path: polyrepos/poly-markdown
+
+    - name: Pull poly-org
+      uses: actions/checkout@v4
+      with:
+        repository: polymode/poly-org
+        path: polyrepos/poly-org
+
+    - name: Pull poly-noweb
+      uses: actions/checkout@v4
+      with:
+        repository: polymode/poly-noweb
+        path: polyrepos/poly-noweb
+
+    - name: Check Emacs version
+      run: emacs --version
+
+    - name: ELPA
+      run: make elpa
+
+    - name: Build
+      run: make build
+
+    - name: Test
+      run: make test-local
diff --git a/Makefile b/Makefile
index 4b36504f50..78f2940065 100644
--- a/Makefile
+++ b/Makefile
@@ -64,7 +64,7 @@ test: version clean
 
 test-local: version
        @echo "******************* Testing $(MODULE) 
***************************"
-       $(EMACSTARGET) -f pm--target-local -f pm--target-test
+       $(EMACSTARGET) -f pm--target-local-init -f pm--target-test
 
 test/%:
        $(eval PATTERN := $(subst test/, , $@))
diff --git a/polymode-test-utils.el b/polymode-test-utils.el
index 8ae65fc1c6..263b4d2127 100644
--- a/polymode-test-utils.el
+++ b/polymode-test-utils.el
@@ -54,6 +54,10 @@ Look into tests/input directory then in samples directory."
                  if (file-exists-p f) return f)
         (error "No file with name '%s' found in '%s'" name 
default-directory))))
 
+(defun pm-test-running-on-github-p ()
+  (string= (downcase (or (getenv "GITHUB_ACTIONS") "false")) "true"))
+
+
 (defun pm-test-matcher (string span-alist matcher &optional dry-run)
   (with-temp-buffer
     (insert string)
@@ -110,7 +114,7 @@ MODE is a quoted symbol."
 
 (defun pm-test-spans (mode string)
   (declare (indent 1))
-  (pm-test-run-on-string mode 
+  (pm-test-run-on-string mode
     string 1
     (pm-map-over-spans
      (lambda (span)
diff --git a/targets/deps b/targets/deps
index e573ca7339..2999fdb50c 100644
--- a/targets/deps
+++ b/targets/deps
@@ -1,3 +1 @@
-(ess markdown-mode yaml-mode rust-mode
-  slim-mode elisp-lint
-  coffee-mode markdown-mode poly-markdown )
+(ess markdown-mode yaml-mode rust-mode slim-mode elisp-lint coffee-mode 
poly-markdown)
diff --git a/targets/poly-targets.el b/targets/poly-targets.el
index ffe4386644..bfa9ff09ce 100644
--- a/targets/poly-targets.el
+++ b/targets/poly-targets.el
@@ -64,9 +64,9 @@
 
     (elisp-lint-files-batch)))
 
-(defun pm--target-local ()
-  (load-file "template/targets/utils.el")
-  (polymode-add-deps-to-load-path "polymode.el"))
+(defun pm--target-melpa ()
+  (load "template/targets/utils.el")
+  (polymode-install-packages "polymode.el"))
 
 (defun pm--target-melpa-init ()
   (require 'package)
@@ -78,14 +78,19 @@
                            ("melpa" . "https://melpa.org/packages/";)))
   (package-initialize))
 
-(defun pm--target-melpa ()
-  (load "template/targets/utils.el")
-  (polymode-install-packages "polymode.el"))
+(defun pm--target-local-init ()
+  "Add all relevant local paths to the load-path.
+Used for local development and CI."
+  (load-file "template/targets/utils.el")
+  (polymode-add-deps-to-load-path "polymode.el"))
 
 (defun pm--target-test ()
   (toggle-debug-on-error)
 
   (let ((polymode-test-dir (expand-file-name "tests/")))
+    ;; make sure current directory always has precedence, even if the same 
package is
+    ;; installed in .ELPA
+    (setq load-path (cons (expand-file-name "./") load-path))
     (add-to-list 'load-path polymode-test-dir)
     (dolist (f (directory-files polymode-test-dir t ".*el\\'"))
       (load f)))
diff --git a/template/Makefile b/template/Makefile
index df8d554c77..6c5969f313 100644
--- a/template/Makefile
+++ b/template/Makefile
@@ -22,7 +22,7 @@ build: version clean
 
 build-local: version clean
        @echo "******************* BUILDING $(MODULE) *************************"
-       $(EMACSTARGET) -f pm--target-local --funcall batch-byte-compile *.el
+       $(EMACSTARGET) -f pm--target-local-init --funcall batch-byte-compile 
*.el
 
 checkdoc: version
        @echo "******************* CHECKDOC $(MODULE) *************************"
@@ -46,7 +46,7 @@ start: version melpa
        $(EMACSTARGET) -L . -f pm--target-melpa-init --load tests/*.el
 
 startvs: version
-       $(EMACSTARGET) -L . -f pm--target-local \
+       $(EMACSTARGET) -L . -f pm--target-local-init \
                       --load tests/*.el --load ~/.eBasic.el
 
 test: build version
@@ -55,7 +55,7 @@ test: build version
 
 test-local: version
        @echo "******************* Testing $(MODULE) 
***************************"
-       $(EMACSTARGET) -f pm--target-local -f pm--target-test
+       $(EMACSTARGET) -f pm--target-local-init -f pm--target-test
 
 version:
        @echo "EMACS VERSION: $(EMACS_VERSION)"
diff --git a/template/targets/poly-targets.el b/template/targets/poly-targets.el
index 601739ab11..76faef306a 100644
--- a/template/targets/poly-targets.el
+++ b/template/targets/poly-targets.el
@@ -24,6 +24,20 @@
 
 ;;; Code:
 
+(defmacro dlet (binders &rest body)
+  "Like `let' but using dynamic scoping."
+  (declare (indent 1) (debug let))
+  ;; (defvar FOO) only affects the current scope, but in order for
+  ;; this not to affect code after the main `let' we need to create a new 
scope,
+  ;; which is what the surrounding `let' is for.
+  ;; FIXME: (let () ...) currently doesn't actually create a new scope,
+  ;; which is why we use (let (_) ...).
+  `(let (_)
+     ,@(mapcar (lambda (binder)
+                 `(defvar ,(if (consp binder) (car binder) binder)))
+               binders)
+     (let ,binders ,@body)))
+
 (defun pm--target-checkdoc ()
   (dlet ((sentence-end-double-space)
          (checkdoc-arguments-in-order-flag)
@@ -51,7 +65,7 @@
 
     (elisp-lint-files-batch)))
 
-(defun pm--target-local ()
+(defun pm--target-local-init ()
   (load-file "targets/utils.el")
   (polymode-add-deps-to-load-path "__MODULE__.el"))
 
@@ -70,6 +84,9 @@
 
 (defun pm--target-test ()
   (let ((polymode-test-dir (expand-file-name "tests/")))
+    ;; make sure current directory always has precedence, even if the same 
package is
+    ;; installed in .ELPA
+    (setq load-path (cons (expand-file-name "./") load-path))
     (add-to-list 'load-path polymode-test-dir)
     (dolist (f (directory-files polymode-test-dir t ".*el$"))
       (load f)))
diff --git a/tests/compat-tests.el b/tests/compat-tests.el
index 9b80f34d16..ca74c2c0c0 100644
--- a/tests/compat-tests.el
+++ b/tests/compat-tests.el
@@ -7,7 +7,7 @@
 (require 'polymode-test-utils)
 (require 'poly-markdown nil t)          ;Don't fail if not installed.
 
-(define-innermode poly-test-markdown-inline-python-innermode  
poly-markdown-inline-code-innermode
+(define-innermode poly-test-markdown-inline-python-innermode 
poly-markdown-inline-code-innermode
   :head-matcher (cons "[^`]\\(`py \\)" 1)
   :mode 'python-mode
   :fallback-mode 'poly-fallback-mode
diff --git a/tests/define-tests.el b/tests/define-tests.el
index 652a96264f..4828ec63a1 100644
--- a/tests/define-tests.el
+++ b/tests/define-tests.el
@@ -48,9 +48,9 @@
   (should (should (eq (lookup-key poly-xyz+-mode-map "<")
                       'some-command))))
 
+
 (ert-deftest define/hooks-run-in-indirect-buffers ()
-  ;; skip when run under GithubActions
-  (skip-unless (not (string= (getenv "GITHUB_ACTIONS") "true")))
+  (skip-when (pm-running-on-github-p))
   (setq ran-body-in-modes nil
         ran-hooks-in-modes nil
         ran-inner-hooks-in-modes nil
diff --git a/tests/poly-modes-tests.el b/tests/poly-modes-tests.el
index 43e4b6f4a3..b6961e2c2a 100644
--- a/tests/poly-modes-tests.el
+++ b/tests/poly-modes-tests.el
@@ -5,9 +5,13 @@
 ;; load all tests from individual poly-xyz repositories located in the parent 
of
 ;; this repository
 
+(require 'polymode)
 (require 'polymode-test-utils)
 
-(let* ((root (expand-file-name "../.."
+
+(let* ((root (expand-file-name (if (pm-test-running-on-github-p)
+                                   "../polyrepos/"
+                                 "../..")
                                (file-truename
                                 (file-name-directory
                                  (or load-file-name buffer-file-name 
default-directory)))))

Reply via email to