Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 38 additions & 97 deletions bitrise.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
format_version: 5
format_version: "13"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

include:
- repository: steps-check
branch: master
path: step-metadata.bitrise.yml
- repository: steps-check
branch: master
path: golang.bitrise.yml

app:
envs:
- STEP_VERSION: 2.1.0
Expand All @@ -16,14 +24,36 @@ workflows:
# ----------------------------------------------------------------
# --- workflow to Step Test
ci:
test:
before_run:
- audit-this-step
steps:
- go-list:
- golint:
- errcheck:
- go-test:
- script@1:
title: yamlfmt
inputs:
- content: |-
#!/bin/env bash
set -eo pipefail
set -x

# TODO: deviates from the step-repo convention on purpose. bundle::yamlfmt only
# reformats and leaves autofix-ci to commit the result, which needs Unified CI, so
# here it could never fail. Lint instead until this Step migrates, then switch back.
ymlfmt_conf="$(mktemp)"
curl -sSfL -o "$ymlfmt_conf" https://raw.githubusercontent.com/bitrise-steplib/steps-check/refs/heads/master/.ymlfmt
go run github.com/google/yamlfmt/cmd/yamlfmt@v0.21.0 -lint -conf "$ymlfmt_conf" -match_type doublestar -exclude "_tmp/**,.bitrise.secrets.yml,.git/**,.github/**,vendor/**" '**/*.yml'
- bundle::step-yml-audit: {}
- script@1:
title: Add GOPATH/bin to PATH
inputs:
- content: |-
#!/bin/env bash
set -eo pipefail
# The golangci-lint bundle installs into $(go env GOPATH)/bin and then invokes the
# binary by name. That directory is not on PATH on this stack, where Go is managed
# by asdf, so the bundle fails with "golangci-lint: command not found".
envman add --key PATH --value "$(go env GOPATH)/bin:$PATH"
- bundle::golangci-lint:
inputs:
- golangci_lint_version: 2.11.4
- bundle::go-test: {}
after_run:
- _test_invalid
- _test_success
Expand Down Expand Up @@ -72,92 +102,3 @@ workflows:
- repository_url: "$TEST_REPOSITORY_URL"
- commit_hash:
- build_url: $TEST_BUILD_URL

go-tests:
before_run:
- _install-test-tools
steps:
- script:
title: Export go files to test
inputs:
- content: |-
#!/usr/bin/env bash
set -ex

no_vendor_paths="$(go list ./... | grep -v vendor)"
envman add --key GOLIST_WITHOUT_VENDOR --value "$no_vendor_paths"
- script:
title: Err check
inputs:
- content: |-
#!/usr/bin/env bash
set -ex

errcheck -asserts=true -blank=true $GOLIST_WITHOUT_VENDOR
- script:
title: Go lint
inputs:
- content: |-
#!/usr/bin/env bash
set -ex

while read -r line; do
echo "-> Linting: $line"
golint_out="$(golint $line)"
if [[ "${golint_out}" != "" ]] ; then
echo "=> Golint issues found:"
echo "${golint_out}"
exit 1
fi
done <<< "$GOLIST_WITHOUT_VENDOR"
- script:
title: Go test
inputs:
- content: |-
#!/usr/bin/env bash
set -ex

go test ./...

_install-test-tools:
steps:
- script:
title: Install required testing tools
inputs:
- content: |-
#!/usr/bin/env bash
set -ex

# Check for unhandled errors
go get -u -v github.com/kisielk/errcheck

# Go lint
go get -u -v github.com/golang/lint/golint

# ----------------------------------------------------------------
# --- Utility workflows
dep-update:
title: Dep update
description: |
Used for updating bitrise dependencies with dep
steps:
- script:
title: Dependency update
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
go get -u -v github.com/golang/dep/cmd/dep
dep ensure -v
dep ensure -v -update

# ----------------------------------------------------------------
# --- workflows to Share this step into a Step Library
audit-this-step:
steps:
- script:
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
stepman audit --step-yml ./step.yml
Loading
Loading