-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docker): Add docker command (#188)
* feat(docker): Add docker command * Add docker test * Ignore test on windows * docs: * docs: Update changelog
- Loading branch information
Showing
13 changed files
with
392 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(':', ''); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.