Glue Stack
GitHubLive AppChat
1.0.0
1.0.0
  • Read Me
  • Architecture
    • How Web Applications Work
  • Development
    • Our Development Process
    • Running Locally
    • Setup Development Tools
    • Setup Visual Studio Code (vscode)
    • Setup Database Connection In Sequel Pro
    • Building Glue Stack From an Empty Folder
    • Developing Process Documentation
    • UI Connect Component
  • Infrastructure
    • Setup AWS Account
    • Setup AWS Cloud Infrastructure
    • Continuous Integration (CI): Travis CI
    • Performance Testing and Connection Pool Sizes
Powered by GitBook
On this page
  • Execution
  • Alternatives
  • Problems
  • Method
  1. Infrastructure

Continuous Integration (CI): Travis CI

PreviousSetup AWS Cloud InfrastructureNextPerformance Testing and Connection Pool Sizes

Last updated 6 years ago

It seems the definition is rather subjective so let me be explict about what glue-stack does: 1. Tests are run when you create your pull request (pr) into master and you can't merge until they pass. 2. When you've merged your code into master, it will be deployed to production.

I guess that would be Continuous Deployment?

Our pipeline (process) looks like this: 1. Run the ui and api tests in parallel. 2. When they are both complete and pass, deploy the api. 1. The api is deployed to AWS elastic beanstalk which is AWS' PaaS (platform as a service) offering. It can be configured to do rolling deploys for zero downtime deploys. 2. When the new api version starts up, automatically runs database change scripts if required. 3. When the api is deployed, deploy the ui.

Execution

Oh wow was this hard. That was probably in part due to me not wanting to do this but CI is very standard in the industry so it really had to be done and the final product is pretty cool. Unfortunately I didn't really learn anything more about CI while setting up Travis, I mainly learned about setting up Travis. And how painful it is.

Its really easy to get a basic build and test to make sure the branch doesn't fail but the automatic deploy was a bit harder.

Alternatives

After reaching the halfway point I thought about changing to either Circle CI or Buddy.works but I thought that would be harder than just finishing off travis. Travis is cool because it gives you concurrent jobs for free but that's only for open source projects.

This is a bit of a weird area for this project because I want to teach everyone software development; open source and closed source, but at the same time its nice to reap the rewards offered by services for open source projects. GitLab has its own CI for free for private projects so that is pretty dam tasty if you go closed source because the private repo and CI is free. I don't think I'm willing to move this project over to GitLab since GitHub is largely the open source standard but if I needed closed source I would be looking at them.

Problems

  • you need to specify the pro option on travis cli even though we're not pro because they changed the domain for newer open source accounts to the same domain as the pro.

  • Repoistory Environment Variables can't be used in your .travis.yml file.

  • Travis cli encrypt overwrites encrypted variables by default instead of appending.

  • There's nothing on the environment variables page about how to use the variables in the .travis.yml file.

  • Testcontainers uses travis internally apparently but they don't have docs for it.

  • You have to specify not to delete the built files you want to deploy in the deploy section.

  • Only build prs and master branch

Method

  1. Select Open Source.

  2. Intall it for free.

  3. Complete order and begin installation.

  4. Select Install.

  5. Sign in with GitHub.

  6. Authorize travis-pro.

  7. Open project in VSCode.

  8. Create a new branch.

  9. We need the docker service for our testcontainers database API tests.

  10. Sign in to the AWS console.

  11. Go to IAM.

  12. Select Users.

  13. Select Add user.

    User name: travis

    Access type: Programmatic access.

  14. Select Next: permissions.

  15. Select Attach existing policies directly.

  16. Select AmazonS3FullAccess.

  17. Select AWSElasticBeanstalkFullAccess.

  18. Select Next: Review.

  19. Select Create user.

  20. Keep the page open so we can copy the credentials into our travis file.

  21. Open the root of our project in VSCode.

  22. Install the Travis CLI

    brew install travis
  23. Login into your travis account using the CLI

    travis login --pro

    The pro is important because travis changed their domain for free accounts to the pro domain.

  24. Encrypt your credentials. This is done using a private key for your account that only travis knows. Its bad practice to check in credentials into source control. In fact, there are bots that are constantly scanning GitHub for credentials and if they find some they automatically spin up instances, usually to mine bitcoin, and you pay for it.

    travis encrypt access_key_id=YOUR_ACCESS_KEY --add env
    travis encrypt secret_access_key=YOUR_SECRET_KEY --add --append env
  25. Commit your work.

  26. Push the branch.

  27. Check if the build passed in Travis CI.

  28. Click the build: unknown badge next to your repo name.

  29. Select Markdown.

  30. Copy the code.

  31. Paste it in the root README.md.

Following

Open .

Create the .travis.yml file from .

Continuous Integration vs. Continuous Delivery vs. Continuous Deployment
Flyway
Open source on travis.com
Travis CI - Using repository environment variables in .travis.yml
Environment Variables
https://stackoverflow.com/questions/31882306/how-to-configure-travis-ci-to-build-pull-requests-merges-to-master-w-o-redunda#31882307
https://docs.travis-ci.com/user/getting-started/
Travis CI in the GitHub Marketplace
.travis.yml