Skip to content

Instantly share code, notes, and snippets.

@elithrar
Last active June 29, 2019 17:34
Show Gist options
  • Save elithrar/3bf2e3bd60292e71d3b735cdab06cc78 to your computer and use it in GitHub Desktop.
Save elithrar/3bf2e3bd60292e71d3b735cdab06cc78 to your computer and use it in GitHub Desktop.
Generate a @circleci Config for Go for the @gorilla Toolkit - https://github.com/gorilla
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 ./...
# Only run gofmt, vet & lint against the latest Go version
- run: >
if [[ "$LATEST" = true ]]; then
diff -u <(echo -n) <(gofmt -d .)
fi
- run: >
if [[ "$LATEST" = true ]]; then
go vet -v .
fi
- run: go test -v -race ./...
"latest":
<<: *test
environment:
LATEST: true
{{ range .Versions }}
"{{ . }}":
<<: *test
docker:
- image: circleci/golang:{{ . }}
{{ end }}
workflows:
version: 2
build:
jobs:
- "latest"{{ range .Versions }}
- "{{ . }}"{{ end }}
#!/bin/bash
# Error handling
trap 'ret=$?; test $ret -ne 0 && printf "Fetch failed\n" >&2; exit $ret' EXIT
set -e
get_repo_names() {
if ! [ -x "$(command -v jq)" ]; then
printf "jq is not installed\n"
exit 0
fi
curl -s https://api.github.com/orgs/gorilla/repos | jq '.[] | select(.name | contains("github") | not) | .name'
}
get_repo_names()
package main
import (
"log"
"os"
"text/template"
)
var (
versions = []string{"1.12", "1.11", "1.10", "1.9", "1.8", "1.7"}
libraries = []string{"handlers", "css", "feeds", "schema", "rpc", "securecookie", "sessions", "mux"}
)
func main() {
// load configTemplate from a file
tmpl, err := template.New("config").Parse(string(configTemplate))
if err != nil {
log.Fatal(err)
}
for _, lib := range libraries {
if err := tmpl.Execute(os.Stdout, map[string]interface{}{
"RepoUser": "gorilla",
"RepoName": lib,
"Versions": versions,
}); err != nil {
log.Fatal(err)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment