Merge pull request #538 from meshery/dependabot/go_modules/github.com… #1131
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Default Meshery Linkerd Workflow | |
on: | |
push: | |
branches: | |
- '*' | |
tags: | |
- 'v*' | |
paths-ignore: | |
- 'docs/**' | |
- '.github/**' | |
- 'img/**' | |
- 'templates/**' | |
pull_request: | |
branches: | |
- master | |
paths: | |
- '**.go' | |
- '**.yml' | |
- '**.yaml' | |
jobs: | |
detect_changes: | |
runs-on: ubuntu-latest | |
outputs: | |
go_changes: ${{ steps.filter.outputs.go_changes }} | |
yaml_changes: ${{ steps.filter.outputs.yaml_changes }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
filters: | | |
go_changes: | |
- '**.go' | |
yaml_changes: | |
- '**.yml' | |
- '**.yaml' | |
golangci-lint: | |
runs-on: ubuntu-latest | |
needs: detect_changes | |
if: needs.detect_changes.outputs.go_changes == 'true' | |
steps: | |
- name: Setup go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.19' | |
- name: Cache Go modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-build-codegen-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-build-codegen- | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Run Linters | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
args: --timeout 3m --verbose | |
codecov: | |
name: Code Coverage | |
if: github.repository == 'meshery/meshery-linkerd' | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@master | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.19.x | |
- name: Run unit tests | |
run: go test --short ./... -race -coverprofile=coverage.txt -covermode=atomic | |
- name: Upload coverage to Codecov | |
if: github.repository == 'meshery/meshery-linkerd' | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./coverage.txt | |
flags: unittests | |
error_code_check: | |
name: Error code utility check | |
runs-on: ubuntu-22.04 | |
needs: detect_changes | |
if: needs.detect_changes.outputs.yaml_changes == 'true' | |
steps: | |
- name: Setup go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.19' | |
- name: Cache Go modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-build-codegen-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-build-codegen- | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- run: | | |
errWillHave="level=error" | |
GOPROXY=https://proxy.golang.org,direct GOSUMDB=off GO111MODULE=on go install github.com/layer5io/meshkit/cmd/errorutil; | |
err=$(/home/runner/go/bin/errorutil -d . update --skip-dirs meshery -i ./helpers -o ./helpers); | |
echo "ERR: $err"; | |
if [[ $err == *"$errWillHave"* ]]; | |
then | |
echo "$err"; | |
return 1; | |
fi | |
tests: | |
name: Tests | |
runs-on: ubuntu-22.04 | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
steps: | |
- name: Setup go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.19' | |
- name: Cache Go modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-build-codegen-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-build-codegen- | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: Create cluster using KinD | |
uses: engineerd/[email protected] | |
with: | |
version: "v0.11.0" | |
- run: | | |
export CURRENTCONTEXT="$(kubectl config current-context)" | |
echo "current-context:" ${CURRENTCONTEXT} | |
export KUBECONFIG="${HOME}/.kube/config" | |
echo "environment-kubeconfig:" ${KUBECONFIG} | |
GOPROXY=https://proxy.golang.org,direct GOSUMDB=off GO111MODULE=on go test -v ./... |