Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for rustic-cargo-outdated in presence of git dependencies #552

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5d36b91
Fix cargo login token tests
psibi Aug 18, 2023
e3ebab3
Remove rust-ts-mode from auto-mode-alist
psibi Feb 18, 2024
866c5e2
Fix possible babel test failures
psibi Feb 18, 2024
a4fbc1b
Change regex for rustic-test-babel-error-results
psibi Feb 18, 2024
9a6ddd0
No issue with compile error
psibi Feb 18, 2024
8620a98
Do fixes at other locations too
psibi Feb 18, 2024
fd5b5d8
Merge pull request #2 from psibi/babel-test-failures
psibi Feb 18, 2024
4002826
Enable test for emacs 29.1
psibi Feb 18, 2024
c6cd30f
Bump version of cask
psibi Feb 18, 2024
a743dd7
Try using ert tests
psibi Feb 18, 2024
5a36ba4
Require test-helper
psibi Feb 18, 2024
36077a2
Add load-file
psibi Feb 18, 2024
b56aba0
Update depedency
psibi Feb 18, 2024
0b03616
Add melpa check
psibi Feb 18, 2024
de38bba
Update
psibi Feb 18, 2024
c64e2fb
Fix seq version
psibi Feb 18, 2024
e784003
seq is included with Emacs 25
psibi Feb 18, 2024
408adb1
Remove seq
psibi Feb 18, 2024
69b02b4
Do relevant imports for rustic-cargo-test
psibi Feb 18, 2024
038c4f6
Modify test setup for Emacs 29.1
psibi Feb 19, 2024
ebee470
Slight cleanup
psibi Feb 19, 2024
498e7b7
Update tests
psibi Feb 19, 2024
5654d66
Switch the compilation error count to 1
psibi Feb 19, 2024
91731e8
Revert it back to 10
psibi Feb 19, 2024
6da5f7b
Remove should-not
psibi Feb 19, 2024
c726954
Simplify github action
psibi Feb 19, 2024
3748f6d
Revert test numbers
psibi Feb 19, 2024
2621065
Add changelog
psibi Feb 19, 2024
6c2f266
Try fixing flaky tests
psibi Feb 19, 2024
ecd95ed
Fix one more flaky test
psibi Feb 19, 2024
5c1cff5
Merge pull request #3 from psibi/emacs-20
psibi Feb 19, 2024
adf3690
Update changelog
psibi Feb 19, 2024
5e37592
Fix rustic-cargo-outdated
psibi Feb 23, 2024
ad136cd
Update changelog
psibi Feb 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 37 additions & 48 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,40 @@ name: CI
on: [push, pull_request]

jobs:
unix-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
emacs-version:
- 27.2
- 28.1
steps:
- uses: actions/checkout@v2

- uses: purcell/setup-emacs@master
with:
version: ${{ matrix.emacs-version }}

- uses: conao3/setup-cask@master
with:
version: 0.8.4

- name: Install requirements
run: |
echo "$HOME/.cask/bin" >> $GITHUB_PATH
echo "$HOME/bin" >> $GITHUB_PATH

sudo apt update
sudo apt install -y gnutls-bin gnupg2 dirmngr
sudo apt install -y texinfo libgif-dev libxpm-dev

- name: Install needed rust stuff
run: |
curl -sSf https://build.travis-ci.com/files/rustup-init.sh | sh -s -- --default-toolchain=stable -y
source $HOME/.cargo/env
rustup component add rustfmt-preview

- name: rustic-doc prerequisites
run: |
wget https://github.com/jgm/pandoc/releases/download/2.17.0.1/pandoc-2.17.0.1-1-amd64.deb
sudo dpkg -i pandoc-2.17.0.1-1-amd64.deb
mkdir -p ~/.local/bin
mkdir -p ~/.local/share/emacs/rustic-doc/std/
curl -sL https://github.com/sharkdp/fd/releases/download/v8.3.2/fd-v8.3.2-x86_64-unknown-linux-musl.tar.gz | tar xz --wildcards --strip-components=1 -C /usr/local/bin '*/fd'
curl -sL https://github.com/BurntSushi/ripgrep/releases/download/13.0.0/ripgrep-13.0.0-x86_64-unknown-linux-musl.tar.gz | tar xz --wildcards --strip-components=1 -C /usr/local/bin '*/rg'
rustup component add rust-docs

- name: Run tests
run: |
make test
unix-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
emacs-version:
- 27.2
- 28.1
- 29.1
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@v2
with:
tool: [email protected]
- uses: purcell/setup-emacs@master
with:
version: ${{ matrix.emacs-version }}

- uses: cask/setup-cask@v1
with:
version: 0.9.0

- name: Install requirements
run: |
echo "$HOME/.cask/bin" >> $GITHUB_PATH
echo "$HOME/bin" >> $GITHUB_PATH

- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.74.1
components: clippy, rustfmt

- name: Run tests
run: |
just build
just test
11 changes: 11 additions & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* Unreleased

- Revamp testing in CI: Use only cask.
- Replace Makefile with justfile.
- Pin Rust version in CI to avoid spurious failure.
- Create a new babel variable to create temporary directory and not
rely on babel's internal stuff. This was needed to fix the tests.
- Fix flaky tests.
- Enable tests for Emacs 29.1
- Fix bugs in rustic-cargo-outdated mode in the presence of git
repositories as dependency.
153 changes: 0 additions & 153 deletions Makefile

This file was deleted.

14 changes: 14 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# List all recipes
just:
just --list --unsorted

# Install dependencies and build via cask
build:
emacs --version
cask install
cask build

# Test
test:
cask emacs --batch -L . -L test -f batch-byte-compile $(cask files)
cask emacs --batch -L . -L test -l test/all-tests.el -f ert-run-tests-batch-and-exit
23 changes: 11 additions & 12 deletions rustic-babel.el
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@

(require 'rustic-rustfmt)

;; FIXME This variable doesn't exist in noninteractive emacs sessions,
;; which probably means that it is internal and we shouldn't use it.
(defvar org-babel-temporary-directory)

(defvar rustic-info nil)

(add-to-list 'org-src-lang-modes '("rust" . rustic))
Expand Down Expand Up @@ -160,7 +156,7 @@ execution with rustfmt."
(save-excursion
(save-match-data
(goto-char (point-min))
(when (re-search-forward "^thread '[^']+' panicked at '[^']+', ")
(when (re-search-forward "^thread '[^']+' panicked at .*")
(goto-char (match-beginning 0))
(setq result (buffer-substring-no-properties (point) (line-end-position)))))))
(rustic-babel-run-update-result-block result)
Expand Down Expand Up @@ -210,10 +206,13 @@ after successful compilation."
(buffer-string)))))))
(kill-buffer "rustic-babel-format-buffer"))))

(defvar rustic-org-babel-temporary-directory
(make-temp-file "babel-" t))

(defun rustic-babel-generate-project (&optional expand)
"Create rust project in `org-babel-temporary-directory'.
"Create rust project in `rustic-org-babel-temporary-directory'.
Return full path if EXPAND is t."
(let* ((default-directory org-babel-temporary-directory)
(let* ((default-directory rustic-org-babel-temporary-directory)
(dir (make-temp-file-internal "cargo" 0 "" nil)))
(shell-command-to-string (format "cargo new %s --bin --quiet" dir))
(if expand
Expand All @@ -224,14 +223,14 @@ Return full path if EXPAND is t."
"In order to reduce the execution time when the project has
dependencies, the project name is stored as a text property in the
header of the org-babel block to check if the project already exists
in `org-babel-temporary-directory'. If the project exists, reuse it.
in `rustic-org-babel-temporary-directory'. If the project exists, reuse it.
Otherwise create it with `rustic-babel-generate-project'."
(let* ((beg (org-babel-where-is-src-block-head))
(end (save-excursion (goto-char beg)
(line-end-position)))
(line (buffer-substring beg end)))
(let* ((project (symbol-name (get-text-property 0 'project line)))
(path (concat org-babel-temporary-directory "/" project "/")))
(path (concat rustic-org-babel-temporary-directory "/" project "/")))
(if (file-directory-p path)
(progn
(put-text-property beg end 'project (make-symbol project))
Expand Down Expand Up @@ -348,7 +347,7 @@ kill the running process."
(progn
(rustic-process-kill-p p t)
nil)
(let* ((default-directory org-babel-temporary-directory)
(let* ((default-directory rustic-org-babel-temporary-directory)
(project (rustic-babel-project))
(dir (setq rustic-babel-dir (expand-file-name project)))
(main-p (cdr (assq :main params)))
Expand Down Expand Up @@ -392,7 +391,7 @@ at least one time in this emacs session before this command can be used."
(line-end-position)))
(line (buffer-substring beg end))
(project (symbol-name (get-text-property 0 'project line)))
(path (concat org-babel-temporary-directory "/" project "/src/main.rs")))
(path (concat rustic-org-babel-temporary-directory "/" project "/src/main.rs")))
(if (file-exists-p path)
(find-file path)
(message "Run block first to visit generated project."))))
Expand All @@ -403,7 +402,7 @@ at least one time in this emacs session before this command can be used."
(interactive)
(rustic--inheritenv
(let* ((err-buff (get-buffer-create rustic-babel-compilation-buffer-name))
(default-directory org-babel-temporary-directory)
(default-directory rustic-org-babel-temporary-directory)
(body (org-element-property :value (org-element-at-point)))
(project (rustic-babel-project))
(params (list "cargo" "clippy")))
Expand Down
Loading
Loading