Skip to content

Commit 065b294

Browse files
committed
sync CI/build scripts with other CWL projects
1 parent 58124cd commit 065b294

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+4170
-88
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ updates:
1515
- dependency-name: mypy
1616
versions:
1717
- "0.800"
18+
# Maintain dependencies for GitHub Actions
19+
- package-ecosystem: "github-actions"
20+
directory: "/"
21+
schedule:
22+
interval: "daily"

.github/workflows/ci-tests.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ on:
55
branches: [ main ]
66
pull_request:
77
branches: [ main ]
8-
workflow_dispatch:
8+
9+
concurrency:
10+
group: build-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
912

1013
env:
1114
singularity_version: 3.6.4
@@ -20,8 +23,8 @@ jobs:
2023
strategy:
2124
matrix:
2225
py-ver-major: [3]
23-
py-ver-minor: [6, 7, 8, 9]
24-
step: [lint, unit, mypy]
26+
py-ver-minor: [6, 7, 8, 9, 10]
27+
step: [lint, unit, bandit, mypy]
2528

2629
env:
2730
py-semver: ${{ format('{0}.{1}', matrix.py-ver-major, matrix.py-ver-minor) }}
@@ -38,10 +41,6 @@ jobs:
3841
with:
3942
singularity-version: ${{ env.singularity_version }}
4043

41-
- name: Give the test runner user a name to make provenance happy.
42-
if: ${{ matrix.step == 'unit' || matrix.step == 'mypy' }}
43-
run: sudo usermod -c 'CI Runner' $(whoami)
44-
4544
- name: Set up Python
4645
uses: actions/setup-python@v2
4746
with:
@@ -70,7 +69,7 @@ jobs:
7069

7170
- name: Upload coverage to Codecov
7271
if: ${{ matrix.step == 'unit' }}
73-
uses: codecov/codecov-action@v1
72+
uses: codecov/codecov-action@v2.1.0
7473
with:
7574
fail_ci_if_error: true
7675

@@ -84,8 +83,8 @@ jobs:
8483
step: [lint-readme, pydocstyle]
8584

8685
env:
87-
py-semver: 3.9
88-
TOXENV: ${{ format('py39-{0}', matrix.step) }}
86+
py-semver: "3.10"
87+
TOXENV: ${{ format('py310-{0}', matrix.step) }}
8988

9089
steps:
9190
- uses: actions/checkout@v2
@@ -115,7 +114,6 @@ jobs:
115114
- name: Test with tox
116115
run: tox
117116

118-
119117
release_test:
120118
name: cwl-utils release test
121119

@@ -132,10 +130,7 @@ jobs:
132130
- name: Set up Python
133131
uses: actions/setup-python@v2
134132
with:
135-
python-version: 3.9
136-
137-
- name: Give the test runner user a name to make provenance happy.
138-
run: sudo usermod -c 'CI Runner' $(whoami)
133+
python-version: "3.10" # quoted, otherwise that turns into the number 3.1
139134

140135
- name: Cache for pip
141136
uses: actions/cache@v2

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
schedule:
77
- cron: '0 0 * * 0'
88

9+
concurrency:
10+
group: build-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
CodeQL-Build:
1115

Makefile

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,23 @@
2121
# make coverage-report to check coverage of the python scripts by the tests
2222

2323
MODULE=cwl_utils
24+
PACKAGE=cwl-utils
25+
EXTRAS=
2426

