Skip to content

Commit

Permalink
fix install w/ .cylcignore (#5066)
Browse files Browse the repository at this point in the history
* .cylcignore path.

* changelog

* Extend a func test.

* Update change log. [skip ci]

Co-authored-by: Tim Pillinger <26465611+wxtim@users.noreply.github.com>
  • Loading branch information
hjoliver and wxtim authored Aug 18, 2022
1 parent 7dfbf9d commit 72311c6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 17 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ Maintenance release.
[#5067](https://github.com/cylc/cylc-flow/pull/5067) - Datastore fix for
taskdefs removed before restart.

-------------------------------------------------------------------------------
## __cylc-8.0.2 (<span actions:bind='release-date'>Pending YYYY-MM-DD</span>)__

Maintenance release.

### Fixes

[#5066](https://github.com/cylc/cylc-flow/pull/5066) - Fix bug where
.cylcignore only found if `cylc install` is run in source directory.

-------------------------------------------------------------------------------
## __cylc-8.0.1 (<span actions:bind='release-date'>Released 2022-08-16</span>)__

Expand Down
5 changes: 3 additions & 2 deletions cylc/flow/workflow_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -1477,8 +1477,9 @@ def get_rsync_rund_cmd(src, dst, reinstall=False, dry_run=False):
if (Path(src).joinpath(exclude).exists() or
Path(dst).joinpath(exclude).exists()):
rsync_cmd.append(f"--exclude={exclude}")
if Path(src).joinpath('.cylcignore').exists():
rsync_cmd.append("--exclude-from=.cylcignore")
cylcignore_file = Path(src).joinpath('.cylcignore')
if cylcignore_file.exists():
rsync_cmd.append(f"--exclude-from={cylcignore_file}")
rsync_cmd.append(f"{src}/")
rsync_cmd.append(f"{dst}/")

Expand Down
44 changes: 29 additions & 15 deletions tests/functional/cylc-install/03-file-transfer.t
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
if ! command -v 'tree' >'/dev/null'; then
skip_all '"tree" command not available'
fi
set_test_number 6
set_test_number 9

# Need to override any symlink dirs set in global.cylc:
create_test_global_config "" "
Expand Down Expand Up @@ -69,24 +69,36 @@ __OUT__
popd || exit 1
purge_rnd_workflow


# Test cylc install copies files to run dir successfully, exluding files from .cylcignore file.
TEST_NAME="${TEST_NAME_BASE}-cylcignore-file"
make_rnd_workflow
pushd "${RND_WORKFLOW_SOURCE}" || exit 1
mkdir .git .svn dir1 dir2 extradir1 extradir2
touch .git/file1 .svn/file1 dir1/file1 dir2/file1 extradir1/file1 extradir2/file1 file1 file2 .cylcignore
cat > .cylcignore <<__END__
# Test cylc install copies files to run dir successfully, exluding files from
# .cylcignore file.
# Should work if we run "cylc install" from source dir or not (see GH #5066)
for RUN_IN_SRC_DIR in true false; do
TEST_NAME="${TEST_NAME_BASE}-cylcignore-${RUN_IN_SRC_DIR}"
make_rnd_workflow
pushd "${RND_WORKFLOW_SOURCE}" || exit 1
mkdir .git .svn dir1 dir2 extradir1 extradir2
touch .git/file1 .svn/file1 dir1/file1 dir2/file1 extradir1/file1 extradir2/file1 file1 file2 .cylcignore
cat > .cylcignore <<__END__
dir*
extradir*
file2
__END__

run_ok "${TEST_NAME}" cylc install --no-run-name
if ${RUN_IN_SRC_DIR}; then
run_ok "${TEST_NAME}" cylc install --no-run-name
CWD="${PWD}"
else
DTMP=$(mktemp -d)
pushd "${DTMP}" || exit 1
run_ok "${TEST_NAME}" cylc install --no-run-name "${RND_WORKFLOW_SOURCE}"
CWD="${PWD}"
popd || exit 1
fi

tree -a -v -I '*.log|03-file-transfer*' --charset=ascii --noreport "${RND_WORKFLOW_RUNDIR}/" > 'cylc-ignore-tree.out'
OUT="cylc-ignore-tree-${RUN_IN_SRC_DIR}.out"
tree -a -v -I '*.log|03-file-transfer*' --charset=ascii --noreport "${RND_WORKFLOW_RUNDIR}/" > "$OUT"

cmp_ok 'cylc-ignore-tree.out' <<__OUT__
cmp_ok "$OUT" <<__OUT__
${RND_WORKFLOW_RUNDIR}/
|-- _cylc-install
| \`-- source -> ${RND_WORKFLOW_SOURCE}
Expand All @@ -96,8 +108,10 @@ ${RND_WORKFLOW_RUNDIR}/
\`-- install
__OUT__

contains_ok "${TEST_NAME}.stdout" <<__OUT__
contains_ok "${CWD}/${TEST_NAME}.stdout" <<__OUT__
INSTALLED $RND_WORKFLOW_NAME from ${RND_WORKFLOW_SOURCE}
__OUT__
popd || exit 1
purge_rnd_workflow

popd || exit 1
purge_rnd_workflow
done

0 comments on commit 72311c6

Please sign in to comment.