Skip to content

Commit

Permalink
feat(docker): Add docker command (#188)
Browse files Browse the repository at this point in the history
* feat(docker): Add docker command

* Add docker test

* Ignore test on windows

* docs:

* docs: Update changelog
  • Loading branch information
jcs090218 authored Sep 20, 2023
1 parent 918633e commit fcb071d
Show file tree
Hide file tree
Showing 13 changed files with 392 additions and 120 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Docker

on:
push:
branches:
- master
paths:
- 'eask'
- '**.yml'
- lisp/**
- cmds/**
- src/**
- test/**
pull_request:
branches:
- master
paths-ignore:
- '**.md'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
#- windows-latest # XXX: Docker is not supported on Windows!
emacs-version:
- 29.1

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

- uses: actions/checkout@v4

- name: Prepare Eask (Unix)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: |
chmod -R 777 ./
.github/scripts/setup-eask
- name: Prepare Eask (Windows)
if: matrix.os == 'windows-latest'
run: .github/scripts/setup-eask.ps1

- name: Testing...
run: |
make command-docker
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
* Print archives progress (#184)
* Respect package file path in `autoload` command (44c042445bba0dd071d9112e58549437b7ebd58d)
* fix(vcpkg): Use workaround for `MODULE_NOT_FOUND` error (#187)
* Add docker command (#188)

## 0.8.x
> Released Mar 08, 2023
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ command-check-eask:
./test/checker/dsl/run.sh
./test/checker/metadata/run.sh

command-docker:
./test/commands/docker/run.sh

command-exec:
./test/commands/exec/run.sh

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ information.*
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| `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) |
Expand Down
73 changes: 73 additions & 0 deletions cmds/core/docker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* Copyright (C) 2023 Jen-Chieh Shen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Emacs; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/

"use strict";

const path = require('path');
const child_process = require("child_process");

exports.command = ['docker <version> [args..]'];
exports.desc = 'Launch specified Emacs version in a Docker container';
exports.builder = async (yargs) => {
yargs.help(false);
yargs.version(false);
yargs.getOptions().narg = [];
yargs.positional('<version>', {
description: 'Emacs version to test',
type: 'string',
});
};

exports.handler = async (argv) => {
if (!UTIL.which('docker')) {
console.log("Docker is not installed (cannot find `docker' executable)");
return;
}

let project_dir = convert_path(process.cwd());
if (!project_dir.startsWith('/')) {
project_dir = '/' + project_dir;
}
let container_dir = '/' + path.basename(project_dir);

let container_arg = project_dir + ':' + container_dir;

let default_cmd = ['docker', 'run', '--rm',
'-v', container_arg,
'-w', container_dir,
'silex/emacs:' + argv.version + '-ci-eask',
'eask'];
let rest = process.argv.slice(4);
let cmd = default_cmd.concat(rest);

let proc = child_process.spawn(UTIL.cli_args(cmd), { stdio: 'inherit', shell: true });

proc.on('close', function (code) {
if (code == 0) return;
process.exit(code);
});
};

/**
* Convert path so docker can recognize!
* @param { String } path - Path to convert.
*/
function convert_path(path) {
return UTIL.slash(path).replaceAll(':', '');
}
71 changes: 36 additions & 35 deletions docs/content/en/Getting-Started/Basic-Usage/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,41 +32,42 @@ Eask is a command-line tool that helps you build, lint, and test Emacs Lisp pack
Usage: eask <command> [options..]
Commands:
archives List out all package archives [aliases: sources]
clean <type> Delete various files produced during building
compile [names..] Byte compile all Emacs Lisp files in the package
create <type> Create a new elisp project
emacs [args..] Execute emacs with the appropriate environment
eval [form] Evaluate lisp form with a proper PATH
path [patterns..] Print the PATH (exec-path) from workspace [aliases: exec-path]
exec [args..] Execute command with correct environment PATH set up
files [patterns..] Print all package files
generate <type> Generate files that are used for the development
info Display information about the current package
init [files..] Initialize project to use Eask
install-deps Automatically install package dependencies [aliases: install-dependencies, prepare]
install [names..] Install packages
keywords List available keywords that can be used in the header section
link <action> Manage links
lint <type> Run linter
list List packages
load-path [patterns..] Print the load-path from workspace
load [files..] Load elisp files
outdated Show all outdated dependencies
package-directory Print path to package directory
package [destination] Build a package artifact, and put it into the given destination
recipe Suggest a recipe format
refresh Download package archives
reinstall [names..] Reinstall packages
run [names..] Run the script named [names..] [aliases: run-script]
search [queries..] Search packages
status Display the state of the workspace
test <type> Run test
uninstall [names..] Uninstall packages [aliases: delete]
upgrade [names..] Upgrade packages
check-eask [files..] Run eask checker
locate Print out Eask installed location
upgrade-eask Upgrade Eask itself [aliases: upgrade-self]
archives List out all package archives [aliases: sources]
clean <type> Delete various files produced during building
compile [names..] Byte compile all Emacs Lisp files in the package
create <type> Create a new elisp project
docker <version> [args..] Launch specified Emacs version in a Docker container
emacs [args..] Execute emacs with the appropriate environment
eval [form] Evaluate lisp form with a proper PATH
path [patterns..] Print the PATH (exec-path) from workspace [aliases: exec-path]
exec [args..] Execute command with correct environment PATH set up
files [patterns..] Print all package files
generate <type> Generate files that are used for the development
info Display information about the current package
init [files..] Initialize project to use Eask
install-deps Automatically install package dependencies [aliases: install-dependencies, prepare]
install [names..] Install packages
keywords List available keywords that can be used in the header section
link <action> Manage links
lint <type> Run linter
list List packages
load-path [patterns..] Print the load-path from workspace
load [files..] Load elisp files
outdated Show all outdated dependencies
package-directory Print path to package directory
package [destination] Build a package artifact, and put it into the given destination
recipe Suggest a recipe format
refresh Download package archives
reinstall [names..] Reinstall packages
run [names..] Run the script named [names..] [aliases: run-script]
search [queries..] Search packages
status Display the state of the workspace
test <type> Run test
uninstall [names..] Uninstall packages [aliases: delete]
upgrade [names..] Upgrade packages
check-eask [files..] Run eask checker
locate Print out Eask installed location
upgrade-eask Upgrade Eask itself [aliases: upgrade-self]
Proxy Options:
--proxy update proxy for HTTP and HTTPS to host [string]
Expand Down
68 changes: 44 additions & 24 deletions docs/content/en/Getting-Started/Commands-and-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,30 +233,6 @@ $ eask [GLOBAL-OPTIONS] files [PATTERNS..]

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

## 🔍 eask exec

Execute the system command with the given arguments.

```sh
$ eask [GLOBAL-OPTIONS] exec [COMMAND] [ARGUMENTS ...]
```

## 🔍 eask emacs

Execute emacs with the appropriate environment.

```sh
$ eask [GLOBAL-OPTIONS] emacs [ARGUMENTS ...]
```

## 🔍 eask eval

Evaluate `FORM` as a lisp form.

```sh
$ eask [GLOBAL-OPTIONS] eval [FORM]
```

## 🔍 eask load

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

Alias: `run-script`

# 🚩 Execution


## 🔍 eask exec

Execute the system command with the given arguments.

```sh
$ eask [GLOBAL-OPTIONS] exec [COMMAND] [ARGUMENTS ...]
```

## 🔍 eask emacs

Execute emacs with the appropriate environment.

```sh
$ eask [GLOBAL-OPTIONS] emacs [ARGUMENTS ...]
```

## 🔍 eask eval

Evaluate `FORM` as a lisp form.

```sh
$ eask [GLOBAL-OPTIONS] eval [FORM]
```

## 🔍 eask docker

Launch specified Emacs version in a Docker container.

```sh
$ eask [GLOBAL-OPTIONS] docker <VERSION> [ARGUMENTS ...]
```

For example:

```sh
$ eask docker 26.1 info
```

This is the same as jumping right into Emacs 26.1 (in docker) and executing
`eask info`.

# 🚩 Management

## 🔍 eask archives
Expand Down
Loading

0 comments on commit fcb071d

Please sign in to comment.