gorgonia.org/gorgonia@v0.9.17/.github/workflows/job-template.go (about) 1 package main 2 3 type ci struct { 4 Workflows []workflow 5 StableGoVersion string 6 PreviousGoVersion string 7 } 8 9 type workflow struct { 10 WorkflowName string 11 WorkflowFile string 12 Jobs []job 13 } 14 15 type job struct { 16 JobID string //stable-go 17 JobName string //Build and test on latest stable Go release 18 RunsOn string //ubuntu-latest 19 GoVersion string //1.15.x 20 Tags map[string]bool // none:false, avx:true, sse:true 21 WithRace bool // false 22 } 23 24 const workflowTmpl = `## DO NOT EDIT - This file is generated 25 on: [pull_request] 26 name: {{ .WorkflowName }} 27 env: 28 GOPROXY: "https://proxy.golang.org" 29 jobs: 30 {{- range .Jobs }}{{ template "Job" . }}{{ end }} 31 32 {{- define "Job" }} 33 {{ .JobID }}: 34 name: {{ .JobName }} 35 env: 36 GOVERSION: '{{ .GoVersion }}' 37 strategy: 38 matrix: 39 experimental: [false] 40 tags: [{{ mapToList .Tags }}] 41 {{- if hasExperimental .Tags }} 42 include: 43 {{- range $tag,$experimental := .Tags}} 44 {{- if $experimental }} 45 - tags: {{ $tag }} 46 experimental: true 47 {{- end}} 48 {{- end}} 49 {{- end}} 50 runs-on: "{{ .RunsOn }}" 51 continue-on-error: ${{"{{"}} matrix.experimental {{"}}"}} 52 steps: 53 - name: Install Go 54 uses: actions/setup-go@v2 55 with: 56 go-version: ${{"{{"}} env.GOVERSION {{"}}"}} 57 # Get values for cache paths to be used in later steps 58 - id: go-cache-paths 59 run: | 60 echo "::set-output name=go-build::$(go env GOCACHE)" 61 echo "::set-output name=go-mod::$(go env GOMODCACHE)" 62 - name: Checkout 63 uses: actions/checkout@v2 64 # Cache go build cache, used to speedup go test 65 - name: Go Build Cache 66 if: steps.go-cache-paths.outputs.go-build != '' 67 id: build-cache 68 uses: actions/cache@v2 69 with: 70 path: ${{"{{"}} steps.go-cache-paths.outputs.go-build {{"}}"}} 71 key: ${{"{{"}} runner.os {{"}}"}}-go-build-${{"{{"}} hashFiles('**/go.sum') {{"}}"}} 72 restore-keys: | 73 ${{"{{"}} runner.os {{"}}"}}-go-build- 74 # Cache go mod cache, used to speedup builds 75 - name: Go Mod Cache 76 if: steps.go-cache-paths.outputs.go-mod != '' 77 id: build-mod-cache 78 uses: actions/cache@v2 79 with: 80 path: ${{"{{"}} steps.go-cache-paths.outputs.go-mod {{"}}"}} 81 key: ${{"{{"}} runner.os {{"}}"}}-go-mod-${{"{{"}} hashFiles('**/go.sum') {{"}}"}} 82 restore-keys: | 83 ${{"{{"}} runner.os {{"}}"}}-go-mod- 84 - name: Install Dependencies 85 if: steps.build-mod-cache.outputs.cache-hit != 'true' 86 run: | 87 GOARCH=arm GOOS=linux go get -t . 88 GOARCH=amd64 GOOS=linux go get -t . 89 GOARCH=amd64 GOOS=darwin go get -t . 90 - name: Build without tags (all plateforms) 91 if: matrix.tags == 'none' 92 run: | 93 GOARCH=arm GOOS=linux go build . 94 GOARCH=amd64 GOOS=linux go build . 95 GOARCH=amd64 GOOS=darwin go build . 96 - name: Test without tags 97 if: matrix.tags == 'none' 98 run: | 99 go test {{if .WithRace}}-race{{end}} -timeout 20m 100 - name: Build with tag 101 if: matrix.tags != 'none' 102 run: | 103 go build -tags=${{"{{"}} matrix.tags {{"}}"}} 104 - name: Test with tag 105 if: matrix.tags != 'none' 106 run: | 107 go test {{if .WithRace}}-race{{end}} -timeout 20m -tags=${{"{{"}} matrix.tags {{"}}"}} 108 {{- end }} 109 `