From b1ba2f75df57b18a53ae9b21a46a65dec62a1c26 Mon Sep 17 00:00:00 2001 From: Yuvraj Date: Thu, 17 Feb 2022 08:31:41 +0530 Subject: [PATCH] Added reuseable workflows (#34) * Added reuseable workflows Signed-off-by: Yuvraj * more changes Signed-off-by: Yuvraj --- .github/workflows/boilerplate-automation.yml | 37 -------- .github/workflows/checks.yml | 80 ++++++++++++++++ .github/workflows/master.yml | 97 -------------------- .github/workflows/pull_request.yml | 80 ---------------- .github/workflows/release-automation.yml | 42 --------- .github/workflows/release.yml | 26 ------ .github/workflows/upgrade_automtion.yml | 20 ++++ 7 files changed, 100 insertions(+), 282 deletions(-) delete mode 100644 .github/workflows/boilerplate-automation.yml create mode 100644 .github/workflows/checks.yml delete mode 100644 .github/workflows/master.yml delete mode 100644 .github/workflows/pull_request.yml delete mode 100644 .github/workflows/release-automation.yml delete mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/upgrade_automtion.yml diff --git a/.github/workflows/boilerplate-automation.yml b/.github/workflows/boilerplate-automation.yml deleted file mode 100644 index d4a76239be..0000000000 --- a/.github/workflows/boilerplate-automation.yml +++ /dev/null @@ -1,37 +0,0 @@ -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 - 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 - diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000000..2fee547bad --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,80 @@ +name: Flyte copilot Checks + +on: + workflow_dispatch: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + lint: + name: Lint + uses: flyteorg/flytetools/.github/workflows/lint.yml@master + + tests: + name: Unit Tests + uses: flyteorg/flytetools/.github/workflows/tests.yml@master + secrets: + FLYTE_BOT_PAT: ${{ secrets.FLYTE_BOT_PAT }} + + dry_run: + name: Dry run goreleaser + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '1.16' + - name: Run GoReleaser dry run + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: --snapshot --skip-publish --rm-dist + + build_docker_image: + name: Build & Push Flyte copilot Image + uses: flyteorg/flytetools/.github/workflows/publish.yml@master + with: + version: v1 + dockerfile: Dockerfile + push: false + repository: ${{ github.repository }} + secrets: + FLYTE_BOT_PAT: ${{ secrets.FLYTE_BOT_PAT }} + FLYTE_BOT_USERNAME: ${{ secrets.FLYTE_BOT_USERNAME }} + + generate: + name: Check Go Gennerate + uses: flyteorg/flytetools/.github/workflows/go_generate.yml@master + + bump_version: + name: Bump Version + if: ${{ github.event_name != 'pull_request' }} + needs: [ lint, tests, generate, dry_run, build_docker_image ] # Only to ensure it can successfully build + uses: flyteorg/flytetools/.github/workflows/bump_version.yml@master + secrets: + FLYTE_BOT_PAT: ${{ secrets.FLYTE_BOT_PAT }} + + goreleaser: + name: Goreleaser + needs: [ bump_version ] # Only to ensure it can successfully build + uses: flyteorg/flytetools/.github/workflows/goreleaser.yml@master + secrets: + FLYTE_BOT_PAT: ${{ secrets.FLYTE_BOT_PAT }} + + push_docker_image: + name: Build & Push Flyte copilot Image + needs: [ bump_version ] + uses: flyteorg/flytetools/.github/workflows/publish.yml@master + with: + version: ${{ needs.bump_version.outputs.version }} + dockerfile: Dockerfile + push: true + repository: ${{ github.repository }} + secrets: + FLYTE_BOT_PAT: ${{ secrets.FLYTE_BOT_PAT }} + FLYTE_BOT_USERNAME: ${{ secrets.FLYTE_BOT_USERNAME }} diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml deleted file mode 100644 index 0aef5a35fd..0000000000 --- a/.github/workflows/master.yml +++ /dev/null @@ -1,97 +0,0 @@ -name: Master - -on: - push: - branches: - - master - -jobs: - # Duplicated from pull request workflow because sharing is not yet supported - build-docker: - name: Build Docker Image - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - id: load-docker-cache - name: Load Docker Cache - uses: actions/cache@v1 - with: - path: /tmp/tmp/docker-images - key: /tmp/docker-images-${{ github.event.after }} - restore-keys: | - /tmp/docker-images-${{ github.event.before }} - /tmp/docker-images-${{ github.event.pull_request.base.sha }} - - name: Prime docker cache - run: (docker load -i /tmp/tmp/docker-images/snapshot-builder.tar || true) && (docker load -i /tmp/tmp/docker-images/snapshot.tar || true) - - name: Build dockerfile - run: | - docker build -t lyft/${{ github.event.repository.name }}:builder --target builder --cache-from=lyft/${{ github.event.repository.name }}:builder . - docker build -t lyft/${{ github.event.repository.name }}:latest --cache-from=lyft/${{ github.event.repository.name }}:builder . - - - name: Tag and cache docker image - run: mkdir -p /tmp/tmp/docker-images && docker save lyft/${{ github.event.repository.name }}:builder -o /tmp/tmp/docker-images/snapshot-builder.tar && docker save lyft/${{ github.event.repository.name }}:latest -o /tmp/tmp/docker-images/snapshot.tar - - bump-version: - name: Bump Version - if: github.actor != 'goreleaserbot' - runs-on: ubuntu-latest - needs: build-docker # Only to ensure it can successfully build - outputs: - version: ${{ steps.bump-version.outputs.tag }} - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: '0' - - name: Bump version and push tag - id: bump-version - uses: anothrNick/github-tag-action@1.17.2 - env: - GITHUB_TOKEN: ${{ secrets.FLYTE_BOT_PAT }} - WITH_V: true - DEFAULT_BUMP: patch - - push-github: - name: Push to Github Registry - runs-on: ubuntu-latest - needs: bump-version - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: '0' - - name: Push Docker Image to Github Registry - uses: whoan/docker-build-with-cache-action@v5 - with: - username: "${{ secrets.FLYTE_BOT_USERNAME }}" - password: "${{ secrets.FLYTE_BOT_PAT }}" - image_name: ${{ github.repository }} - image_tag: latest,${{ github.sha }},${{ needs.bump-version.outputs.version }} - push_git_tag: true - registry: ghcr.io - build_extra_args: "--compress=true" - - tests-lint: - name: Run tests and lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: '0' - - name: Unit Tests - uses: cedrickring/golang-action@1.5.2 - env: - GO111MODULE: "on" - with: - args: make install && make test_unit_codecov - - name: Push CodeCov - uses: codecov/codecov-action@v1 - with: - file: coverage.txt - flags: unittests - fail_ci_if_error: true - - name: Lint - uses: cedrickring/golang-action@1.5.2 - env: - GO111MODULE: "on" - with: - args: make install && make lint \ No newline at end of file diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml deleted file mode 100644 index e77f6fd48e..0000000000 --- a/.github/workflows/pull_request.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Pull Request - -on: - pull_request - -jobs: - build-docker: - name: Build Docker Image - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - id: load-docker-cache - name: Load Docker Cache - uses: actions/cache@v1 - with: - path: /tmp/tmp/docker-images - key: /tmp/docker-images-${{ github.event.after }} - restore-keys: | - /tmp/docker-images-${{ github.event.before }} - /tmp/docker-images-${{ github.event.pull_request.base.sha }} - - name: Prime docker cache - run: (docker load -i /tmp/tmp/docker-images/snapshot-builder.tar || true) && (docker load -i /tmp/tmp/docker-images/snapshot.tar || true) - - name: Build dockerfile - run: | - docker build -t lyft/${{ github.event.repository.name }}:builder --target builder --cache-from=lyft/${{ github.event.repository.name }}:builder . - docker build -t lyft/${{ github.event.repository.name }}:latest --cache-from=lyft/${{ github.event.repository.name }}:builder . - - - name: Tag and cache docker image - run: mkdir -p /tmp/tmp/docker-images && docker save lyft/${{ github.event.repository.name }}:builder -o /tmp/tmp/docker-images/snapshot-builder.tar && docker save lyft/${{ github.event.repository.name }}:latest -o /tmp/tmp/docker-images/snapshot.tar - - tests-lint: - name: Run tests and lint - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Unit Tests - uses: cedrickring/golang-action@1.5.2 - env: - GO111MODULE: "on" - with: - args: make install && make test_unit_codecov - - name: Push CodeCov - uses: codecov/codecov-action@v1 - with: - file: coverage.txt - flags: unittests - fail_ci_if_error: true - - name: Lint - uses: cedrickring/golang-action@1.5.2 - env: - GO111MODULE: "on" - with: - args: make install && make lint - - dry-run-gorelease: - name: Dry run goreleaser - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - go-version: '1.16' - - name: Run GoReleaser dry run - uses: goreleaser/goreleaser-action@v2 - with: - version: latest - args: --snapshot --skip-publish --rm-dist - - generate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions/setup-go@v2 - with: - go-version: '1.16' - - name: Go generate and diff - run: DELTA_CHECK=true make generate \ No newline at end of file diff --git a/.github/workflows/release-automation.yml b/.github/workflows/release-automation.yml deleted file mode 100644 index b3176452da..0000000000 --- a/.github/workflows/release-automation.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Update flyteidl version - -on: - workflow_dispatch: - -jobs: - update-flyte-releases: - name: Update Flyteidl version - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: "0" - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.16 - - name: Update release - run: | - FLYTEIDL_VERSION=$(curl --silent "https://api.github.com/repos/flyteorg/flyteidl/releases/latest" | jq -r .tag_name) - go get -u github.com/flyteorg/flyteidl@$FLYTEIDL_VERSION - - name: Create Pull Request - id: cpr - uses: peter-evans/create-pull-request@v3 - with: - token: ${{ secrets.FLYTE_BOT_PAT }} - commit-message: Update Flyteidl version - committer: Flyte-Bot - author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> - signoff: true - branch: flyte-bot-update-flyteidl - delete-branch: true - title: 'Update Flyteidl version' - body: | - Update Flyteidl version - - Auto-generated by [flyte-bot] - labels: | - flyteidl - team-reviewers: | - owners - maintainers - draft: false \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index fff2994a1b..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Release Flytecopilot - -on: - push: - tags: - - 'v*' - -jobs: - releaser: - name: Release flytecopilot - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: "0" - - uses: actions/setup-go@v2 - with: - go-version: '1.16' - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 - with: - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.FLYTE_BOT_PAT }} diff --git a/.github/workflows/upgrade_automtion.yml b/.github/workflows/upgrade_automtion.yml new file mode 100644 index 0000000000..b94163b1c2 --- /dev/null +++ b/.github/workflows/upgrade_automtion.yml @@ -0,0 +1,20 @@ +name: Upgrade Automation +on: + workflow_dispatch: + inputs: + component: + description: "Name of Flyte component" + required: true + default: "boilerplate" + type: choice + options: + - boilerplate + - flyteidl +jobs: + trigger-upgrade: + name: ${{ github.event.inputs.component }} Upgrade + uses: flyteorg/flytetools/.github/workflows/flyte_automation.yml@master + with: + component: ${{ github.event.inputs.component }} + secrets: + FLYTE_BOT_PAT: ${{ secrets.FLYTE_BOT_PAT }}