1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
sap-jenkins-library/.github/workflows/verify-go.yml
Marcus Holl a6b2cb9c83
Tell us what was changed. (#2492)
With the current approach we get a failure when the generated
content triggers a change. But we cannot see what was changed.

With this commit we can see the diff. In case there is not diff
we will not see anything, so there is in that case no real change
in the behaviour. But in case there is a change we will see that
change.

Without that we have to reproduce locally, which means additional
efforts.
2021-01-04 13:23:30 +01:00

96 lines
2.5 KiB
YAML

name: Go
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
unit:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v1
with:
go-version: '1.15.x'
- name: Cache Golang Packages
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-golang-${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-golang-
- name: checkout
uses: actions/checkout@v2
- name: unit-test
uses: paambaati/codeclimate-action@v2.6.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_REPORTER_ID }}
with:
coverageCommand: go test ./... -coverprofile cover.out
coverageLocations: cover.out:gocov
# truncate package name from file paths in report
prefix: github.com/SAP/jenkins-library/
format:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v1
with:
go-version: '1.15.x'
- name: Cache Golang Packages
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-golang-format${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-golang-format
${{ runner.os }}-golang-
- name: checkout
uses: actions/checkout@v2
- name: format
run: go fmt ./...
- name: verify
run: git diff --name-only --exit-code
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v1
with:
go-version: '1.15.x'
- name: Cache Golang Packages
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-golang-generate${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-golang-generate
${{ runner.os }}-golang-
- name: checkout
uses: actions/checkout@v2
- name: generate
run: go run pkg/generator/step-metadata.go
- name: verify
run: git diff --exit-code
dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v1
with:
go-version: '1.15.x'
- name: Cache Golang Packages
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-golang-dependencies${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-golang-dependencies
${{ runner.os }}-golang-
- name: checkout
uses: actions/checkout@v2
- name: cleanup dependencies
run: go mod tidy
- name: verify
run: git diff --name-only --exit-code