Skip to content

Commit

Permalink
Added boilerplate automation (#162)
Browse files Browse the repository at this point in the history
* Added boilerplate automation

Signed-off-by: Yuvraj <evalsocket@gmail.com>

* More changes

Signed-off-by: Yuvraj <evalsocket@gmail.com>
  • Loading branch information
yindia authored May 31, 2021
1 parent dc75d32 commit 170e0fe
Show file tree
Hide file tree
Showing 20 changed files with 1,395 additions and 658 deletions.
36 changes: 36 additions & 0 deletions flyteidl/.github/workflows/boilerplate-automation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Update Boilerplate Automation
on:
workflow_dispatch:

jobs:
update-boilerplate:
name: Update Boilerplate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: Update Boilerplate
run: |
make update_boilerplate
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.FLYTE_BOT_PAT }}
commit-message: Update Boilerplate
committer: Flyte-Bot <admin@flyte.org>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: true
branch: flyte-bot-update-boilerplate
delete-branch: true
title: 'Update Boilerplate'
body: |
Update Boilerplate
- Auto-generated by [flyte-bot]
labels: |
boilerplate
team-reviewers: |
owners
maintainers
draft: false
6 changes: 3 additions & 3 deletions flyteidl/.golangci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
# ONLY EDIT THIS FILE FROM WITHIN THE 'LYFT/BOILERPLATE' REPOSITORY:
# ONLY EDIT THIS FILE FROM WITHIN THE 'FLYTEORG/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst

run:
skip-dirs:
- pkg/client
- pkg/client
- gen

linters:
Expand Down
3 changes: 2 additions & 1 deletion flyteidl/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/bin/bash

export REPOSITORY=flyteidl
include boilerplate/lyft/golang_test_targets/Makefile
include boilerplate/flyte/golang_test_targets/Makefile

define PIP_COMPILE
pip-compile $(1) --upgrade --verbose
endef

.PHONY: update_boilerplate
update_boilerplate:
@curl https://raw.githubusercontent.com/flyteorg/boilerplate/master/boilerplate/update.sh -o boilerplate/update.sh
@boilerplate/update.sh

.PHONY: generate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
module github.com/lyft/boilerplate
module github.com/flyteorg/boilerplate

go 1.13
go 1.16

require (
github.com/alvaroloes/enumer v1.1.2
github.com/golangci/golangci-lint v1.22.2
github.com/lyft/flytestdlib v0.2.31
github.com/pseudomuto/protoc-gen-doc v1.4.1
github.com/flyteorg/flytestdlib v0.3.22
github.com/golangci/golangci-lint v1.38.0
github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5
)

Expand Down
1,267 changes: 1,267 additions & 0 deletions flyteidl/boilerplate/flyte/golang_support_tools/go.sum

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
package tools

import (
_ "github.com/alvaroloes/enumer"
_ "github.com/flyteorg/flytestdlib/cli/pflags"
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
_ "github.com/lyft/flytestdlib/cli/pflags"
_ "github.com/vektra/mockery/cmd/mockery"
_ "github.com/alvaroloes/enumer"
_ "github.com/pseudomuto/protoc-gen-doc"
)
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
# ONLY EDIT THIS FILE FROM WITHIN THE 'LYFT/BOILERPLATE' REPOSITORY:
# ONLY EDIT THIS FILE FROM WITHIN THE 'FLYTEORG/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst


.PHONY: download_tooling
download_tooling: #download dependencies (including test deps) for the package
@boilerplate/lyft/golang_test_targets/download_tooling.sh
@boilerplate/flyte/golang_test_targets/download_tooling.sh

.PHONY: lint
lint: download_tooling #lints the package for common code smells
Expand All @@ -16,7 +16,7 @@ lint: download_tooling #lints the package for common code smells
# skips 'vendor'
.PHONY: goimports
goimports:
@boilerplate/lyft/golang_test_targets/goimports
@boilerplate/flyte/golang_test_targets/goimports

.PHONY: mod_download
mod_download: #download dependencies (including test deps) for the package
Expand All @@ -39,9 +39,15 @@ test_benchmark:

.PHONY: test_unit_cover
test_unit_cover:
go test ./... -coverprofile /tmp/cover.out -covermode=count; go tool cover -func /tmp/cover.out
go test ./... -coverprofile /tmp/cover.out -covermode=count
go tool cover -func /tmp/cover.out

.PHONY: test_unit_visual
test_unit_visual:
go test ./... -coverprofile /tmp/cover.out -covermode=count; go tool cover -html=/tmp/cover.out

go test ./... -coverprofile /tmp/cover.out -covermode=count
go tool cover -html=/tmp/cover.out

