Skip to content

Commit

Permalink
Sync Github Workflows from offical provider aws
Browse files Browse the repository at this point in the history
Signed-off-by: Hasan Turken <turkenh@gmail.com>
  • Loading branch information
turkenh committed Nov 15, 2022
1 parent f61ead2 commit 85afcb9
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
# one. Many do not support merge commits, or do not support pull requests with
# more than one commit. This one does. It also handily links backport PRs with
# new PRs, and provides commentary and instructions when it can't backport.
# The master gotchas with this action are that it _only_ supports merge commits,
# The main gotchas with this action are that it _only_ supports merge commits,
# and that PRs _must_ be labelled before they're merged to trigger a backport.
open-pr:
runs-on: ubuntu-22.04
Expand Down
115 changes: 52 additions & 63 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI
on:
push:
branches:
- master
- main
- release-*
pull_request: {}
workflow_dispatch: {}
Expand All @@ -14,10 +14,12 @@ env:
GOLANGCI_VERSION: 'v1.50.0'
DOCKER_BUILDX_VERSION: 'v0.8.2'

UPBOUND_CI_ROBOT_USR: ${{ secrets.UPBOUND_CI_ROBOT_USR }}

# Common users. We can't run a step 'if secrets.XXX != ""' but we can run a
# step 'if env.XXX' != ""', so we copy these to succinctly test whether
# credentials have been provided before trying to run steps that need them.
UPBOUND_MARKETPLACE_PUSH_ROBOT_USR: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }}
jobs:
detect-changes:
detect-noop:
runs-on: ubuntu-22.04
outputs:
noop: ${{ steps.noop.outputs.should_skip }}
Expand All @@ -30,10 +32,12 @@ jobs:
paths_ignore: '["**.md", "**.png", "**.jpg"]'
do_not_skip: '["workflow_dispatch", "schedule", "push"]'


lint:
runs-on: ubuntu-22.04
needs: detect-changes
if: ${{ needs.detect-changes.outputs.noop != 'true' }}
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -47,7 +51,7 @@ jobs:

- name: Find the Go Build Cache
id: go
run: echo "::set-output name=cache::$(go env GOCACHE)"
run: echo "::set-output name=cache::$(make go.cachedir)"

- name: Cache the Go Build Cache
uses: actions/cache@v2
Expand All @@ -66,20 +70,18 @@ jobs:
- name: Vendor Dependencies
run: make vendor vendor.check

# We could run 'make lint' to ensure our desired Go version, but we
# prefer this action because it leaves 'annotations' (i.e. it comments
# on PRs to point out linter violations).
# We could run 'make lint' but we prefer this action because it leaves
# 'annotations' (i.e. it comments on PRs to point out linter violations).
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: ${{ env.GOLANGCI_VERSION }}
working-directory: ${{ matrix.providers }}
args: --timeout 10m0s

check-diff:
runs-on: ubuntu-22.04
needs: detect-changes
if: ${{ needs.detect-changes.outputs.noop != 'true' }}
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -95,22 +97,20 @@ jobs:
run: go install golang.org/x/tools/cmd/goimports

- name: Find the Go Build Cache
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(make go.cachedir)"
echo "::set-output name=go-mod::$(make go.mod.cachedir)"
id: go
run: echo "::set-output name=cache::$(make go.cachedir)"

- name: Cache the Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
path: ${{ steps.go.outputs.cache }}
key: ${{ runner.os }}-build-check-diff-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-build-check-diff-

- name: Cache Go Dependencies
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-pkg-

Expand All @@ -122,8 +122,8 @@ jobs:

unit-tests:
runs-on: ubuntu-22.04
needs: detect-changes
if: ${{ needs.detect-changes.outputs.noop != 'true' }}
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

steps:
- name: Checkout
Expand All @@ -140,22 +140,20 @@ jobs:
go-version: ${{ env.GO_VERSION }}

- name: Find the Go Build Cache
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(make go.cachedir)"
echo "::set-output name=go-mod::$(make go.mod.cachedir)"
id: go
run: echo "::set-output name=cache::$(make go.cachedir)"

- name: Cache the Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
path: ${{ steps.go.outputs.cache }}
key: ${{ runner.os }}-build-unit-tests-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-build-unit-tests-

- name: Cache Go Dependencies
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-pkg-

Expand All @@ -169,12 +167,12 @@ jobs:
uses: codecov/codecov-action@v1
with:
flags: unittests
file: ./_output/tests/linux_amd64/coverage.txt
file: _output/tests/linux_amd64/coverage.txt

e2e-tests:
publish-artifacts:
runs-on: ubuntu-22.04
needs: detect-changes
if: ${{ needs.detect-changes.outputs.noop != 'true' }}
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

steps:
- name: Setup QEMU
Expand All @@ -188,6 +186,14 @@ jobs:
version: ${{ env.DOCKER_BUILDX_VERSION }}
install: true

- name: Login to Upbound
uses: docker/login-action@v1
if: env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != ''
with:
registry: xpkg.upbound.io
username: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }}
password: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW }}

- name: Checkout
uses: actions/checkout@v2
with:
Expand All @@ -202,25 +208,22 @@ jobs:
go-version: ${{ env.GO_VERSION }}

- name: Find the Go Build Cache
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(make go.cachedir)"
echo "::set-output name=go-mod::$(make go.mod.cachedir)"
id: go
run: echo "::set-output name=cache::$(make go.cachedir)"

- name: Cache the Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-build-e2e-tests-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-build-e2e-tests-
path: ${{ steps.go.outputs.cache }}
key: ${{ runner.os }}-build-publish-artifacts-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-build-publish-artifacts-

- name: Cache Go Dependencies
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-pkg-
restore-keys: ${{ runner.os }}-pkg-

- name: Vendor Dependencies
run: make vendor vendor.check
Expand All @@ -231,27 +234,13 @@ jobs:
# We're using docker buildx, which doesn't actually load the images it
# builds by default. Specifying --load does so.
BUILD_ARGS: "--load"

# NOTE(hasheddan): this will load the package into the Docker daemon, but
# we will likely need to setup a step to apply a tag to the image in order
# for it to be used in e2e tests when they are added.
- name: Load Packages
run: make xpkg.load

- name: Run E2E Tests
run: make e2e USE_HELM3=true

check-examples:
runs-on: ubuntu-22.04
needs: detect-changes
if: ${{ needs.detect-changes.outputs.noop != 'true' }}

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Publish Artifacts to GitHub
uses: actions/upload-artifact@v2
with:
submodules: true
name: output
path: _output/**

- name: Check Example Manifests
run: |
./scripts/check-examples.py package/crds examples
- name: Publish Artifacts
if: env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != ''
run: make publish BRANCH_NAME=${GITHUB_REF##*/}
2 changes: 1 addition & 1 deletion .github/workflows/commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: issue_comment

jobs:
backport:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/backport')
steps:
- name: Extract Command
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Tag

on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. v0.1.0)'
required: true
message:
description: 'Tag message'
required: true

jobs:
create-tag:
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Create Tag
uses: negz/create-tag@v1
with:
version: ${{ github.event.inputs.version }}
message: ${{ github.event.inputs.message }}
token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 85afcb9

Please sign in to comment.