-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from erichlf/CheckHealth
Breaking: Rename lua directory to devcontainer-cli
- Loading branch information
Showing
13 changed files
with
153 additions
and
75 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 |
---|---|---|
@@ -1,24 +1,19 @@ | ||
--- | ||
on: [push, pull_request] | ||
name: default | ||
|
||
env: | ||
IMAGE_NAME: nvim-devcontainer-cli | ||
|
||
jobs: | ||
docker: | ||
unit-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Pre-build devcontainer image | ||
uses: devcontainers/[email protected] | ||
with: | ||
imageName: ${{ env.IMAGE_NAME }} | ||
imageName: ${{ env.IMAGE_NAME }} | ||
cacheFrom: ${{ env.IMAGE_NAME }} | ||
push: never | ||
|
||
- name: Run tests inside the docker image | ||
uses: devcontainers/[email protected] | ||
with: | ||
|
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
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
lua/devcontainer_cli/devcontainer_cli.lua → lua/devcontainer-cli/devcontainer_cli.lua
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
File renamed without changes.
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,30 @@ | ||
local M = {} | ||
|
||
local start = vim.health.start or vim.health.report_start | ||
local ok = vim.health.ok or vim.health.report_ok | ||
local warn = vim.health.warn or vim.health.report_warn | ||
local error = vim.health.error or vim.health.report_error | ||
|
||
local function verify_binary(binary_name) | ||
if vim.fn.executable(binary_name) ~= 1 then | ||
error(("`%s` executable not found."):format(binary_name), ("Install %s"):format(binary_name)) | ||
else | ||
ok(("`%s` executable found."):format(binary_name)) | ||
end | ||
end | ||
-- TODO: create a check for DevcontainerUp, this needs to be done after | ||
-- creating the ability to stop a container | ||
-- TODO: create a check for DevcontainerExec | ||
|
||
function M.check() | ||
start("devcontainer-cli") | ||
local required_binaries = { | ||
"docker", | ||
"devcontainer", | ||
} | ||
for _, bin_name in ipairs(required_binaries) do | ||
verify_binary(bin_name) | ||
end | ||
end | ||
|
||
return M |
4 changes: 2 additions & 2 deletions
4
lua/devcontainer_cli/init.lua → lua/devcontainer-cli/init.lua
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
2 changes: 1 addition & 1 deletion
2
lua/devcontainer_cli/windows_utils.lua → lua/devcontainer-cli/windows_utils.lua
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 was deleted.
Oops, something went wrong.
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,62 @@ | ||
local folder_utils = require("devcontainer-cli.folder_utils") | ||
local utils = require("devcontainer-cli.devcontainer_utils") | ||
|
||
describe("folder_utils.get_root:", function() | ||
it( | ||
"check if first devcontainer directory when toplevel is false", | ||
function() | ||
-- dbg() | ||
-- This test assumes that we are in the root folder of the project | ||
local project_root = vim.fn.getcwd() | ||
-- We change the current directory to a subfolder | ||
vim.fn.chdir("lua/devcontainer-cli") | ||
local devcontainer_cli_folder = vim.fn.getcwd() | ||
-- First we check that the we properly changed the directory | ||
assert(devcontainer_cli_folder == project_root .. "/lua/devcontainer-cli") | ||
-- Verify that the project root is at the current level when toplevel is false | ||
local root_folder = folder_utils.get_root(false) | ||
-- From the subfolder, we check that the get_root function returns the folder where the git repo is located instead of the CWD | ||
print("ROOT: " .. root_folder) | ||
print("PROJECT_ROOT: " .. project_root) | ||
assert(root_folder == project_root) | ||
-- After running the test we come back to the initial location | ||
vim.fn.chdir(project_root) | ||
end | ||
) | ||
end) | ||
|
||
describe("folder_utils.get_root:", function() | ||
it( | ||
"check if top most devcontainer directory when toplevel is true", | ||
function() | ||
-- dbg() | ||
-- This test assumes that we are in the root folder of the project | ||
local project_root = vim.fn.getcwd() | ||
-- We change the current directory to a subfolder | ||
vim.fn.chdir("lua/devcontainer-cli") | ||
local devcontainer_cli_folder = vim.fn.getcwd() | ||
-- First we check that the we properly changed the directory | ||
assert(devcontainer_cli_folder == project_root .. "/lua/devcontainer-cli") | ||
|
||
-- Verify that the project root is at HOME (location of top most devcontainer directory) when toplevel is true | ||
project_root = os.getenv("HOME") | ||
local root_folder = folder_utils.get_root(true) | ||
|
||
-- From the subfolder, we check that the get_root function returns the folder where the git repo is located instead of the CWD | ||
print("ROOT: " .. root_folder) | ||
print("PROJECT_ROOT: " .. project_root) | ||
assert(root_folder == project_root) | ||
|
||
vim.fn.chdir(project_root) | ||
end | ||
) | ||
end) | ||
|
||
describe("devcontainer_utils.exec_command:", function() | ||
it( | ||
"check if a command can be executed", | ||
function() | ||
utils.exec_command("echo 'Hello World!'") | ||
end | ||
) | ||
end) |