.PHONY: test_unit_codecov
test_unit_codecov:
go test ./... -race -coverprofile=coverage.txt -covermode=atomic
curl -s https://codecov.io/bash > codecov_bash.sh && bash codecov_bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ Provides a ``test_benchmark`` target for benchmark tests.

**To Enable:**

Add ``lyft/golang_test_targets`` to your ``boilerplate/update.cfg`` file.
Add ``flyteorg/golang_test_targets`` to your ``boilerplate/update.cfg`` file.

Make sure you're using ``go mod`` for dependency management.

Provide a ``.golangci`` configuration (the lint target requires it).

Add ``include boilerplate/lyft/golang_test_targets/Makefile`` in your main ``Makefile`` _after_ your REPOSITORY environment variable
Add ``include boilerplate/flyte/golang_test_targets/Makefile`` in your main ``Makefile`` _after_ your REPOSITORY environment variable

::

REPOSITORY=<myreponame>
include boilerplate/lyft/golang_test_targets/Makefile
include boilerplate/flyte/golang_test_targets/Makefile

(this ensures the extra make targets get included in your main Makefile)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# pins. To facilitate this, we're maintaining two sets of go.mod/sum files - the second one only for tooling. This is
# the same approach that go 1.14 will take as well.
# See:
# https://github.com/lyft/flyte/issues/129
# https://github.com/flyteorg/flyte/issues/129
# https://github.com/golang/go/issues/30515 for some background context
# https://github.com/go-modules-by-example/index/blob/5ec250b4b78114a55001bd7c9cb88f6e07270ea5/010_tools/README.md

Expand All @@ -17,15 +17,14 @@ set -e
# In the format of "<cli>:<package>" or ":<package>" if no cli
tools=(
"github.com/vektra/mockery/cmd/mockery"
"github.com/lyft/flytestdlib/cli/pflags"
"github.com/flyteorg/flytestdlib/cli/pflags"
"github.com/golangci/golangci-lint/cmd/golangci-lint"
"github.com/alvaroloes/enumer"
"github.com/pseudomuto/protoc-gen-doc"
)

tmp_dir=$(mktemp -d -t gotooling-XXX)
echo "Using temp directory ${tmp_dir}"
cp -R boilerplate/lyft/golang_support_tools/* $tmp_dir
cp -R boilerplate/flyte/golang_support_tools/* $tmp_dir
pushd "$tmp_dir"

for tool in "${tools[@]}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
# ONLY EDIT THIS FILE FROM WITHIN THE 'LYFT/BOILERPLATE' REPOSITORY:
# ONLY EDIT THIS FILE FROM WITHIN THE 'FLYTEORG/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst

goimports -w $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./pkg/client/*")
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
# ONLY EDIT THIS FILE FROM WITHIN THE 'LYFT/BOILERPLATE' REPOSITORY:
# ONLY EDIT THIS FILE FROM WITHIN THE 'FLYTEORG/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst

run:
skip-dirs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Provides a ``.golangci`` file with the linters we've agreed upon.

**To Enable:**

Add ``lyft/golangci_file`` to your ``boilerplate/update.cfg`` file.
Add ``flyteorg/golangci_file`` to your ``boilerplate/update.cfg`` file.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash

# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
# ONLY EDIT THIS FILE FROM WITHIN THE 'LYFT/BOILERPLATE' REPOSITORY:
# ONLY EDIT THIS FILE FROM WITHIN THE 'FLYTEORG/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst

set -e

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Provides a Pull Request template.

**To Enable:**

Add ``lyft/golang_test_targets`` to your ``boilerplate/update.cfg`` file.
Add ``flyteorg/golang_test_targets`` to your ``boilerplate/update.cfg`` file.
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Read then delete

- Make sure to use a concise title for the pull-request.
- Use #patch, #minor or #major in the pull-request title to bump the corresponding version. Otherwise, the patch version
will be bumped. [More details](https://github.com/marketplace/actions/github-tag-bump)

# TL;DR
_Please replace this text with a description of what this PR accomplishes._

Expand All @@ -18,9 +24,9 @@ _Please replace this text with a description of what this PR accomplishes._
_How did you fix the bug, make the feature etc. Link to any design docs etc_

## Tracking Issue
https://github.com/lyft/flyte/issues/<number>
https://github.com/flyteorg/flyte/issues/<number>

## Follow-up issue
_NA_
OR
_https://github.com/lyft/flyte/issues/<number>_
_https://github.com/flyteorg/flyte/issues/<number>_
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash

# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
# ONLY EDIT THIS FILE FROM WITHIN THE 'LYFT/BOILERPLATE' REPOSITORY:
# ONLY EDIT THIS FILE FROM WITHIN THE 'FLYTEORG/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst

set -e

Expand Down
Loading

0 comments on commit 170e0fe

Please sign in to comment.