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

Just use VM, not docker #10

Open
jjangga0214 opened this issue Sep 30, 2019 · 8 comments
Open

Just use VM, not docker #10

jjangga0214 opened this issue Sep 30, 2019 · 8 comments

Comments

@jjangga0214
Copy link

jjangga0214 commented Sep 30, 2019

This line would spend time a lot.

https://github.com/pullreminders/slack-action/blob/da2ae3e1a32c9e629f5f6fa59a95f846366e85ff/Dockerfile#L13

I tested this action in my repository, and just building an docker image consumed 40s.

Screenshot from 2019-09-30 21-24-52

Generally speaking, pulling pre-built image from docker hub is a better option compared to buliding it every time the action is called.

However, I suggest not to use docker just for using curl. According to https://help.github.com/en/articles/software-in-virtual-environments-for-github-actions#ubuntu-1804-lts, VMs already have curl preinstalled. So directly executing entrypoint.sh would be the best.

@lf-novelt
Copy link

lf-novelt commented Nov 15, 2019

I suppose docker use here helps for cross platform compatibilty (windows-latest)
Maybe consider python as another cross platform cmd?

But yeah, I noticed too the Build pullreminders/slack-action@master step that lasts 31sec ends up being the longest step of my workflow :'(
I'll consider switching to a JS based one that may run faster like https://github.com/marketplace/actions/action-slack

@jjangga0214
Copy link
Author

jjangga0214 commented Nov 15, 2019

@lf-novelt
Yeah, docker would be helpful on Windows. But Mac doesn't have it (There's an request for it though: actions/runner-images#17). So, docker can't be the ultimate solution. Actually, I'm little skeptical of the idea running a container just for a very light script.

IMHO, directly running entrypoint.sh on Linux, Mac, and entrypoint(?).cmd on Windows would be the way to go.

By the way, yes, I also think JS, instead of docker, more fits into this kind of simple tasks, which also provides cross platform compatibility. The only drawback to find/create JS actions currently is there are many more useful scripts already written in shell script in CI world. But it worths to be considered for us to find/create JS actions.

@lf-novelt
Copy link

lf-novelt commented Nov 15, 2019

For info, I ended up doing exactly what you said:

  • slack-send.sh (same as entrypoint.sh except for the new env variables)
  • slack-send.ps1
$postParams = "{'channel': '$Env:CHANNEL', 'attachments': [{'color': '$Env:COLOR', 'pretext': '$Env:PRETEXT', 'text': '$Env:TEXT'}]}"

Invoke-WebRequest -Method POST -Headers @{'Content-Type' = "application/json; charset=utf-8"; 'Authorization' = "Bearer $Env:SLACK_BOT_TOKEN"} -Uri https://slack.com/api/chat.postMessage -Body $postParams

callable with this syntax

    - name: Slack notification test
      env:
        SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }}
        CHANNEL: test-notif
        COLOR: good
        PRETEXT: Test notif windows from github
        TEXT: "<${{ github.event.commits[0].url }} |${{ github.repository }}: *${{ github.event.commits[0].message }} *> by ${{ github.event.commits[0].author.name }}\\n<${{ github.event.commits[0].url }}/checks|Workflow ${{ github.workflow }}>: `${{ job.status }}`"
      run: powershell -File ${env:GITHUB_WORKSPACE}\.github\workflows\slack-send.ps1
      shell: powershell

@jjangga0214
Copy link
Author

jjangga0214 commented Nov 17, 2019

@lf-novelt Great! Thank you for sharing the Powershell script and Action snippet. This would be helpful to others as well :)

@robpc
Copy link
Contributor

robpc commented Feb 28, 2020

I just added a PR that uses the official curl docker image which cut the build time for me to about 12 seconds #17

@jjangga0214
Copy link
Author

jjangga0214 commented Mar 1, 2020

@robpc Good to hear the improvement.
However, should the action really be built every time it's used?
I still think just pulling a pre-built image can be faster, though not tested against to this action by myself.

Like by this configuration in action.yml. (The repo currently does not have action.yml).

runs:
  using: 'docker'
  image: 'docker://pullreminders/slack-action'

Refer to container-action getting started docs or reference in case you're not familar with this yet.

@robpc
Copy link
Contributor

robpc commented Mar 2, 2020

That's definitely a good suggestion, but I would not be able to make that change without creating my own action (or at least taking ownership of the docker repo).

@jjangga0214
Copy link
Author

jjangga0214 commented Mar 4, 2020

@robpc Yes, I know.
I hope the maintainer tests this suggestion and accepts it if applicable, though this issue is not responded for several months.
If the maintainer accepts your PR, please remind him or her this issue.

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

No branches or pull requests

3 participants