cli: update parts cache in the container #1546

Merged
merged 8 commits into from Oct 27, 2017

Conversation

Projects
None yet
4 participants
Collaborator

kalikiana commented Sep 12, 2017

  • Have you followed the guidelines for contributing?
  • Have you signed the CLA?
  • If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on bug reports?
  • If this is a new feature. Have you discussed the design on the forum?
  • Have you successfully run ./runtests.sh static?
  • Have you successfully run ./runtests.sh unit?

  • Pass snapcraft update through to the container
    See the forum proposal.

Note: The other part is implemented in #1412.

@kalikiana kalikiana self-assigned this Sep 12, 2017

@sergiusens sergiusens referenced this pull request Sep 19, 2017

Closed

update story #1462

Looks good, a question related to a test and how this would affect the behavior of define and search when the environment variable is set where it would potentially never be updated locally.

snapcraft/tests/commands/test_update.py
+ fake_lxd.name = 'local:snapcraft-snap-test'
+ fake_lxd.status = 'Running'
+ fake_logger = fixtures.FakeLogger(level=logging.INFO)
+ self.useFixture(fake_logger)
@sergiusens

sergiusens Oct 5, 2017

Collaborator

I don't think you need this fake logger setup here; or what is it intended for as there are no checks for it. self.run_command would return an object with an output and exit_code attribute.

@kalikiana

kalikiana Oct 5, 2017

Collaborator

You're right! Thanks for pointing it out! I'd copied it because it's used in other tests, but actually the output is the same - we could probably simplify a few other tests this way at some point.
I dropped the logger and added a check for exit code (not sure if it's really necessary here, but can't hurt to have it).

This looks fine, although in the proposal you say:

Proposal

  • Run snapcraft update in the container
  • Run apt-get update, apt-get upgrade and snap refresh as part of update - this would be similar to how the clean command without arguments deletes the container
  • Stop running apt-get update with all other commands

I proposed a PR implementing the proposal.

All I see here is the first in that list, no?

snapcraft/tests/commands/test_update.py
+ summary: test snapping
+ description: if snap is succesful a snap package will be available
+ architectures: ['amd64']
+ type: {}
@kyrofa

kyrofa Oct 11, 2017

Member

When using an external template like this, named parameters are far more clear and scalable than positional ones.

@kalikiana

kalikiana Oct 12, 2017

Collaborator

I just copied it from the snap test :-D but yeah, I changed it to {snap_type}

Collaborator

kalikiana commented Oct 12, 2017

@kyle Note that the PR description explicitly mentions the part that this PR implements. This one is update. #1412 covers the refresh/ upgrade.

snapcraft/tests/commands/test_update.py
def setUp(self):
super().setUp()
self.parts_dir = os.path.join(BaseDirectory.xdg_data_home, 'snapcraft')
self.parts_yaml = os.path.join(self.parts_dir, 'parts.yaml')
self.headers_yaml = os.path.join(self.parts_dir, 'headers.yaml')
+ def make_snapcraft_yaml(self, n=1, snap_type='app', snapcraft_yaml=None):
@sergiusens

sergiusens Oct 12, 2017

Collaborator

There is a make_snapcraft_yaml in the parent class for tests which you can just use, right?

@kalikiana

kalikiana Oct 12, 2017

Collaborator

I basically went with the style used in other tests there, which have their own customized version of the method for repeated use. But you're right, in this case I can keep it really simple. So, done.

Collaborator

kalikiana commented Oct 13, 2017

Tests are green again!

snapcraft/cli/parts.py
+ container_config = env.get_container_config()
+ if container_config.use_container:
+ project_options = get_project_options(**kwargs)
+ lifecycle.containerbuild('update', project_options, container_config)
@elopio

elopio Oct 24, 2017

Member

This looks good to me, but I'm wondering why do we have to update the parts in the host?

@kalikiana

kalikiana Oct 24, 2017

Collaborator

Because snapcraft define and snapcraft search operate on the host. There's little reason to start a container for those... or do you think we should?

Collaborator

sergiusens commented Oct 25, 2017

@sergiusens sergiusens added this to the 2.35 milestone Oct 26, 2017

elopio approved these changes Oct 26, 2017

Thanks for the comment, it makes my doubts go away.

kyrofa approved these changes Oct 27, 2017

This has my vote of approval, thanks @kalikiana.

@kyrofa kyrofa merged commit 0dde023 into snapcore:master Oct 27, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@sergiusens sergiusens referenced this pull request Nov 1, 2017

Merged

Release changelog for 2.35 #1650

6 of 6 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment