By Wilson29thID
I appreciate how fast app platform is at detecting a new push to my GitHub repo and deploying it, but how can I configure it to wait for the automated tests to pass first?
I happen to use a GitHub Action to run tests.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Maybe you want to avoid this path, but I see tests as part of the development process, so that the github action could be triggered by commits to some staging branch. When that’s ok, follow to deploy by merging to the DO main branch.
At the moment i’m using the gitlab CI to run all the tests etc on each branch. Then when it merges to master it just deploys. Rather than having a staging branch, we just test every branch and MR. It depends on the git flow you’re using.
But it would be cool if Digital Ocean did something similar to vercel or buddy CI where it adds it’s self to the pipelines in gitlab.
Because we should test master before it’s released but for now the branch only test seem to work fine.
A bare-bones solution is to run the test command as part of the build step for your component. Typically, App Platform allows individual lines in your build command to fail without failing the whole build, as long as your actual build output succeeds. However, you can set the CLI to fail if any of its commands fail.
For example, in a NodeJS project with a test script defined in your NPM package.json file, you would modify your App Platform component Build Command and prepend it with the following:
# First, tell the CLI to exit with a failure code if
# any of the statements in the Build Command fail.
set -e
# Next, run your test command.
# Replace the following NodeJS example with your own test command
# (ex. JUnit, pytest, rspec, etc.).
npm run test --ci
# ... Include the remainder of your build steps.
If the test command exits unsuccessfully for any reason, (i.e. test failures), the component build will also fail and App Platform will not deploy the commit.
I haven’t tested whether the Build Command allows for exporting things like test result or code coverage reports to external tools. I don’t know what kind of network access the build environment allows beyond dependency registries.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.