2527
# `SHELL=bash` doesn't work for some, so don't use BASH-isms like
2628
# `[[` conditional expressions.
2729
PYSOURCES=$(filter-out parser/cwl_v%,$(shell find $(MODULE) -name "*.py")) $(wildcard tests/*.py) *.py
28-
DEVPKGS=diff_cover black pylint coverage pep257 pydocstyle flake8 mypy\
29-
isort wheel autoflake
30+
DEVPKGS=diff_cover black pylint pep257 pydocstyle flake8 tox tox-pyenv \
31+
isort wheel autoflake flake8-bugbear pyupgrade bandit \
32+
-rtest-requirements.txt -rmypy-requirements.txt
3033
DEBDEVPKGS=pep8 python-autopep8 pylint python-coverage pydocstyle sloccount \
3134
python-flake8 python-mock shellcheck
3235
VERSION=$(shell awk '{print $3}' < cwl_utils/__meta__.py )
3336
mkfile_dir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
3437
UNAME_S=$(shell uname -s)
3538

3639
## all : default task
37-
all:
38-
pip install -e .
40+
all: dev
3941

4042
## help : print this help message and exit
4143
help: Makefile
@@ -46,20 +48,19 @@ install-dep: install-dependencies
4648

4749
install-dependencies:
4850
pip install --upgrade $(DEVPKGS)
49-
pip install -r requirements.txt -r mypy_requirements.txt -r docs/requirements.txt
51+
pip install -r requirements.txt -r mypy-requirements.txt -r docs/requirements.txt
5052

5153
## install-deb-dep: install most of the dev dependencies via apt-get
5254
install-deb-dep:
5355
sudo apt-get install $(DEBDEVPKGS)
5456

55-
## install : install the ${MODULE} module and schema-salad-tool
57+
## install : install the ${MODULE} module and scripts
5658
install: FORCE
57-
pip install .[deps]
59+
pip install .$(EXTRAS)
5860

5961
## dev : install the ${MODULE} module in dev mode
6062
dev: install-dep
61-
pip install -e .[deps]
62-
63+
pip install -e .$(EXTRAS)
6364

6465
## dist : create a module package for distribution
6566
dist: dist/${MODULE}-$(VERSION).tar.gz
@@ -101,12 +102,15 @@ diff_pydocstyle_report: pydocstyle_report.txt
101102
format: $(PYSOURCES)
102103
black $^
103104

105+
format-check: $(PYSOURCES)
106+
black --diff --check $^
107+
104108
## pylint : run static code analysis on Python code
105109
pylint: $(PYSOURCES)
106110
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
107111
$^ -j0|| true
108112

109-
pylint_report.txt: ${PYSOURCES}
113+
pylint_report.txt: $(PYSOURCES)
110114
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
111115
$^ -j0> $@ || true
112116

@@ -138,17 +142,17 @@ diff-cover.html: coverage.xml
138142

139143
## test : run the ${MODULE} test suite
140144
test: $(PYSOURCES)
141-
pytest # --addopts "-n auto --dist=loadfile"
145+
python setup.py test ${PYTEST_EXTRA}
142146

143147
## testcov : run the ${MODULE} test suite and collect coverage
144148
testcov: $(PYSOURCES)
145-
pytest --cov ${MODULE} # -n auto --dist=loadfile"
149+
python setup.py test --addopts "--cov" ${PYTEST_EXTRA}
146150

147-
sloccount.sc: ${PYSOURCES} Makefile
151+
sloccount.sc: $(PYSOURCES) Makefile
148152
sloccount --duplicates --wide --details $^ > $@
149153

150154
## sloccount : count lines of code
151-
sloccount: ${PYSOURCES} Makefile
155+
sloccount: $(PYSOURCES) Makefile
152156
sloccount $^
153157

154158
list-author-emails:
@@ -165,17 +169,24 @@ mypy: $(filter-out setup.py,${PYSOURCES})
165169
fi # if minimally required ruamel.yaml version is 0.15.99 or greater, than the above can be removed
166170
MYPYPATH=$$MYPYPATH:typeshed mypy $^
167171

172+
pyupgrade: $(PYSOURCES)
173+
pyupgrade --exit-zero-even-if-changed --py36-plus $^
174+
168175
release-test: FORCE
169176
git diff-index --quiet HEAD -- || ( echo You have uncommited changes, please commit them and try again; false )
170177
./release-test.sh
171178

172179
release: release-test
173180
. testenv2/bin/activate && \
174-
python testenv2/src/${MODULE}/setup.py sdist bdist_wheel && \
181+
python testenv2/src/${PACKAGE}/setup.py sdist bdist_wheel
182+
. testenv2/bin/activate && \
175183
pip install twine && \
176-
twine upload testenv2/src/${MODULE}/dist/* && \
184+
twine upload testenv2/src/${PACKAGE}/dist/* && \
177185
git tag ${VERSION} && git push --tags
178186

187+
flake8: $(PYSOURCES)
188+
flake8 $^
189+
179190
FORCE:
180191

181192
# Use this to print the value of a Makefile variable
File renamed without changes.

cwl_utils/cwl_expression_refactor.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,25 @@
77
import shutil
88
import sys
99
from pathlib import Path
10-
from typing import Any, Callable, Dict, List, MutableSequence, Optional, Tuple, Union
10+
from typing import (
11+
Any,
12+
Callable,
13+
Dict,
14+
List,
15+
MutableSequence,
16+
Optional,
17+
Tuple,
18+
Union,
19+
TYPE_CHECKING,
20+
)
1121

1222
from cwltool.loghandler import _logger as _cwltoollogger
1323
from ruamel import yaml
14-
from typing_extensions import Protocol
24+
25+
if TYPE_CHECKING:
26+
from typing_extensions import Protocol
27+
else:
28+
Protocol = object
1529

1630
_logger = logging.getLogger("cwl-expression-refactor") # pylint: disable=invalid-name
1731
defaultStreamHandler = logging.StreamHandler() # pylint: disable=invalid-name

cwl_utils/cwl_v1_0_expression_refactor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def expand_stream_shortcuts(process: cwl.CommandLineTool) -> cwl.CommandLineTool
4242
stdout_path = process.stdout
4343
if not stdout_path:
4444
stdout_path = str(
45-
hashlib.sha1(
45+
hashlib.sha1( # nosec
4646
json_dumps(cwl.save(process)).encode("utf-8")
4747
).hexdigest()
4848
)
@@ -101,7 +101,7 @@ def get_expression(
101101
"cores": 0,
102102
"ram": 0,
103103
"outdir": "/root",
104-
"tmpdir": "/tmp",
104+
"tmpdir": "/tmp", # nosec
105105
"outdirSize": 0,
106106
"tmpdirSize": 0,
107107
}
@@ -1446,8 +1446,8 @@ def traverse_CommandLineTool(
14461446
"basename": "base.name",
14471447
"nameroot": "base",
14481448
"nameext": "name",
1449-
"path": "/tmp/base.name",
1450-
"dirname": "/tmp",
1449+
"path": "/tmp/base.name", # nosec
1450+
"dirname": "/tmp", # nosec
14511451
}
14521452
]
14531453
if outp.outputBinding.loadContents:

cwl_utils/cwl_v1_1_expression_refactor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def expand_stream_shortcuts(process: cwl.CommandLineTool) -> cwl.CommandLineTool
4242
stdout_path = process.stdout
4343
if not stdout_path:
4444
stdout_path = str(
45-
hashlib.sha1(
45+
hashlib.sha1( # nosec
4646
json_dumps(cwl.save(process)).encode("utf-8")
4747
).hexdigest()
4848
)
@@ -101,7 +101,7 @@ def get_expression(
101101
"cores": 0,
102102
"ram": 0,
103103
"outdir": "/root",
104-
"tmpdir": "/tmp",
104+
"tmpdir": "/tmp", # nosec
105105
"outdirSize": 0,
106106
"tmpdirSize": 0,
107107
}
@@ -1446,8 +1446,8 @@ def traverse_CommandLineTool(
14461446
"basename": "base.name",
14471447
"nameroot": "base",
14481448
"nameext": "name",
1449-
"path": "/tmp/base.name",
1450-
"dirname": "/tmp",
1449+
"path": "/tmp/base.name", # nosec
1450+
"dirname": "/tmp", # nosec
14511451
}
14521452
]
14531453
if outp.outputBinding.loadContents:

cwl_utils/cwl_v1_2_expression_refactor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def expand_stream_shortcuts(process: cwl.CommandLineTool) -> cwl.CommandLineTool
4242
stdout_path = process.stdout
4343
if not stdout_path:
4444
stdout_path = str(
45-
hashlib.sha1(
45+
hashlib.sha1( # nosec
4646
json_dumps(cwl.save(process)).encode("utf-8")
4747
).hexdigest()
4848
)
@@ -101,7 +101,7 @@ def get_expression(
101101
"cores": 0,
102102
"ram": 0,
103103
"outdir": "/root",
104-
"tmpdir": "/tmp",
104+
"tmpdir": "/tmp", # nosec
105105
"outdirSize": 0,
106106
"tmpdirSize": 0,
107107
}
@@ -1542,8 +1542,8 @@ def traverse_CommandLineTool(
15421542
"basename": "base.name",
15431543
"nameroot": "base",
15441544
"nameext": "name",
1545-
"path": "/tmp/base.name",
1546-
"dirname": "/tmp",
1545+
"path": "/tmp/base.name", # nosec
1546+
"dirname": "/tmp", # nosec
15471547
}
15481548
]
15491549
if outp.outputBinding.loadContents:

cwl_utils/image_puller.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""Classes for docker-extract."""
33
import logging
44
import os
5-
import subprocess
5+
import subprocess # nosec
66
from abc import ABC, abstractmethod
77
from typing import List
88

@@ -27,7 +27,7 @@ def save_docker_image(self) -> None:
2727
@staticmethod
2828
def _run_command_pull(cmd_pull: List[str]) -> None:
2929
try:
30-
subprocess.run(
30+
subprocess.run( # nosec
3131
cmd_pull, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
3232
)
3333
except subprocess.CalledProcessError as err:
@@ -61,7 +61,7 @@ def save_docker_image(self) -> None:
6161
os.path.join(self.save_directory, self.get_image_name()),
6262
self.req,
6363
]
64-
subprocess.run(cmd_save, check=True)
64+
subprocess.run(cmd_save, check=True) # nosec
6565
_LOGGER.info(
6666
f"Image successfully pulled: {self.save_directory}/{self.get_image_name()}"
6767
)
@@ -79,7 +79,7 @@ class SingularityImagePuller(ImagePuller):
7979
def __init__(self, req: str, save_directory: str) -> None:
8080
"""Create a Singularity-based software container image downloader."""
8181
super(SingularityImagePuller, self).__init__(req, save_directory)
82-
version = subprocess.check_output(
82+
version = subprocess.check_output( # nosec
8383
["singularity", "--version"], universal_newlines=True
8484
)
8585
if version.startswith("singularity version "):

0 commit comments

Comments
 (0)