branch: elpa/flymake-pyrefly
commit 6a45620b3886ca0c7a60bc8317c9545dfb4c7482
Merge: ce4f30639b0 372add4d6e1
Author: Boris Shminke <[email protected]>
Commit: GitHub <[email protected]>

    Merge pull request #30 from inpefess/11-add-test-coverage-badge
    
    Add test coverage badge
---
 .elpaignore                             |  2 +-
 .github/workflows/main.yml              |  7 +++
 .gitignore                              |  1 +
 Eask                                    | 22 ++++++++
 Makefile                                | 97 ++++++++++++++++++++++++++++-----
 {tests => test}/example.py              |  0
 {tests => test}/test-flymake-pyrefly.el |  9 ++-
 7 files changed, 121 insertions(+), 17 deletions(-)

diff --git a/.elpaignore b/.elpaignore
index ada35494d1f..dea79dbef39 100644
--- a/.elpaignore
+++ b/.elpaignore
@@ -1,4 +1,4 @@
 Makefile
-tests
+test
 .github
 .gitignore
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index a0177739704..841a84b173b 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -16,6 +16,9 @@ jobs:
       - uses: actions/setup-python@v5
         with:
           python-version: '3.13'
+      - uses: emacs-eask/setup-eask@master
+        with:
+          version: 'snapshot'
       - name: Check out repository code
         uses: actions/checkout@v4
       - name: Install Pyrefly
@@ -26,6 +29,10 @@ jobs:
         run: |
           export PYREFLY_BIN_DIR=$(pwd)/.venv/bin
           make test
+      - name: Upload coverage reports to Codecov
+        uses: codecov/codecov-action@v5
+        with:
+          token: ${{ secrets.CODECOV_TOKEN }}
       - name: Compile
         run: |
           make compile
diff --git a/.gitignore b/.gitignore
index 319b8054368..c92ee90fb6f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,4 @@ dist/
 *.~undo-tree
 
 *.xml
+coverage/
diff --git a/Eask b/Eask
new file mode 100644
index 00000000000..246dfdaf007
--- /dev/null
+++ b/Eask
@@ -0,0 +1,22 @@
+;; -*- mode: eask; lexical-binding: t -*-
+
+(package "flymake-pyrefly"
+         "0.1.8"
+         "A Pyrefly Flymake backend")
+
+(website-url "https://github.com/inpefess/flymake-pyrefly";)
+(keywords "tools" "languages")
+
+(package-file "flymake-pyrefly.el")
+
+(script "test" "echo \"Error: no test specified\" && exit 1")
+
+(source "gnu")
+
+(depends-on "emacs" "26.1")
+
+(source "melpa")
+
+(development
+  (depends-on "f")
+  (depends-on "undercover"))
diff --git a/Makefile b/Makefile
index bdd2a968fd2..8cb3ebccddb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,20 +1,89 @@
-ALL_TARGETS = help clean test compile
-EMACS_TEST_JUNIT_REPORT=1
+##
+# Eask generated template Makefile
+#
+# File located in 
https://github.com/emacs-eask/template-elisp/blob/master/Makefile
+##
 
-.PHONY: ${ALL_TARGETS}
+EMACS ?= emacs
+EASK ?= eask
 
-help:
-       @echo Targets:
-       @for t in ${ALL_TARGETS}; do echo "- "$$t; done
+.PHONY: clean package install compile test checkdoc lint
 
-clean:
-       @rm -rf *.elc test/*.elc
+# CI entry point
+#
+# You can add or remove any commands here
+#
+# (Option 1): Basic for beginner, only tests for package's installation
+ci: clean package install compile
+# (Option 2): Advanced for a high-quality package
+#ci: clean package install compile checkdoc lint test
 
-test:
-       emacs --batch -L . -L tests -l test-flymake-pyrefly \
-       -f ert-run-tests-batch-and-exit
+# Build an package artefact, default to `dist` folder
+#
+# This is used to test if your package can be built correctly before the
+# package installation.
+package:
+       @echo "Packaging..."
+       $(EASK) package
+
+# Install package
+#
+# If your package is a single file package, you generally wouldn't need to 
+install:
+       @echo "Installing..."
+       $(EASK) install
 
+# Byte-compile package
+#
+# Compile all your package .el files to .elc
 compile:
-       emacs --batch -L . \
-       --eval "(setq byte-compile-error-on-warn t)" \
-       -f batch-byte-compile flymake-pyrefly.el
+       @echo "Compiling..."
+       $(EASK) compile
+
+# Run regression tests
+#
+# The default test is `ert`; but Eask also support other regression test!
+# See 
https://emacs-eask.github.io/Getting-Started/Commands-and-options/#-linting
+test:
+       @echo "Testing..."
+       $(EASK) install-deps --dev
+       $(EASK) test ert ./test/*.el
+
+# Run checkdoc
+#
+# See https://www.emacswiki.org/emacs/CheckDoc
+checkdoc:
+       @echo "Checking documentation..."
+       $(EASK) lint checkdoc --strict
+
+# Lint package metadata
+#
+# See https://github.com/purcell/package-lint
+lint:
+       @echo "Linting..."
+       $(EASK) lint package
+
+# Generate autoloads file
+#
+# NOTE: This is generally unnecessary
+autoloads:
+       @echo "Generating autoloads..."
+       $(EASK) autoloads
+
+# Generate -pkg file
+#
+# NOTE: This is generally unnecessary
+pkg-file:
+       @echo "Generating -pkg file..."
+       $(EASK) pkg-file
+
+# Clean up
+#
+# This will clean all the entire workspace including the following folders
+# and files
+#
+#   - .eask folder (sandbox)
+#   - all .elc files
+clean:
+       $(EASK) clean all
+       rm -rf coverage
diff --git a/tests/example.py b/test/example.py
similarity index 100%
rename from tests/example.py
rename to test/example.py
diff --git a/tests/test-flymake-pyrefly.el b/test/test-flymake-pyrefly.el
similarity index 87%
rename from tests/test-flymake-pyrefly.el
rename to test/test-flymake-pyrefly.el
index 9d7b487a7fa..27a6cd09296 100644
--- a/tests/test-flymake-pyrefly.el
+++ b/test/test-flymake-pyrefly.el
@@ -19,11 +19,16 @@
 ;; Test suite for flymake-pyrefly.
 
 ;;; Code:
+(when (require 'undercover nil t)
+  (undercover "flymake-pyrefly.el"
+              (:report-format 'codecov)
+              (:send-report nil)))
 (require 'flymake-pyrefly)
 (require 'flymake)
+(require 'f)
 (ert-deftest flymake-pyrefly-test-no-pyrefly ()
   "Test error message when Pyrefly is not found."
-  (find-file "tests/example.py")
+  (find-file (f-join "test" "example.py"))
   (should-error (pyrefly-flymake-backend 'identity)
                 :type 'no-pyrefly-error))
 (ert-deftest flymake-pyrefly-test-normal-use-case ()
@@ -31,7 +36,7 @@
   (defun mock-report-fn (args)
     (setq saved-args args))
   (push (getenv "PYREFLY_BIN_DIR") exec-path)
-  (find-file "tests/example.py")
+  (find-file (f-join "test" "example.py"))
   (setq saved-args nil)
   (pyrefly-flymake-backend 'mock-report-fn)
   (pyrefly-flymake-backend 'mock-report-fn)

Reply via email to