Skip to content

Commit

Permalink
Add gitlab workflow extension to VSCode
Browse files Browse the repository at this point in the history
  • Loading branch information
lukin0110 committed Nov 30, 2024
1 parent ff88e12 commit ab88c6b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
5 changes: 3 additions & 2 deletions template/.devcontainer/devcontainer.json.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
"extensions": [
"charliermarsh.ruff",
"eamodio.gitlens",
"github.copilot",
"github.copilot",{% if ci =='github' %}
"GitHub.vscode-github-actions",
"GitHub.vscode-pull-request-github",
"GitHub.vscode-pull-request-github",{% elif ci == 'gitlab' %}
"GitLab.gitlab-workflow",{% endif %}
"ms-azuretools.vscode-docker",
"ms-python.mypy-type-checker",
"ms-python.python",
Expand Down
4 changes: 2 additions & 2 deletions testing/tests/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_github_generation(answers: dict[str, str | bool], expected_paths: set[s
".github/dependabot.yml",
}
assert_paths(tmpdir, expected)
assert_devcontainer(Path(tmpdir) / ".devcontainer/devcontainer.json")
assert_devcontainer(Path(tmpdir) / ".devcontainer/devcontainer.json", github=True)
assert_toml(Path(tmpdir) / "pyproject.toml")
assert_yaml(Path(tmpdir) / ".pre-commit-config.yaml")
assert_yaml(Path(tmpdir) / "docker-compose.yml")
Expand All @@ -47,7 +47,7 @@ def test_gitlab_generation(answers: dict[str, str | bool], expected_paths: set[s
copier.run_copy(str(_path.absolute()), tmpdir, data=answers_, cleanup_on_error=True)
expected = expected_paths | {".gitlab-ci.yml"}
assert_paths(tmpdir, expected)
assert_devcontainer(Path(tmpdir) / ".devcontainer/devcontainer.json")
assert_devcontainer(Path(tmpdir) / ".devcontainer/devcontainer.json", gitlab=True)
assert_toml(Path(tmpdir) / "pyproject.toml")
assert_yaml(Path(tmpdir) / ".pre-commit-config.yaml")
assert_yaml(Path(tmpdir) / "docker-compose.yml")
Expand Down
15 changes: 12 additions & 3 deletions testing/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def assert_paths(directory: str, paths: set[str]) -> None:
------
AssertionError
If any of the paths in the set are not found in the directory.
"""
tree = set()
for root, _, files in os.walk(directory):
Expand Down Expand Up @@ -57,8 +58,17 @@ def assert_yaml(path: Path) -> dict[str, Any]:
raise AssertionError(f"Could not load: {path}") from e


def assert_devcontainer(path: Path) -> None:
def assert_devcontainer(path: Path, /, github: bool = False, gitlab: bool = False) -> None:
"""Check if the given path is a valid devcontainer definition."""
if github:
extensions = [
"GitHub.vscode-github-actions",
"GitHub.vscode-pull-request-github",
]
elif gitlab:
extensions = ["GitLab.gitlab-workflow"]
else:
extensions = []
try:
with path.open("r") as fh:
data = json.load(fh)
Expand All @@ -80,8 +90,7 @@ def assert_devcontainer(path: Path) -> None:
"charliermarsh.ruff",
"eamodio.gitlens",
"github.copilot",
"GitHub.vscode-github-actions",
"GitHub.vscode-pull-request-github",
*extensions,
"ms-azuretools.vscode-docker",
"ms-python.mypy-type-checker",
"ms-python.python",
Expand Down

0 comments on commit ab88c6b

Please # to comment.