Skip to content

Instantly share code, notes, and snippets.

@elithrar elithrar/.travis.yml
Last active Jun 17, 2019

Embed
What would you like to do?
CircleCI vs. TravisCI for gorilla/mux - comparing maintainability, verbosity, DRY, etc. Ref: https://twitter.com/elithrar/status/1140342082768261120
language: go
matrix:
include:
- go: 1.7.x
- go: 1.8.x
- go: 1.9.x
- go: 1.10.x
- go: 1.11.x
- go: 1.x
env: LATEST=true
- go: tip
allow_failures:
- go: tip
install:
- # Skip
script:
- go get -t -v ./...
- diff -u <(echo -n) <(gofmt -d .)
- if [[ "$LATEST" = true ]]; then go vet .; fi
- go test -v -race ./...
version: 2.0
jobs:
# Base test configuration for Go library tests Each distinct version should
# inherit this base, and override (at least) the container image used.
"test": &test
docker:
- image: circleci/golang:latest
working_directory: /go/src/github.com/gorilla/mux
steps: &steps
- checkout
- run: go version
- run: go get -t -v ./...
- run: diff -u <(echo -n) <(gofmt -d .)
- run: if [[ "$LATEST" = true ]]; then go vet -v .; fi
- run: go test -v -race ./...
"latest":
<<: *test
environment:
LATEST: true
"1.12":
<<: *test
docker:
- image: circleci/golang:1.12
"1.11":
<<: *test
docker:
- image: circleci/golang:1.11
"1.10":
<<: *test
docker:
- image: circleci/golang:1.10
"1.9":
<<: *test
docker:
- image: circleci/golang:1.9
"1.8":
<<: *test
docker:
- image: circleci/golang:1.8
"1.7":
<<: *test
docker:
- image: circleci/golang:1.7
workflows:
version: 2
build:
jobs:
- "latest"
- "1.12"
- "1.11"
- "1.10"
- "1.9"
- "1.8"
- "1.7"
@elithrar

This comment has been minimized.

Copy link
Owner Author

commented Jun 17, 2019

A variant that uses Parameters in v2.1 to re-use more code.

  • Pros: only need to write the version once (important, as version numbers tend to be error prone, and CI configs are hard to test on their own), overall readability is maintained
  • Cons: every test is called "test-$n" in the workflow UI, which makes it harder to debug workflow and far less clear to someone submitting a PR (and seeing the status update).

image

version: "2.1"

jobs:
  # Base test configuration for Go library tests Each distinct version should
  # inherit this base, and override (at least) the container image used.
  test:
    parameters:
      v:
        type: string
        default: "latest"
      latest:
        type: boolean
        default: false
    docker:
      - image: "circleci/golang:<< parameters.v >>"
    working_directory: /go/src/github.com/gorilla/mux
    steps:
      - checkout
      - run: go version
      - run: go get -t -v ./...
      - run: diff -u <(echo -n) <(gofmt -d .)
      - run: if [[ "$LATEST" = true ]]; then go vet -v .; fi
      - run: go test -v -race ./...

workflows:
  workflow:
    jobs:
      - test:
          v: "latest"
          latest: true
      - test:
          v: "1.12"
      - test:
          v: "1.11"
      - test:
          v: "1.10"
      - test:
          v: "1.9"
      - test:
          v: "1.8"
      - test:
          v: "1.7"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.