Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests and CI #34

Merged
merged 25 commits into from
Dec 10, 2020
Merged

Add tests and CI #34

merged 25 commits into from
Dec 10, 2020

Conversation

joao-p-marques
Copy link
Contributor

@joao-p-marques joao-p-marques commented Nov 9, 2020

Takes from #14 and start apllying suggestions and improvements.

So far:

  • Migrate tests to pytest
  • Add Github Actions to run tests
  • Install python3 in the dockerfile.
  • Remove POST rule
  • Make sure the same image that is tested is pushed.
  • Publish image in ghcr.io

TT26468

@joao-p-marques joao-p-marques requested a review from yajo November 9, 2020 16:38
Copy link
Contributor

@yajo yajo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you.

Lots of suggestions:

.github/workflows/test.yaml Outdated Show resolved Hide resolved
.github/workflows/test.yaml Outdated Show resolved Hide resolved
.github/workflows/test.yaml Outdated Show resolved Hide resolved
.github/workflows/test.yaml Outdated Show resolved Hide resolved
.github/workflows/test.yaml Outdated Show resolved Hide resolved
tests/run_tests.sh Outdated Show resolved Hide resolved
tests/test_service.py Outdated Show resolved Hide resolved
tests/test_service.py Outdated Show resolved Hide resolved
tests/test_service.py Outdated Show resolved Hide resolved
tests/test_service.py Outdated Show resolved Hide resolved
@joao-p-marques
Copy link
Contributor Author

Changes made @yajo, apart from the comment above.
I was trying to enable auto push to ghcr.io, but we need to add specific tokens, similar to Tecnativa/doodba#347

As a reference, see https://docs.github.com/en/free-pro-team@latest/packages/getting-started-with-github-container-registry/migrating-to-github-container-registry-for-docker-images#updating-your-github-actions-workflow (GITHUB_TOKEN is not supported, unfortunately)

@joao-p-marques joao-p-marques force-pushed the add-tests branch 4 times, most recently from b49f3ef to 4779acb Compare November 25, 2020 12:40
.github/workflows/test.yaml Outdated Show resolved Hide resolved
.copier-answers.autopretty.yml Outdated Show resolved Hide resolved
.github/workflows/test.yaml Outdated Show resolved Hide resolved
.github/workflows/test.yaml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
tests/test_service.py Outdated Show resolved Hide resolved
@joao-p-marques
Copy link
Contributor Author

I've made come changes @yajo. Still WIP so pls tell me if this goes in the direction you meant.

@yajo
Copy link
Contributor

yajo commented Dec 2, 2020

Not exactly. Let me write that code for you.

@yajo
Copy link
Contributor

yajo commented Dec 2, 2020

I pushed the initial structure. It is probably failing, but I hope you can continue your WIP on top of it. I also added a very important point to your checklist in first comment: Make sure the same image that is tested is pushed.

@joao-p-marques
Copy link
Contributor Author

Thank you for the suggestions @yajo
Changes made for the tests.

@yajo
Copy link
Contributor

yajo commented Dec 3, 2020

Is this ready to review?

@joao-p-marques
Copy link
Contributor Author

I am still working on adding the auto config generator script as an entrypoint and making sure the same image that is tested is pushed.

I was thinking on marking it as ready when that is done 😃

Tests are ready for review, however.

Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
tests/test_service.py Show resolved Hide resolved
@joao-p-marques
Copy link
Contributor Author

Ended up removing:

  • Add the proposed script as an entrypoint.
  • Document usage in README.
    as it didn't seem to make sense for the project after all.

@joao-p-marques
Copy link
Contributor Author

We seem to be hitting docker/buildx#59. I applied docker/buildx#59 (comment) to build the image only in the runner's platform for testing purposes and then build the rest when it is time to push. This is a limitation of docker buildx when exporting to local docker, which we need to test the image.

It is not the best but we would only test one version of the image anyway (the one corresponding to the runner's platform), right? 🤷‍♂️

@joao-p-marques joao-p-marques marked this pull request as ready for review December 3, 2020 15:24
Comment on lines +3 to +14
on:
pull_request:
push:
branches:
- master
workflow_dispatch:
inputs:
pytest_addopts:
description:
Extra options for pytest; use -vv for full details; see
https://docs.pytest.org/en/latest/example/simple.html#how-to-change-command-line-options-defaults
required: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this is the time to implement #33 (comment)?

I'm developing for TT25794 a new python lib that will help know that you're currently in the latest tag. I'll notify you when it's done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good suggestion. I agree that it makes sense now. I'll wait for your call then.

.github/workflows/test.yaml Outdated Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
Builds the image (in single arch) before testing
Loads the image into local docker (See https://github.com/docker/build-push-action#export-image-to-docker)
Rebuilds and pushes the final image in multi-arch at the end.
joao-p-marques and others added 2 commits December 4, 2020 10:01
This reverts commit dc0b60e and allows using `--prebuild` CLI flag for pytest when doing local tests.
Copy link
Contributor

@yajo yajo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very good.

I think it's better to not block it due to #34 (comment) because that'll take a bit of time still.

@yajo yajo merged commit e84babd into master Dec 10, 2020
@yajo yajo deleted the add-tests branch December 10, 2020 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants