Skip to content

Commit 8393482

Browse files
authored
Merge branch 'main' into 17054-custom-name
2 parents a6f5e17 + 462377e commit 8393482

File tree

8 files changed

+186
-27
lines changed

8 files changed

+186
-27
lines changed

.github/workflows/quay-publish.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: publish-quay
2+
on:
3+
push:
4+
branches:
5+
- main
6+
tags:
7+
- '*'
8+
workflow_dispatch: {}
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@master
14+
- name: Get image tags
15+
id: image_tags
16+
run: |
17+
echo -n ::set-output name=IMAGE_TAGS::$(git describe --tags)
18+
- name: Build and publish cwltool_module image to Quay
19+
uses: docker/build-push-action@v1
20+
with:
21+
file: cwltool.Dockerfile
22+
registry: ${{ secrets.REGISTRY_SERVER }}
23+
repository: ${{ secrets.REGISTRY_NAMESPACE }}/cwltool_module
24+
username: ${{ secrets.REGISTRY_USERNAME }}
25+
password: ${{ secrets.REGISTRY_PASSWORD }}
26+
tags: "${{ steps.image_tags.outputs.IMAGE_TAGS }}"
27+
target: module
28+
- name: Build and publish cwltool image to Quay
29+
uses: docker/build-push-action@v1
30+
with:
31+
file: cwltool.Dockerfile
32+
registry: ${{ secrets.REGISTRY_SERVER }}
33+
repository: ${{ secrets.REGISTRY_NAMESPACE }}/cwltool
34+
username: ${{ secrets.REGISTRY_USERNAME }}
35+
password: ${{ secrets.REGISTRY_PASSWORD }}
36+
tags: "${{ steps.image_tags.outputs.IMAGE_TAGS }}"

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Conda: |Conda Version| |Conda Installs|
1010

1111
Debian: |Debian Testing package| |Debian Stable package|
1212

13+
Quay.io (Docker): |Quay.io Container|
14+
1315
.. |Linux Status| image:: https://github.com/common-workflow-language/cwltool/actions/workflows/ci-tests.yml/badge.svg?branch=main
1416
:target: https://github.com/common-workflow-language/cwltool/actions/workflows/ci-tests.yml
1517

@@ -37,6 +39,9 @@ Debian: |Debian Testing package| |Debian Stable package|
3739
.. |Conda Installs| image:: https://anaconda.org/conda-forge/cwltool/badges/downloads.svg
3840
:target: https://anaconda.org/conda-forge/cwltool
3941

42+
.. |Quay.io Container| image:: https://quay.io/repository/commonwl/cwltool/status
43+
:target: https://quay.io/repository/commonwl/cwltool
44+
4045
This is the reference implementation of the Common Workflow Language. It is
4146
intended to be feature complete and provide comprehensive validation of CWL
4247
files as well as provide other tools related to working with CWL.

build-cwl-docker.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
2-
set -e
3-
docker build --file=cwltool.Dockerfile --tag=commonworkflowlanguage/cwltool_module --target module .
4-
docker build --file=cwltool.Dockerfile --tag=commonworkflowlanguage/cwltool .
2+
set -ex
3+
docker build --file=cwltool.Dockerfile --tag=quay.io/commonwl/cwltool_module --target module .
4+
docker build --file=cwltool.Dockerfile --tag=quay.io/commonwl/cwltool .
55

66
version=$(git describe --tags)
77
if echo "$version" | grep -vq '\-' >& /dev/null ; then
8-
docker tag commonworkflowlanguage/cwltool_module commonworkflowlanguage/cwltool_module:"$version"
9-
docker tag commonworkflowlanguage/cwltool commonworkflowlanguage/cwltool:"$version"
8+
docker tag quay.io/commonwl/cwltool_module quay.io/commonwl/cwltool_module:"$version"
9+
docker tag quay.io/commonwl/cwltool quay.io/commonwl/cwltool:"$version"
1010
fi

cwltool.Dockerfile

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
FROM python:3.8-alpine as builder
2-
3-
RUN apk add --no-cache git gcc python3-dev libxml2-dev libxslt-dev libc-dev linux-headers
1+
FROM python:3.9-slim as builder
2+
3+
RUN apt-get update && apt-get install -y \
4+
gcc \
5+
git \
6+
libc-dev \
7+
libxml2-dev \
8+
libxslt1-dev \
9+
python3-dev \
10+
&& rm -rf /var/lib/apt/lists/*
11+
# linux-headers \
412

513
WORKDIR /cwltool
614
COPY . .
@@ -9,16 +17,28 @@ RUN python setup.py bdist_wheel --dist-dir=/wheels
917
RUN pip wheel -r requirements.txt --wheel-dir=/wheels
1018
RUN pip install --no-index --no-warn-script-location --root=/pythonroot/ /wheels/*.whl
1119

12-
FROM python:3.8-alpine as module
13-
LABEL maintainer peter.amstutz@curoverse.com
20+
FROM python:3.9-slim as module
21+
LABEL maintainer peter.amstutz@curii.com
1422

15-
RUN apk add --no-cache docker nodejs graphviz libxml2 libxslt
23+
RUN apt-get update && apt-get install -y \
24+
docker.io \
25+
graphviz \
26+
libxml2 \
27+
libxslt1.1 \
28+
nodejs \
29+
&& rm -rf /var/lib/apt/lists/*
1630
COPY --from=builder /pythonroot/ /
1731

18-
FROM python:3.8-alpine
19-
LABEL maintainer peter.amstutz@curoverse.com
32+
FROM python:3.9-slim
33+
LABEL maintainer peter.amstutz@curii.com
2034

21-
RUN apk add --no-cache docker nodejs graphviz libxml2 libxslt
35+
RUN apt-get update && apt-get install -y \
36+
docker.io \
37+
graphviz \
38+
libxml2 \
39+
libxslt1.1 \
40+
nodejs \
41+
&& rm -rf /var/lib/apt/lists/*
2242
COPY --from=builder /pythonroot/ /
2343
COPY cwltool-in-docker.sh /cwltool-in-docker.sh
2444

cwltool/process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def stage_files(
309309
os.makedirs(entry.target)
310310
else:
311311
shutil.copytree(entry.resolved, entry.target)
312-
ensure_writable(entry.target)
312+
ensure_writable(entry.target, include_root=True)
313313
elif entry.type == "CreateFile" or entry.type == "CreateWritableFile":
314314
with open(entry.target, "wb") as new:
315315
if secret_store is not None:

cwltool/utils.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -367,23 +367,30 @@ def downloadHttpFile(httpurl):
367367
return str(f.name)
368368

369369

370-
def ensure_writable(path): # type: (str) -> None
370+
def ensure_writable(path: str, include_root: bool = False) -> None:
371+
"""
372+
Ensure that 'path' is writable.
373+
374+
If 'path' is a directory, then all files and directories under 'path' are
375+
made writable, recursively. If 'path' is a file or if 'include_root' is
376+
`True`, then 'path' itself is made writable.
377+
"""
378+
379+
def add_writable_flag(p: str) -> None:
380+
st = os.stat(p)
381+
mode = stat.S_IMODE(st.st_mode)
382+
os.chmod(p, mode | stat.S_IWUSR)
383+
371384
if os.path.isdir(path):
385+
if include_root:
386+
add_writable_flag(path)
372387
for root, dirs, files in os.walk(path):
373388
for name in files:
374-
j = os.path.join(root, name)
375-
st = os.stat(j)
376-
mode = stat.S_IMODE(st.st_mode)
377-
os.chmod(j, mode | stat.S_IWUSR)
389+
add_writable_flag(os.path.join(root, name))
378390
for name in dirs:
379-
j = os.path.join(root, name)
380-
st = os.stat(j)
381-
mode = stat.S_IMODE(st.st_mode)
382-
os.chmod(j, mode | stat.S_IWUSR)
391+
add_writable_flag(os.path.join(root, name))
383392
else:
384-
st = os.stat(path)
385-
mode = stat.S_IMODE(st.st_mode)
386-
os.chmod(path, mode | stat.S_IWUSR)
393+
add_writable_flag(path)
387394

388395

389396
def ensure_non_writable(path): # type: (str) -> None

tests/test_iwdr.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pathlib import Path
2+
from stat import S_IWRITE, S_IWGRP, S_IWOTH
23
from typing import Any
34

45
from cwltool.factory import Factory
@@ -80,6 +81,53 @@ def test_iwdr_permutations(tmp_path_factory: Any) -> None:
8081
)
8182

8283

84+
def test_iwdr_permutations_readonly(tmp_path_factory: Any) -> None:
85+
"""Confirm that readonly input files are properly made writable."""
86+
misc = tmp_path_factory.mktemp("misc")
87+
fifth = tmp_path_factory.mktemp("fifth")
88+
fifth_file = fifth / "bar"
89+
fifth_dir = fifth / "foo"
90+
fifth_file.touch()
91+
fifth_dir.mkdir()
92+
sixth = tmp_path_factory.mktemp("sixth")
93+
first = misc / "first"
94+
first.touch()
95+
second = misc / "second"
96+
second.touch()
97+
outdir = str(tmp_path_factory.mktemp("outdir"))
98+
for entry in [first, second, fifth, sixth, fifth_file, fifth_dir]:
99+
mode = entry.stat().st_mode
100+
ro_mask = 0o777 ^ (S_IWRITE | S_IWGRP | S_IWOTH)
101+
entry.chmod(mode & ro_mask)
102+
assert (
103+
main(
104+
[
105+
"--no-container",
106+
"--debug",
107+
"--leave-outputs",
108+
"--outdir",
109+
outdir,
110+
get_data("tests/wf/iwdr_permutations_nocontainer.cwl"),
111+
"--first",
112+
str(first),
113+
"--second",
114+
str(second),
115+
"--fifth",
116+
str(fifth),
117+
"--sixth",
118+
str(sixth),
119+
]
120+
)
121+
== 0
122+
)
123+
for entry in [first, second, fifth, sixth, fifth_file, fifth_dir]:
124+
try:
125+
mode = entry.stat().st_mode
126+
entry.chmod(mode | S_IWRITE)
127+
except PermissionError:
128+
pass
129+
130+
83131
@needs_docker
84132
def test_iwdr_permutations_inplace(tmp_path_factory: Any) -> None:
85133
misc = tmp_path_factory.mktemp("misc")
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env cwl-runner
2+
class: CommandLineTool
3+
cwlVersion: v1.2
4+
requirements:
5+
InitialWorkDirRequirement:
6+
listing:
7+
- entry: $(inputs.first)
8+
entryname: first_writable_file
9+
writable: true
10+
- entry: $(inputs.second)
11+
entryname: second_read_only_file
12+
writable: false
13+
- entry: $(inputs.fifth)
14+
entryname: fifth_writable_directory
15+
writable: true
16+
- entry: $(inputs.sixth)
17+
entryname: sixth_read_only_directory
18+
writable: false
19+
- entry: $(inputs.ninth)
20+
entryname: nineth_writable_directory_literal
21+
writable: true
22+
inputs:
23+
first: File
24+
second: File
25+
fifth: Directory
26+
sixth: Directory
27+
ninth:
28+
type: Directory
29+
default:
30+
class: Directory
31+
basename: foo
32+
listing: []
33+
outputs:
34+
out:
35+
type: Directory
36+
outputBinding:
37+
glob: .
38+
baseCommand: [bash, -c]
39+
arguments:
40+
- |
41+
find .
42+
echo "a" > first_writable_file
43+
touch fifth_writable_directory/c

0 commit comments

Comments
 (0)