Skip to content

Commit

Permalink
Added boilerplate automation (flyteorg#174)
Browse files Browse the repository at this point in the history
Signed-off-by: Yuvraj <evalsocket@gmail.com>
  • Loading branch information
yindia authored May 27, 2021
1 parent 1e550ad commit 93f5e74
Show file tree
Hide file tree
Showing 37 changed files with 1,513 additions and 659 deletions.
37 changes: 37 additions & 0 deletions flyteplugins/.github/workflows/boilerplate-automation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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

5 changes: 3 additions & 2 deletions flyteplugins/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export REPOSITORY=flyteplugins
include boilerplate/lyft/docker_build/Makefile
include boilerplate/lyft/golang_test_targets/Makefile
include boilerplate/flyte/docker_build/Makefile
include boilerplate/flyte/golang_test_targets/Makefile

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

generate: download_tooling
Expand Down
12 changes: 12 additions & 0 deletions flyteplugins/boilerplate/flyte/docker_build/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
# ONLY EDIT THIS FILE FROM WITHIN THE 'FLYTEORG/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst

.PHONY: docker_build
docker_build:
IMAGE_NAME=$$REPOSITORY ./boilerplate/flyte/docker_build/docker_build.sh

.PHONY: dockerhub_push
dockerhub_push:
IMAGE_NAME=flyteorg/$$REPOSITORY REGISTRY=docker.io ./boilerplate/flyte/docker_build/docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ If git head has a git tag, the Dockerhub image will also be tagged ``<IMAGE>:<GI

**To Enable:**

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

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

::

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

(this ensures the extra Make targets get included in your main Makefile)
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
9 changes: 9 additions & 0 deletions flyteplugins/boilerplate/flyte/end2end/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
# ONLY EDIT THIS FILE FROM WITHIN THE 'FLYTEORG/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst

.PHONY: end2end_execute
end2end_execute:
./boilerplate/flyte/end2end/end2end.sh

34 changes: 34 additions & 0 deletions flyteplugins/boilerplate/flyte/end2end/end2end.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/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 'FLYTEORG/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst

set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"

OUT="${DIR}/tmp"
rm -rf ${OUT}
git clone https://github.com/flyteorg/flyte.git "${OUT}"

pushd ${OUT}

if [ ! -z "$IMAGE" ];
then
kind load docker-image ${IMAGE}
if [ ${IMAGE_NAME} -eq "flytepropeller" ]
then
sed -i.bak -e "s_${IMAGE_NAME}:.*_${IMAGE}_g" ${OUT}/kustomize/base/propeller/deployment.yaml
fi

if [ ${IMAGE} -eq "flyteadmin" ]
then
sed -i.bak -e "s_${IMAGE_NAME}:.*_${IMAGE}_g" ${OUT}/kustomize/base/admindeployment/deployment.yaml
fi
fi

make kustomize
make end2end_execute
popd
16 changes: 16 additions & 0 deletions flyteplugins/boilerplate/flyte/flyte_golang_compile/Readme.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Flyte Golang Compile
~~~~~~~~~~~~~~~~~~~~

Common compile script for Flyte golang services.

**To Enable:**

Add ``flyteorg/flyte_golang_compile`` to your ``boilerplate/update.cfg`` file.

Add the following to your Makefile

::

.PHONY: compile_linux
compile_linux:
PACKAGES={{ *your packages }} OUTPUT={{ /path/to/output }} ./boilerplate/flyte/flyte_golang_compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
# ONLY EDIT THIS FILE FROM WITHIN THE 'FLYTEORG/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst

if [ -z "$PACKAGES" ]; then
echo "PACKAGES environment VAR not set"
exit 1
fi

if [ -z "$OUTPUT" ]; then
echo "OUTPUT environment VAR not set"
exit 1
fi

# get the GIT_SHA and RELEASE_SEMVER

GIT_SHA=$(git rev-parse HEAD)
RELEASE_SEMVER=$(git describe --tags --exact-match $GIT_SHA 2>/dev/null)

CURRENT_PKG=github.com/flyteorg/{{ REPOSITORY }}
VERSION_PKG="${CURRENT_PKG}/vendor/github.com/flyteorg/flytestdlib"

LDFLAGS="-X ${VERSION_PKG}/version.Build=${GIT_SHA} -X ${VERSION_PKG}/version.Version=${RELEASE_SEMVER}"

GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "$LDFLAGS" -o "$OUTPUT" "$PACKAGES"
13 changes: 13 additions & 0 deletions flyteplugins/boilerplate/flyte/flyte_golang_compile/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/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 'FLYTEORG/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst

set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"

echo " - generating ${DIR}/flyte_golang_compile.sh"
sed -e "s/{{REPOSITORY}}/${REPOSITORY}/g" ${DIR}/flyte_golang_compile.Template > ${DIR}/flyte_golang_compile.sh
22 changes: 22 additions & 0 deletions flyteplugins/boilerplate/flyte/github_workflows/Readme.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Golang Github Actions
~~~~~~~~~~~~~~~~~

Provides a two github actions workflows.

**To Enable:**

Add ``flyteorg/github_workflows`` to your ``boilerplate/update.cfg`` file.

Add a github secret ``package_name`` with the name to use for publishing (e.g. ``flytepropeller``). Typicaly, this will be the same name as the repository.

*Note*: If you are working on a fork, include that prefix in your package name (``myfork/flytepropeller``).

The actions will push to 2 repos:

1. ``docker.pkg.github.com/flyteorg/<repo>/<package_name>``
2. ``docker.pkg.github.com/flyteorg/<repo>/<package_name>-stages`` : this repo is used to cache build stages to speed up iterative builds after.

There are two workflows that get deployed:

1. A workflow that runs on Pull Requests to build and push images to github registy tagged with the commit sha.
2. A workflow that runs on master merges that bump the patch version of release tag, builds and pushes images to github registry tagged with the version, commit sha as well as "latest"
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
image_name: ${{ secrets.flytegithub_repo }}/operator
image_name: ${{ secrets.package_name }}
image_tag: latest,${{ github.sha }},${{ steps.bump-version.outputs.tag }}
push_git_tag: true
registry: docker.pkg.github.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
image_name: ${{ secrets.flytegithub_repo }}/operator
image_name: ${{ secrets.package_name }}
image_tag: ${{ github.sha }}
push_git_tag: true
registry: docker.pkg.github.com
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
@@ -1,20 +1,20 @@
# 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

FROM golang:1.13.3-alpine3.10 as builder
RUN apk add git openssh-client make curl

# COPY only the go mod files for efficient caching
COPY go.mod go.sum /go/src/github.com/lyft/{{REPOSITORY}}/
WORKDIR /go/src/github.com/lyft/{{REPOSITORY}}
COPY go.mod go.sum /go/src/github.com/flyteorg/{{REPOSITORY}}/
WORKDIR /go/src/github.com/flyteorg/{{REPOSITORY}}

# Pull dependencies
RUN go mod download

# COPY the rest of the source code
COPY . /go/src/github.com/lyft/{{REPOSITORY}}/
COPY . /go/src/github.com/flyteorg/{{REPOSITORY}}/

# This 'linux_compile' target should compile binaries to the /artifacts directory
# The main entrypoint should be compiled to /artifacts/{{REPOSITORY}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Provides a Dockerfile that produces a small image.

**To Enable:**

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

Create and configure a ``make linux_compile`` target that compiles your go binaries to the ``/artifacts`` directory ::

Expand Down
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
@@ -1,11 +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/flyteorg/flytestdlib v0.3.22
github.com/golangci/golangci-lint v1.38.0
github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5
)

Expand Down
Loading

0 comments on commit 93f5e74

Please sign in to comment.