Skip to content

Commit

Permalink
Merge branch 'fix_compile_doc_errors' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ndwarshuis committed Aug 19, 2024
2 parents ea00013 + 140bdea commit 742ed22
Show file tree
Hide file tree
Showing 18 changed files with 459 additions and 159 deletions.
13 changes: 13 additions & 0 deletions .emacs/29.3/straight/versions/default.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(("dash.el" . "39d067b9fbb2db65fc7a6938bfb21489ad990cb4")
("el-get" . "c0713e8d8e8ad987fe1283d76b9c637a10f048ef")
("emacs-buttercup" . "a1a86b027ffe030e1c78a9f43c50cd20a6fed19a")
("emacsmirror-mirror" . "8cbbdaa750c897d05ee71980834699a7d7c2d208")
("f.el" . "de6d4d40ddc844eee643e92d47b9d6a63fbebb48")
("gnu-elpa-mirror" . "3d0759ef4792b6461f2979a4e70e1c819df7283a")
("melpa" . "3126dac37def07fcaa667a325ee79349fb80d285")
("nongnu-elpa" . "a9a649210a8d8b9295b5a1d0c7b60a77db03c14c")
("org" . "071c6e986c424d2e496be7d0815d6e9cd83ae4e6")
("org-ml" . "7a7b1e918e8440f3f6ddb37db9bd1471d0dad37d")
("s.el" . "4d7d83122850cf70dc60662a73124f0be41ad186")
("straight.el" . "88e574ae75344e39b436f863ef0344135c7b6517"))
:gamma
36 changes: 14 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,25 @@ jobs:
strategy:
matrix:
emacs_version:
- '27.1'
- '27.2'
- '28.1'
- '29.3'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.6'
architecture: 'x64'
- uses: purcell/setup-emacs@master
with:
version: ${{ matrix.emacs_version }}
- uses: conao3/setup-cask@master

- uses: mamba-org/[email protected]
with:
version: '0.8.4'
micromamba-version: '1.5.6-0'
environment-file: env-${{ matrix.emacs_version }}.yml
cache-environment: true
post-cleanup: 'all'

- name: Setup testing databases
run: docker-compose up -d
- uses: hoverkraft-tech/[email protected]
with:
up-flags: "--build"
down-flags: "--volumes"

- name: Run tests
if: matrix.allow_failure != true
shell: micromamba-shell {0}
run: |
cask install
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libc_malloc_debug.so
make install
make
- name: Run tests (allow failure)
if: matrix.allow_failure == true
run: |
cask install
make || true
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.elc
.cask
.emacs/*/straight/build
.emacs/*/straight/repos
.emacs/*/straight/build-cache.el
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 4.0.0

breaking changes
- drop support for lots of unsupported database versions (technically a breaking
change, hence major bump)

new features
- timestamps in headlines are now pulled into database (thanks aviav)

bugfixes
- fix compilation and documentation errors (thanks aviav)
- fix whitespace issues with go-sqlcmd

## 3.0.4

- fix compiler errors and warnings
Expand Down
24 changes: 17 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
CASK ?= cask
EMACS ?= emacs
EMACS ?= emacs -Q --batch --load init.el -l org-sql.el

all: test

Expand All @@ -9,24 +8,35 @@ test:
${MAKE} compile

docs:
${CASK} exec ${EMACS} -Q -batch -L . \
${EMACS} \
-l doc/org-sql-doc.el \
-f create-docs-file \
-f org-sql-create-all-erds

stateless:
${CASK} exec buttercup -L . -l test/org-sql-test-stateless.el
${EMACS} -l test/org-sql-test-stateless.el -f buttercup-run-discover

stateful:
${CASK} exec buttercup -L . -l test/org-sql-test-stateful.el
${EMACS} -l test/org-sql-test-stateful.el -f buttercup-run-discover

compile:
${CASK} build
${EMACS} build
${MAKE} stateless
${MAKE} stateful
${MAKE} clean-elc

clean-elc:
${CASK} clean-elc
${EMACS} clean-elc

# install all development packages for the current version
install:
${EMACS} --eval '(print "Install finished")'

# write lockfile for current emacs version given each repo dependency
freeze:
${EMACS} -f straight-freeze-versions

thaw:
${EMACS} -f straight-thaw-versions

.PHONY: all test unit
127 changes: 95 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,41 +38,53 @@ One can also use `use-package` to automate this entire process

## Dependencies

Only Emacs 27.1+ has been tested
Only Emacs 29.3 has been tested. It will probably work for others.

### Emacs packages

- org-ml.el
- dash.el
- s.el
- f.el
- org-ml.el (5.8.8)
- dash.el (2.19.1)
- s.el (1.13)
- f.el (0.20.0)

Versions indicated those that have been tested. Others may work but are not
guaranteed.

As of version 5.8.8, org-ml.el requires org 9.6.x to work. 9.7.x and later
*will* break.

### Database Clients

Only the client binary for your desired implementation are required (ensure they
are in your PATH):

- sqlite3
- sqlite3
- psql (PostgreSQL)
- mysql (MariaDB/MySQL)
- sqlcmd (SQL-Server)

See the conda environment file at `env-XX.Y.yml` (where XX.Y corresponds to the
emacs version) for the exact versions of the each client used for testing. These
were provided with the following packages:

- sqlite (for sqlite)
- postgresql (for PostgreSQL)
- mysqlclient (for MariaDB and MySQL)
- go-sqlcmd (for SQL-Server)


### Database Servers

The following databases servers/versions are supported and tested:

- PostgreSQL (13, 12, 11, 10, 9)
- MariaDB (10.5, 10.4, 10.3, 10.2)
- MySQL (8.0)
- SQL-Server (2019, 2017)
- PostgreSQL (16, 15, 14, 13)
- MariaDB (11.4, 10.6, 10.5)
- MySQL (8.4, 8.0)
- SQL-Server (2022, 2019, 2017)

Many versions besides these will likely work; these are simply those that are in
the testing suite.

MySQL 5.7 should also work for all functions except `org-sql-pull-from-db`,
which will throw mysterious syntax errors because this function relies on
recursive queries (which don't exist in 5.7).

# Configuration

## General Behavior
Expand Down Expand Up @@ -404,45 +416,64 @@ Contributions welcome! But please take advantage of the testing environment
(especially when contributing to code which directly interacts with the database
servers).

## Dependencies
## Reproducible Environment

In addition to all required dependencies above:
The entire development environment is designed to be self-contained and
reproducible. All binaries (including emacs itself) are specified in a conda
environment, the databases are specified in a docker-compose file, and the
dependencies for emacs are specified in a `straight.el` profile in
`.emacs/XX.Y/straight/versions/default.el`.

- [cask](https://github.com/cask/cask)
- docker
- docker-compose
- [erd](https://github.com/BurntSushi/erd)
- make
The only prerequisites for running this are a working conda and docker-compose
installation.

It isn't stricly necessary to use this, but doing so ensures that all tests run
in a standardized manner across all machines and therefore minimizes 'bit rot
bugs'.

## Emacs setup
### Conda dependencies

Install all emacs dependencies:
Assuming a working mamba installation, install all binary dependencies and
activate:

``` sh
cask install --dev
mamba env create -f env-XX.Y.yml
conda activate env-XX.Y.yml
```

## Test environment setup
### Emacs dependencies

Run the following

``` sh
export LD_PRELOAD=/usr/lib/libc_malloc_debug.so
make install
```

Note, the LD_PRELOAD setting is necessary if one gets and error about undefined
symbols for malloc_set_state. This is necessary for all `make ...` commands.

### Database setup

Except for SQLite, the each database for testing is encoded and set up using
`docker-compose` (see the included `docker-compose.yml` and
`docker-compose.override.yml` files). These are
necessary to run the stateful tests above.
`docker-compose` (see the included `docker-compose.yml` file). These are
necessary to run the stateful tests (see below).

To set up the environment, start the docker-daemon (may require sudo).

``` sh
docker-compose up -d -V
```

Add `--build` to rebuild images if altered (see below).

To shut down the environment:

``` sh
docker-compose down
```

### Dockerfile/Docker-compose Layout
#### Dockerfile/Docker-compose Layout

Customization of the `docker-compose` files should not be necessary except when
adding a new database for testing (or a new version). The 'base' docker images
Expand All @@ -453,7 +484,7 @@ is set to the latest version of the container to pull. Note that MariaDB and
MySQL are assumed to share the exact same container configuration, and thus they
share the same Dockerfile.

## Running tests
### Running tests

Tests are divided into stateless (pure functions, don't rely on external
database implementations) and stateful (impure, interacts with the database
Expand Down Expand Up @@ -483,15 +514,47 @@ Run all tests using both interpreted and compiled code:
make test
```

## Building documentation
### Building documentation

To generate documentation:

```
make docs
```

requires [erd](https://github.com/BurntSushi/erd) (which is unfortunately not in
conda).

## Interactive development

To use Emacs to edit the code of `org-sql`, one has several options, from most
to least reliable.

### Emacs from conda

Simply activate the conda environment set up from above and run emacs from the
shell. This will have all the required dependencies, but also won't have your
personal setup.

### Personal emacs with straight dependencies

More clunkily, if one wants/needs the exact versions of each emacs package, one
can copy the hashes from `emacs.d/XX.Y/straight/versions/default.el` into their
own straight config (or make a new profile).

### Personal emacs config with cask

Install [cask](https://github.com/cask/cask) and run the following (without the
conda env activated):

``` sh
cask install
```

Run emacs as normal, and activate the conda environment to run the tests.

# Acknowledgements

The idea for this is based on [John Kitchin's](http://kitchingroup.cheme.cmu.edu/blog/2017/01/03/Find-stuff-in-org-mode-anywhere/)
The idea for this is based on [John
Kitchin's](http://kitchingroup.cheme.cmu.edu/blog/2017/01/03/Find-stuff-in-org-mode-anywhere/)
implementation, which uses `emacsql` as the SQL backend.
Loading

0 comments on commit 742ed22

Please sign in to comment.