juju / charm-tools

Tools for charm authors and maintainers
Other
42 stars 65 forks source link

'ignore' only ignores files from next layer, not any base layers #312

Open cjwatson opened 7 years ago

cjwatson commented 7 years ago

Checklist

What version am I running?

I ran the following command: charm version and got the following ouput:

charm 2.2.0-0ubuntu1~ubuntu16.04.1~ppa2
charm-tools 2.2.0

I am using: Ubuntu 16.04 LTS

Issue

The ignore tactic is documented as follows in the docstring of IgnoreTactic:

If a given layer's ``layer.yaml`` has an ``ignore`` list, then any file
or directory included in that list that is provided by base layers will
be ignored, though any matching file or directory provided by the current
or any higher level layers will be included.

However, this is not what I observe in practice: it in fact only ignores files provided by the immediate next layer. Here's a reduced test case:

<cjwatson@niejwein ~/charm-test/1>$ cat metadata.yaml
name: charm-test-1
summary: Charm test 1
maintainer: Colin Watson <cjwatson@canonical.com>
series:
    - xenial
<cjwatson@niejwein ~/charm-test/1>$ cat layer.yaml
repo: https://example.com/charm-test-1
includes:
    - layer:basic
ignore:
    - bin
<cjwatson@niejwein ~/charm-test/1>$ charm build
build: Composing into /home/cjwatson/charm-test/1
build: Destination charm directory: /home/cjwatson/charm-test/1/builds/charm-test-1
build: Processing layer: layer:basic
build: Processing layer: charm-test-1 (from .)
proof: W: Metadata missing required field "tags"
proof: I: No icon.svg file.
proof: I: all charms should provide at least one thing
proof: I: File config.yaml not found.
<cjwatson@niejwein ~/charm-test/1>$ ls builds/charm-test-1/
Makefile  README.md  builds  copyright  deps  hooks  layer.yaml  lib  metadata.yaml  reactive  requirements.txt  tox.ini  wheelhouse
<cjwatson@niejwein ~/charm-test/1>$ cd ../2
<cjwatson@niejwein ~/charm-test/2>$ cat metadata.yaml
name: charm-test-2
summary: Charm test 2
maintainer: Colin Watson <cjwatson@canonical.com>
series:
    - xenial
<cjwatson@niejwein ~/charm-test/2>$ cat layer.yaml
repo: https://example.com/charm-test-2
includes:
    - layer:basic
    - layer:snap
ignore:
    - bin
<cjwatson@niejwein ~/charm-test/2>$ charm build
build: Composing into /home/cjwatson/charm-test/2
build: Destination charm directory: /home/cjwatson/charm-test/2/builds/charm-test-2
build: Processing layer: layer:basic
build: Processing layer: layer:snap
build: Processing layer: charm-test-2 (from .)
proof: W: Metadata missing required field "tags"
proof: I: No icon.svg file.
proof: I: all charms should provide at least one thing
<cjwatson@niejwein ~/charm-test/2>$ ls builds/charm-test-2/
Makefile  README.md  bin  builds  config.yaml  copyright  deps  hooks  layer.yaml  lib  metadata.yaml  reactive  requirements.txt  tox.ini  wheelhouse

Notice that the only interesting change in the second case here is the addition of layer:snap, and yet this caused the bin directory to stop being ignored. I expected my ignores to be effective for all base layers, as documented.

Here's a non-reduced example. https://github.com/canonical-ols/build.snapcraft.io/commit/b9a8a26720618f78671c304acb00b400e9734c61 resulted in https://git.launchpad.net/~ubuntuone-hackers/build.snapcraft.io/+git/builds/commit/?id=afab79320c046d6978abdacc703244139897e302 when built. Notice how actions.yaml and actions/migrate have popped into existence from layer:ols-pg, despite being listed in ignore.

This is probably the cause of #301.

cjwatson commented 7 years ago

(The git.launchpad.net link there may 404, but should work if you then press Enter in the location bar; it's something to do with ~ / %7E encoding. This is probably a bug in git.launchpad.net that I should investigate, but is of course irrelevant to this issue.)