Skip to content

Commit

Permalink
fix(core): handle empty Poetry dev-dependencies (#85)
Browse files Browse the repository at this point in the history
Running pipelinit in a project with a pyproject.toml
file without a poetry dev-dependencies keys would
crash.
  • Loading branch information
oesgalha committed Oct 18, 2021
1 parent 4ae27c3 commit 2fb777d
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 1 deletion.
19 changes: 19 additions & 0 deletions cli/tests/default_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,22 @@ test(
await cleanGitHubFiles("python/requirements-unknown-version");
},
);

test(
{ fixture: "python/requirements-black-and-pyproject", args: [] },
async (proc) => {
const [stdout, _stderr, { code }] = await output(proc);
assertStringIncludes(stdout, "Detected stack: python");
assertStringIncludes(
stdout,
"No linters for python were identified in the project, creating default pipeline with 'flake8' WITHOUT any specific configuration",
);
assertStringIncludes(
stdout,
"No formatters for python were identified in the project, creating default pipeline with 'isort' WITHOUT any specific configuration",
);
assertEquals(code, 0);
await assertExpectedFiles("python/requirements-black-and-pyproject");
await cleanGitHubFiles("python/requirements-black-and-pyproject");
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated with pipelinit 0.1.0
# https://pipelinit.com/
name: Format Python
on:
pull_request:
paths:
- "**.py"
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9"
- run: pip install -r requirements.txt

- run: python -m pip install pip isort

- run: black . --check
- run: isort . -c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated with pipelinit 0.1.0
# https://pipelinit.com/
name: Lint Python
on:
pull_request:
paths:
- "**.py"
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9"
- run: pip install -r requirements.txt

- run: python -m pip install pip flake8

# Adapts Flake8 to run with the Black formatter, using the '--ignore' flag to skip incompatibilities errors
# Reference: https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html?highlight=other%20tools#id1
- run: flake8 --ignore E203,E501,W503 .
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated with pipelinit 0.1.0
# https://pipelinit.com/
name: SAST
on:
pull_request:
paths:
- "**.py"
jobs:
semgrep:
name: Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: returntocorp/semgrep-action@v1
with:
config: >-
p/ci
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
platforms = ["github"]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("Hello World")
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.black]
line-length = 120
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
black==21.9b0
2 changes: 1 addition & 1 deletion core/plugins/stack/python/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const readDependencyFile = async (context: Context) => {
if (poetryDeps) {
dependencies.push(...Object.keys(poetryDeps));
}
const poetryDevDeps = pyproject.tool?.poetry["dev-dependencies"];
const poetryDevDeps = pyproject.tool?.poetry?.["dev-dependencies"];
if (poetryDevDeps) {
dependencies.push(...Object.keys(poetryDevDeps));
}
Expand Down

0 comments on commit 2fb777d

Please sign in to comment.