]> git.eshelyaron.com Git - emacs.git/commitdiff
Add tree-sitter tests to emba
authorMichael Albinus <michael.albinus@gmx.de>
Mon, 29 May 2023 15:26:46 +0000 (17:26 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Mon, 29 May 2023 15:26:46 +0000 (17:26 +0200)
* admin/notes/emba: Add docker image emacs-tree-sitter.  Improve
docker call.

* test/infra/Dockerfile.emba (emacs-tree-sitter): New image.

* test/infra/gitlab-ci.yml (.tree-sitter-template): New template.
(build-image-tree-sitter, test-tree-sitter): New jobs.

admin/notes/emba
test/infra/Dockerfile.emba
test/infra/gitlab-ci.yml

index c88b422a4fa10902ccb80c4998134e22d4a70f24..1f87a99ddc0c68b4a4c9ecfd1a4f95e5b98d178d 100644 (file)
@@ -97,15 +97,16 @@ recent Emacs branch, and apply the command
 This creates the Debian-based image emacs-inotify, based on the
 instructions in the file Dockerfile.emba.  This image is good for the
 majority of tests.  However, there are also other image build
-instructions like emacs-filenotify-gio, emacs-eglot, emacs-gnustep and
-emacs-native-comp-speed{0,1,2}.  Use the appropriate one.
+instructions like emacs-filenotify-gio, emacs-eglot,
+emacs-tree-sitter, emacs-gnustep and emacs-native-comp-speed{0,1,2}.
+Use the appropriate one.
 
 The image contains a directory "/checkout", which is a copy of your
 local Emacs git repository.  Emacs has been built in this directory
 via "make bootstrap".  In order to use the image, start a container
 like
 
-  docker run --interactive --env EMACS_EMBA_CI=1 --name emacs-inotify \
+  docker run --interactive --tty --env EMACS_EMBA_CI=1 --name emacs-inotify \
     emacs-inotify /bin/sh -i
 
 In this container, change the current directory to "/checkout".  Now
index 689573236da4491d93f67a3bd03cc44e4d403368..5141c8919b1db861f96e1fdcfbf033cac48f7078 100644 (file)
@@ -83,6 +83,62 @@ RUN ./autogen.sh autoconf
 RUN ./configure
 RUN make bootstrap
 
+# Debian bullseye doesn't provide proper packages.  So we use Debian
+# sid for this.
+FROM debian:sid as emacs-tree-sitter
+
+# This corresponds to emacs-base.
+RUN apt-get update && \
+    apt-get install -y --no-install-recommends -o=Dpkg::Use-Pty=0 \
+      libc-dev gcc g++ make autoconf automake libncurses-dev gnutls-dev \
+      libdbus-1-dev libacl1-dev acl git texinfo gdb \
+    && rm -rf /var/lib/apt/lists/*
+
+# Install tree-sitter library.
+RUN apt-get update && \
+    apt-get install -y --no-install-recommends -o=Dpkg::Use-Pty=0 \
+      libtree-sitter0 libtree-sitter-dev \
+    && rm -rf /var/lib/apt/lists/*
+
+COPY . /checkout
+WORKDIR /checkout
+RUN ./autogen.sh autoconf
+RUN ./configure --with-tree-sitter
+RUN make bootstrap
+
+# Install language grammars.
+RUN mkdir /usr/local/lib/tree-sitter
+RUN git config --global http.sslverify "false"
+# See https://github.com/emacs-tree-sitter/tree-sitter-langs/tree/master/repos
+RUN src/emacs -Q --batch \
+    --eval '(setq \
+      treesit-extra-load-path (list "/usr/local/lib/tree-sitter") \
+      treesit-language-source-alist \
+      (quote ((bash "https://github.com/tree-sitter/tree-sitter-bash") \
+      (c "https://github.com/tree-sitter/tree-sitter-c") \
+      (cmake "https://github.com/uyha/tree-sitter-cmake") \
+      (cpp "https://github.com/tree-sitter/tree-sitter-cpp") \
+      (css "https://github.com/tree-sitter/tree-sitter-css") \
+      (elisp "https://github.com/Wilfred/tree-sitter-elisp") \
+      (elixir "https://github.com/elixir-lang/tree-sitter-elixir") \
+      (java "https://github.com/tree-sitter/tree-sitter-java") \
+      (go "https://github.com/tree-sitter/tree-sitter-go") \
+      (gomod "https://github.com/camdencheek/tree-sitter-go-mod") \
+      (heex "https://github.com/phoenixframework/tree-sitter-heex") \
+      (html "https://github.com/tree-sitter/tree-sitter-html") \
+      (javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src") \
+      (json "https://github.com/tree-sitter/tree-sitter-json") \
+      (make "https://github.com/alemuller/tree-sitter-make") \
+      (markdown "https://github.com/ikatyang/tree-sitter-markdown") \
+      (python "https://github.com/tree-sitter/tree-sitter-python") \
+      (ruby "https://github.com/tree-sitter/tree-sitter-ruby") \
+      (toml "https://github.com/tree-sitter/tree-sitter-toml") \
+      (tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src") \
+      (typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src") \
+      (yaml "https://github.com/ikatyang/tree-sitter-yaml"))))' \
+    --eval '(dolist (lang (mapcar (quote car) treesit-language-source-alist)) \
+      (treesit-install-language-grammar lang "/usr/local/lib/tree-sitter"))'
+
 FROM emacs-base as emacs-gnustep
 
 RUN apt-get update && \
index d1fef0187d4d7beb23f07bce4c8b92406e828d58..aabb50f6aaa18220830dc1d67870777437b5dc18 100644 (file)
@@ -176,6 +176,16 @@ default:
         - test/infra/*
         - test/lisp/progmodes/eglot-tests.el
 
+.tree-sitter-template:
+  rules:
+    - if: '$CI_PIPELINE_SOURCE == "web"'
+    - if: '$CI_PIPELINE_SOURCE == "schedule"'
+      changes:
+        - "**.in"
+        - lisp/progmodes/*-ts-mode.el
+        - test/infra/*
+        - test/lisp/progmodes/*-ts-mode-tests.el
+
 .native-comp-template:
   rules:
     - if: '$CI_PIPELINE_SOURCE == "web"'
@@ -256,6 +266,31 @@ test-eglot:
     # This is needed in order to get a JUnit test report.
     make_params: '-k -C test check-expensive LOGFILES="lisp/progmodes/eglot-tests.log"'
 
+build-image-tree-sitter:
+  stage: platform-images
+  extends: [.job-template, .build-template, .tree-sitter-template]
+  variables:
+    target: emacs-tree-sitter
+
+test-tree-sitter:
+  stage: platforms
+  extends: [.job-template, .test-template, .tree-sitter-template]
+  needs:
+    - job: build-image-tree-sitter
+      optional: true
+  variables:
+    target: emacs-tree-sitter
+    # This is needed in order to get a JUnit test report.
+    files: >-
+      lisp/progmodes/c-ts-mode-tests.log
+      lisp/progmodes/elixir-ts-mode-tests.el
+      lisp/progmodes/go-ts-mode-tests.log
+      lisp/progmodes/heex-ts-mode-tests.log
+      lisp/progmodes/java-ts-mode-tests.log
+      lisp/progmodes/ruby-ts-mode-tests.log
+      lisp/progmodes/typescript-ts-mode-tests.log
+    make_params: '-k -C test check-expensive LD_LIBRARY_PATH=/usr/local/lib/tree-sitter LOGFILES="$files"'
+
 build-image-gnustep:
   stage: platform-images
   extends: [.job-template, .build-template, .gnustep-template]