-
Notifications
You must be signed in to change notification settings - Fork 7
Ideas towards reusable python actions #4
Description
👋
At first, I was writing actions with Dockerfiles that didn't do much except define the FROM
. What I like to do in a CI context is run simple shell commands. Install dependencies along with make and run a make command. But I need a good python install.
Obviously the python docker images are great for 1) locking to a python version 2) on a known base OS. The only issue with the python images is that the entry point drops into the interpreter and rarely am I looking to run python code in CI. I'll execute shell commands to execute it, but I feel abstracting that into portable shell commands is just better.
So to me, something useful that I've duplicated in a few repos at this point is an action using a generic image like docker://python:3.6-alpine
but overrides the entrypoint with a dumb runner script that just executes a list of shell commands in args
.
Positives
- No extraneous Dockerfiles in my repo to maintain.
- Relatively easy to follow actions in
main.workflow
E.g.
action "python commands" {
uses = "docker://python:3.6-alpine"
runs = "./runner.sh"
args = [
"apk add make",
"pip install...",
"make test"
]
}
- reuse of the runner.sh script. Because the actions "business logic" is now specified in args.
Negatives
- the commands in args are not cached in an image layer. if it takes a while to install dependencies, this won't be ideal. A lot of libs are on wheels these days but not every thing obviously.
- needing to duplicate that runner script in all the repos.
But I feel like we could remove that list point if we could write an action like this
action "python commands" {
uses = "jefftriplett/python-actions/3.6@master"
args = [
"apk add make",
"pip install...",
"make test"
]
}
We'd have to make choices about the images to use (I'd probably lean toward slim).
What do you think?