6

Github has recently added action button for CI test.

But, I do not want to push a code without passing CI locally.

How can I test my ccpp.yml code locally?

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
ar2015
  • 5,558
  • 8
  • 53
  • 110
  • I think you should just run your tests locally, the CI is then meant to run the tests *for* you. If you made your configuration wrong, you can always change it and push again, or even replace the commit to get rid of unnecessary backandforth. – Felix Dec 29 '19 at 10:53
  • 1
    @Felix, this is not practical for every commit. I want to replicate what `github` does. – ar2015 Dec 29 '19 at 10:58
  • Continuous integration is precisely for running tests for you. You can run tests locally as well, and you **should**, but you can't run online continuous integration locally. If the tests fail online, fix and push again! No worries mate. – Felix Dec 29 '19 at 11:00
  • @Felix, for gitlab, people use `gitlab-runner`. So, running CI locally should not be very unexpected. – ar2015 Dec 29 '19 at 11:31
  • I stand corrected then. But again, if it's a test suite you're running, maybe running it locally is enough. Or if you want to run it online, just push the branch. If it's a more complex pipeline, take this with a grain of salt. – Felix Dec 29 '19 at 11:41
  • Can you please elaborate on exactly which part of the CI you want to do locally? For C++ projects CI is usually just building the project, building tests, running tests and possibly to do profiling or code-coverage. All of that should be possible to do locally as part of your normal build configuration. – Some programmer dude Dec 29 '19 at 12:33
  • @Someprogrammerdude, I want to run `ccpp.yml` from the head to tow. FYI, in my `ccpp.yml` I have a set of builds. Yet, I want to run them from `ccpp.yml` than a synchronized script. – ar2015 Dec 29 '19 at 12:41
  • Good questions on stackoverflow doom being closed. But, I am lucky. – ar2015 Dec 29 '19 at 19:50
  • 5
    It's a reasonable question. Not sure what's with all the -1s. The `yaml` file is code. you want to be able to run said code to test it. Changing and debugging YAML in GitHib Actions and Azure Pipelines is a nightmare. – jessehouwing Dec 29 '19 at 20:07

1 Answers1

2

GitHub Actions currently doesn't support running the YAML file locally. Its twin sibling Azure Pipelines doesn't either. I've asked the team behind the runner many times for this feature, but the consistent answer is that it would only work for single stage, single agent jobs anyway and would therefore never really work satisfactory to anyone. On top of that there is no way for the agent to guarantee that your local system has the same dependencies installed and in the same way, nor does it have access to the secret store.

Because of these reasons, if you want simple CI, use the special Actions, if you want advanced CI that also runs certain stages locally, make sure you don't depend on specific actions, instead: put everything in (Power)Shell and run those from your actions. That way they're also easy to run locally.

unrealapex
  • 578
  • 9
  • 23
jessehouwing
  • 106,458
  • 22
  • 256
  • 341