-
Notifications
You must be signed in to change notification settings - Fork 121
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 tag flavor #15
Add tag flavor #15
Conversation
Codecov Report
@@ Coverage Diff @@
## master #15 +/- ##
==========================================
- Coverage 72.94% 67.67% -5.27%
==========================================
Files 3 3
Lines 85 99 +14
Branches 18 27 +9
==========================================
+ Hits 62 67 +5
Misses 6 6
- Partials 17 26 +9
Continue to review full report at Codecov.
|
@hugopeixoto Thanks for this PR. Can you merge please? |
5984e19
to
d5587fc
Compare
I've rebased the PR to the latest master, resolving the conflicts. Let me know if you meant something else. |
@hugopeixoto Ahah my bad was tired yesterday, I meant rebase 😅 |
@hugopeixoto you beat me to it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM but need some changes:
- Please don't create inline condition. We want to make sure code coverage is respected.
- Add tests
- Update README
I want to append suffix(like |
I suspect #24 may supersede this entirely, even though it may not have been intentionally designed to do so. |
Actually no, |
f64885a
to
04d7e66
Compare
I've updated the PR to include documentation in README.md and some tests in meta.test.ts. @crazy-max I'm fighting codecov and losing. The current problem seems to be the line |
How about this? Some coverage tools cannot recognize short circuits correctly. let tags: Array<string> = [];
const tagPush = (tagStr: string) => {
if (this.inputs.flavor) {
tags.push(`${tagStr}-${this.inputs.flavor}`);
if (this.inputs.mainFlavor) {
tags.push(tagStr);
}
} else {
tags.push(tagStr);
}
};
for (const image of this.inputs.images) {
const imageLc = image.toLowerCase();
tagPush(`${imageLc}:${this.version.main}`);
for (const partial of this.version.partial) {
tagPush(`${imageLc}:${partial}`);
}
if (this.version.latest) {
if (this.inputs.flavor) {
tags.push(`${imageLc}:${this.inputs.flavor}`);
if (this.inputs.mainFlavor) {
tags.push(`${imageLc}:latest`);
}
} else {
tags.push(`${imageLc}:latest`);
}
}
if (this.context.sha && this.inputs.tagSha) {
tagPush(`${imageLc}:sha-${this.context.sha.substr(0, 7)}`);
}
} |
04d7e66
to
6cc8d91
Compare
ae3facd
to
94c31d2
Compare
Thanks for the suggestion. I tried a variation of that: instead of using if (flavor === '') {
main = true;
} else if (this.inputs.mainFlavor) {
main = true;
} else {
main = false;
} And each of the Could it be that there's a problem with codecov's typescript tooling? I rolled the commit back to |
Oh... |
@hugopeixoto Yes don't worry about codecov for this kind of stuff, there's something wrong on their side or something needs to be configured on our side. Will check this out later. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@crazy-max Do you have any updates? Are there any other problems? |
Exactly the feature I need 👍 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi @crazy-max , is there more to do here? 🙏 |
Fixes #13
For cases where you have multiple flavors of the same container, like
node:12-alpine
,node:12-debian
, etc, it would be nice to be able to specify these flavors in this github action. This was requested in #13.Let's say that your container has two flavors,
debian
andalpine
, and that you want images likefoo:latest
to be based on the debian flavor. You might want to generate these tags:foo:x.y.z-debian
foo:x.y.z-alpine
foo:x.y.z
(= foo.x.y.z-debian
)foo:debian
(= foo.x.y.z-debian
)foo:alpine
(= foo.x.y.z-alpine
)foo:latest
(= foo.x.y.z-debian
)foo:sha-AAAAAA-debian
foo:sha-AAAAAA-alpine
foo:sha-AAAAAA
(=
foo:sha-AAAAAA-debian`)To achieve this, I added two options:
flavor (string)
andmain-flavor (boolean)
. Trying to summarize their behavior:main-flavor
is true, the flavorless tags will be emitted as wellfoo:debian
) will only be generated if there's a flavor and the tag matches aslatest
.In other words, each previously emited tag has its flavor counterpart:
foo:x.y.z
=>foo:x.y.z-{flavor}
foo:latest
=>foo:{flavor}
foo:sha-AAAAAA
=>foo:sha-AAAAAA-{flavor}
And the left side are emited
if no flavor != '' or mainFlavor
, and the right side is emitedif flavor != ''
.This is how I'm using this in a project:
I hope this is understandable :P Let me know what you think, and if this is an approach that makes sense. I wasn't sure if the
sha
tags should be flavored as well.I still need to add tests and document this in the readme, but I'd like to know if this is something that you would consider integrate and iterate on before spending time there.