Skip to content

Commit fcb071d

Browse files
authored
feat(docker): Add docker command (#188)
* feat(docker): Add docker command * Add docker test * Ignore test on windows * docs: * docs: Update changelog
1 parent 918633e commit fcb071d

File tree

13 files changed

+392
-120
lines changed

13 files changed

+392
-120
lines changed

.github/workflows/docker.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- 'eask'
9+
- '**.yml'
10+
- lisp/**
11+
- cmds/**
12+
- src/**
13+
- test/**
14+
pull_request:
15+
branches:
16+
- master
17+
paths-ignore:
18+
- '**.md'
19+
workflow_dispatch:
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
test:
27+
runs-on: ${{ matrix.os }}
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
os:
32+
- ubuntu-latest
33+
- macos-latest
34+
#- windows-latest # XXX: Docker is not supported on Windows!
35+
emacs-version:
36+
- 29.1
37+
38+
steps:
39+
- uses: jcs090218/setup-emacs@master
40+
with:
41+
version: ${{ matrix.emacs-version }}
42+
43+
- uses: actions/checkout@v4
44+
45+
- name: Prepare Eask (Unix)
46+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
47+
run: |
48+
chmod -R 777 ./
49+
.github/scripts/setup-eask
50+
51+
- name: Prepare Eask (Windows)
52+
if: matrix.os == 'windows-latest'
53+
run: .github/scripts/setup-eask.ps1
54+
55+
- name: Testing...
56+
run: |
57+
make command-docker

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
2929
* Print archives progress (#184)
3030
* Respect package file path in `autoload` command (44c042445bba0dd071d9112e58549437b7ebd58d)
3131
* fix(vcpkg): Use workaround for `MODULE_NOT_FOUND` error (#187)
32+
* Add docker command (#188)
3233

3334
## 0.8.x
3435
> Released Mar 08, 2023

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ command-check-eask:
3636
./test/checker/dsl/run.sh
3737
./test/checker/metadata/run.sh
3838

39+
command-docker:
40+
./test/commands/docker/run.sh
41+
3942
command-exec:
4043
./test/commands/exec/run.sh
4144

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ information.*
6464
| Test commands in development (`./`) mode || [![Local](https://github.com/emacs-eask/cli/actions/workflows/local.yml/badge.svg)](https://github.com/emacs-eask/cli/actions/workflows/local.yml) |
6565
| Test install packages || [![Install](https://github.com/emacs-eask/cli/actions/workflows/install.yml/badge.svg)](https://github.com/emacs-eask/cli/actions/workflows/install.yml) |
6666
| Test link packages || [![Link](https://github.com/emacs-eask/cli/actions/workflows/link.yml/badge.svg)](https://github.com/emacs-eask/cli/actions/workflows/link.yml) |
67-
| Test execute commands || [![Exec](https://github.com/emacs-eask/cli/actions/workflows/exec.yml/badge.svg)](https://github.com/emacs-eask/cli/actions/workflows/exec.yml) |
68-
| Test emacs commands || [![Emacs](https://github.com/emacs-eask/cli/actions/workflows/emacs.yml/badge.svg)](https://github.com/emacs-eask/cli/actions/workflows/emacs.yml) |
67+
| Test `docker` command || [![Docker](https://github.com/emacs-eask/cli/actions/workflows/docker.yml/badge.svg)](https://github.com/emacs-eask/cli/actions/workflows/docker.yml) |
68+
| Test `exec` command || [![Exec](https://github.com/emacs-eask/cli/actions/workflows/exec.yml/badge.svg)](https://github.com/emacs-eask/cli/actions/workflows/exec.yml) |
69+
| Test `emacs` command || [![Emacs](https://github.com/emacs-eask/cli/actions/workflows/emacs.yml/badge.svg)](https://github.com/emacs-eask/cli/actions/workflows/emacs.yml) |
6970
| Test search packages || [![Search](https://github.com/emacs-eask/cli/actions/workflows/search.yml/badge.svg)](https://github.com/emacs-eask/cli/actions/workflows/search.yml) |
7071
| Test upgrade and check outdated packages || [![Outdated_Upgrade](https://github.com/emacs-eask/cli/actions/workflows/outdated_upgrade.yml/badge.svg)](https://github.com/emacs-eask/cli/actions/workflows/outdated_upgrade.yml) |
7172
| `Eask`-file checker || [![Checker](https://github.com/emacs-eask/cli/actions/workflows/checker.yml/badge.svg)](https://github.com/emacs-eask/cli/actions/workflows/checker.yml) |

cmds/core/docker.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* Copyright (C) 2023 Jen-Chieh Shen
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 3, or (at your option)
7+
* any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with GNU Emacs; see the file COPYING. If not, write to the
16+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17+
* Boston, MA 02110-1301, USA.
18+
*/
19+
20+
"use strict";
21+
22+
const path = require('path');
23+
const child_process = require("child_process");
24+
25+
exports.command = ['docker <version> [args..]'];
26+
exports.desc = 'Launch specified Emacs version in a Docker container';
27+
exports.builder = async (yargs) => {
28+
yargs.help(false);
29+
yargs.version(false);
30+
yargs.getOptions().narg = [];
31+
yargs.positional('<version>', {
32+
description: 'Emacs version to test',
33+
type: 'string',
34+
});
35+
};
36+
37+
exports.handler = async (argv) => {
38+
if (!UTIL.which('docker')) {
39+
console.log("Docker is not installed (cannot find `docker' executable)");
40+
return;
41+
}
42+
43+
let project_dir = convert_path(process.cwd());
44+
if (!project_dir.startsWith('/')) {
45+
project_dir = '/' + project_dir;
46+
}
47+
let container_dir = '/' + path.basename(project_dir);
48+
49+
let container_arg = project_dir + ':' + container_dir;
50+
51+
let default_cmd = ['docker', 'run', '--rm',
52+
'-v', container_arg,
53+
'-w', container_dir,
54+
'silex/emacs:' + argv.version + '-ci-eask',
55+
'eask'];
56+
let rest = process.argv.slice(4);
57+
let cmd = default_cmd.concat(rest);
58+
59+
let proc = child_process.spawn(UTIL.cli_args(cmd), { stdio: 'inherit', shell: true });
60+
61+
proc.on('close', function (code) {
62+
if (code == 0) return;
63+
process.exit(code);
64+
});
65+
};
66+
67+
/**
68+
* Convert path so docker can recognize!
69+
* @param { String } path - Path to convert.
70+
*/
71+
function convert_path(path) {
72+
return UTIL.slash(path).replaceAll(':', '');
73+
}

docs/content/en/Getting-Started/Basic-Usage/_index.md

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,41 +32,42 @@ Eask is a command-line tool that helps you build, lint, and test Emacs Lisp pack
3232
Usage: eask <command> [options..]
3333
3434
Commands:
35-
archives List out all package archives [aliases: sources]
36-
clean <type> Delete various files produced during building
37-
compile [names..] Byte compile all Emacs Lisp files in the package
38-
create <type> Create a new elisp project
39-
emacs [args..] Execute emacs with the appropriate environment
40-
eval [form] Evaluate lisp form with a proper PATH
41-
path [patterns..] Print the PATH (exec-path) from workspace [aliases: exec-path]
42-
exec [args..] Execute command with correct environment PATH set up
43-
files [patterns..] Print all package files
44-
generate <type> Generate files that are used for the development
45-
info Display information about the current package
46-
init [files..] Initialize project to use Eask
47-
install-deps Automatically install package dependencies [aliases: install-dependencies, prepare]
48-
install [names..] Install packages
49-
keywords List available keywords that can be used in the header section
50-
link <action> Manage links
51-
lint <type> Run linter
52-
list List packages
53-
load-path [patterns..] Print the load-path from workspace
54-
load [files..] Load elisp files
55-
outdated Show all outdated dependencies
56-
package-directory Print path to package directory
57-
package [destination] Build a package artifact, and put it into the given destination
58-
recipe Suggest a recipe format
59-
refresh Download package archives
60-
reinstall [names..] Reinstall packages
61-
run [names..] Run the script named [names..] [aliases: run-script]
62-
search [queries..] Search packages
63-
status Display the state of the workspace
64-
test <type> Run test
65-
uninstall [names..] Uninstall packages [aliases: delete]
66-
upgrade [names..] Upgrade packages
67-
check-eask [files..] Run eask checker
68-
locate Print out Eask installed location
69-
upgrade-eask Upgrade Eask itself [aliases: upgrade-self]
35+
archives List out all package archives [aliases: sources]
36+
clean <type> Delete various files produced during building
37+
compile [names..] Byte compile all Emacs Lisp files in the package
38+
create <type> Create a new elisp project
39+
docker <version> [args..] Launch specified Emacs version in a Docker container
40+
emacs [args..] Execute emacs with the appropriate environment
41+
eval [form] Evaluate lisp form with a proper PATH
42+
path [patterns..] Print the PATH (exec-path) from workspace [aliases: exec-path]
43+
exec [args..] Execute command with correct environment PATH set up
44+
files [patterns..] Print all package files
45+
generate <type> Generate files that are used for the development
46+
info Display information about the current package
47+
init [files..] Initialize project to use Eask
48+
install-deps Automatically install package dependencies [aliases: install-dependencies, prepare]
49+
install [names..] Install packages
50+
keywords List available keywords that can be used in the header section
51+
link <action> Manage links
52+
lint <type> Run linter
53+
list List packages
54+
load-path [patterns..] Print the load-path from workspace
55+
load [files..] Load elisp files
56+
outdated Show all outdated dependencies
57+
package-directory Print path to package directory
58+
package [destination] Build a package artifact, and put it into the given destination
59+
recipe Suggest a recipe format
60+
refresh Download package archives
61+
reinstall [names..] Reinstall packages
62+
run [names..] Run the script named [names..] [aliases: run-script]
63+
search [queries..] Search packages
64+
status Display the state of the workspace
65+
test <type> Run test
66+
uninstall [names..] Uninstall packages [aliases: delete]
67+
upgrade [names..] Upgrade packages
68+
check-eask [files..] Run eask checker
69+
locate Print out Eask installed location
70+
upgrade-eask Upgrade Eask itself [aliases: upgrade-self]
7071
7172
Proxy Options:
7273
--proxy update proxy for HTTP and HTTPS to host [string]

docs/content/en/Getting-Started/Commands-and-options.md

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -233,30 +233,6 @@ $ eask [GLOBAL-OPTIONS] files [PATTERNS..]
233233

234234
If `[PATTERNS..]` are defined, it will display files that match that pattern.
235235

236-
## 🔍 eask exec
237-
238-
Execute the system command with the given arguments.
239-
240-
```sh
241-
$ eask [GLOBAL-OPTIONS] exec [COMMAND] [ARGUMENTS ...]
242-
```
243-
244-
## 🔍 eask emacs
245-
246-
Execute emacs with the appropriate environment.
247-
248-
```sh
249-
$ eask [GLOBAL-OPTIONS] emacs [ARGUMENTS ...]
250-
```
251-
252-
## 🔍 eask eval
253-
254-
Evaluate `FORM` as a lisp form.
255-
256-
```sh
257-
$ eask [GLOBAL-OPTIONS] eval [FORM]
258-
```
259-
260236
## 🔍 eask load
261237

262238
Load Emacs Lisp files in order.
@@ -314,6 +290,50 @@ $ eask [GLOBAL-OPTIONS] run [FILES..]
314290

315291
Alias: `run-script`
316292

293+
# 🚩 Execution
294+
295+
296+
## 🔍 eask exec
297+
298+
Execute the system command with the given arguments.
299+
300+
```sh
301+
$ eask [GLOBAL-OPTIONS] exec [COMMAND] [ARGUMENTS ...]
302+
```
303+
304+
## 🔍 eask emacs
305+
306+
Execute emacs with the appropriate environment.
307+
308+
```sh
309+
$ eask [GLOBAL-OPTIONS] emacs [ARGUMENTS ...]
310+
```
311+
312+
## 🔍 eask eval
313+
314+
Evaluate `FORM` as a lisp form.
315+
316+
```sh
317+
$ eask [GLOBAL-OPTIONS] eval [FORM]
318+
```
319+
320+
## 🔍 eask docker
321+
322+
Launch specified Emacs version in a Docker container.
323+
324+
```sh
325+
$ eask [GLOBAL-OPTIONS] docker <VERSION> [ARGUMENTS ...]
326+
```
327+
328+
For example:
329+
330+
```sh
331+
$ eask docker 26.1 info
332+
```
333+
334+
This is the same as jumping right into Emacs 26.1 (in docker) and executing
335+
`eask info`.
336+
317337
# 🚩 Management
318338

319339
## 🔍 eask archives

0 commit comments

Comments
 (0)