In this exercise, you will set up a Continuous Integration (CI) workflow using GitHub as a version control system, Travis CI as a build tool, and DockerHub as artifact repository manager. This workflow will execute the unit tests of the source code and build the code. To trigger it, a change of the codebase must be performed.
-
GitHub account
-
Create a GitHub repository called:
mini-ci-example
-
Add and commit
main.go
,main_test.go
,fib.go
,fib_test.go
, andgo.mod
to your repository via drag-and-drop. -
Active Travis CI for your GitHub repository.
- Follow instructions on: https://docs.travis-ci.com/user/tutorial/#to-get-started-with-travis-ci
-
Create file
.travis.yml
in your repository and copy-paste content from the provided.travis.yml
file.os: linux language: go go: - 1.13.x script: # Test the code - go test -v ./... # Build the code - CGO_ENABLED=0 GOARCH=amd64 go build -o demo
-
Trigger a Travis CI build by a code change, e.g., change "Hello" to "Hi there" in the file
./main.go
-
Watch Travis executing your tests and building the artifact.
🔍 What is your observation?
-
Optional: To add Travis CI status to the README.md, follow instructions on: https://docs.travis-ci.com/user/status-images/
[![Build Status](https://travis-ci.com/YOUR-GITHUB-ACCOUNT/mini-ci-example.svg?branch=main)](https://travis-ci.com/YOUR-GITHUB-ACCOUNT/mini-ci-example)