Skip to content

Commit

Permalink
Merge pull request #27 from linode/update_upjet_version
Browse files Browse the repository at this point in the history
Bump upjet to v1.1.0, enable cli-less provisioning models
  • Loading branch information
eljohnson92 committed Feb 12, 2024
2 parents 08c05b2 + 14a015e commit c4a9d3c
Show file tree
Hide file tree
Showing 265 changed files with 17,935 additions and 4,997 deletions.
142 changes: 34 additions & 108 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ on:

env:
# Common versions
GO_VERSION: '1.19'
GOLANGCI_VERSION: 'v1.50.0'
GO_VERSION: '1.21'
GOLANGCI_VERSION: 'v1.54.2'
DOCKER_BUILDX_VERSION: 'v0.8.2'

# 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
# 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-noop:
runs-on: ubuntu-22.04
Expand All @@ -35,54 +34,48 @@ jobs:
steps:
- name: Detect No-op Changes
id: noop
uses: fkirc/skip-duplicate-actions@v5.3.0
uses: fkirc/skip-duplicate-actions@12aca0a884f6137d619d6a8a09fcc3406ced5281 # v5.3.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
paths_ignore: '["**.md", "**.png", "**.jpg"]'
do_not_skip: '["workflow_dispatch", "schedule", "push"]'


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

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
with:
submodules: true

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3
with:
# turn off caching as it currently conflicts with the golangci-lint action https://github.com/golangci/golangci-lint-action/issues/863
cache: false
go-version: ${{ env.GO_VERSION }}

- name: Find the Go Build Cache
id: go
run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT

- name: Cache the Go Build Cache
uses: actions/cache@v3
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3
with:
path: ${{ steps.go.outputs.cache }}
key: ${{ runner.os }}-build-lint-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-build-lint-

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

- name: Vendor Dependencies
run: make vendor vendor.check

# 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
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3
with:
version: ${{ env.GOLANGCI_VERSION }}

Expand All @@ -93,41 +86,42 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
with:
submodules: true

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3
with:
go-version: ${{ env.GO_VERSION }}

- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports
run: |
cd /tmp
go install golang.org/x/tools/cmd/goimports@v0.1.12
- name: Find the Go Build Cache
id: go
run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT

- name: Cache the Go Build Cache
uses: actions/cache@v3
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3
with:
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@v3
with:
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-pkg-

- name: Vendor Dependencies
run: make vendor vendor.check

- name: Check Diff
run: make check-diff
id: check-diff
run: |
make check-diff
- name: Show diff
if: failure() && steps.check-diff.outcome == 'failure'
run: git diff

unit-tests:
runs-on: ubuntu-22.04
Expand All @@ -136,15 +130,15 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
with:
submodules: true

- name: Fetch History
run: git fetch --prune --unshallow

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3
with:
go-version: ${{ env.GO_VERSION }}

Expand All @@ -153,109 +147,51 @@ jobs:
run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT

- name: Cache the Go Build Cache
uses: actions/cache@v3
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3
with:
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@v3
with:
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-pkg-

- name: Vendor Dependencies
run: make vendor vendor.check

- name: Run Unit Tests
run: make -j2 test

- name: Publish Unit Test Coverage
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3
with:
flags: unittests
file: _output/tests/linux_amd64/coverage.txt

local-deploy:
runs-on: ubuntu-22.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true

- name: Fetch History
run: git fetch --prune --unshallow

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: Find the Go Build Cache
id: go
run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT

- name: Cache the Go Build Cache
uses: actions/cache@v3
with:
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@v3
with:
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-pkg-

- name: Vendor Dependencies
run: make vendor vendor.check

- name: Deploying locally built provider package
run: make local-deploy

publish-artifacts:
runs-on: ubuntu-22.04
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'

steps:
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2
with:
platforms: all

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2
with:
version: ${{ env.DOCKER_BUILDX_VERSION }}
install: true

- name: Login to Upbound
uses: docker/login-action@v2
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
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
with:
submodules: true

- name: Fetch History
run: git fetch --prune --unshallow

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3
with:
go-version: ${{ env.GO_VERSION }}

Expand All @@ -264,19 +200,12 @@ jobs:
run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT

- name: Cache the Go Build Cache
uses: actions/cache@v3
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3
with:
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@v3
with:
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-pkg-

- name: Vendor Dependencies
run: make vendor vendor.check

Expand All @@ -287,11 +216,8 @@ jobs:
# builds by default. Specifying --load does so.
BUILD_ARGS: "--load"

- name: Upload Artifacts to GitHub
uses: actions/upload-artifact@v2
- name: Publish Artifacts to GitHub
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
with:
name: output
path: _output/**

- name: Publish Artifacts
run: make publish BRANCH_NAME=${GITHUB_REF##*/}
30 changes: 15 additions & 15 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
run:
deadline: 10m
deadline: 20m

skip-files:
- "zz_\\..+\\.go$"
- "zz_\\..+\\.go$"

output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
Expand All @@ -27,9 +27,9 @@ linters-settings:
# report about shadowed variables
check-shadowing: false

golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
revive:
# confidence for issues, default is 0.8
confidence: 0.8

gofmt:
# simplify code: gofmt with `-s` option, true by default
Expand All @@ -38,7 +38,7 @@ linters-settings:
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/upbound/upjet-provider-template
local-prefixes: github.com/linode/provider-linode

gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
Expand Down Expand Up @@ -113,7 +113,7 @@ linters:
- goimports
- gofmt # We enable this as well as goimports for its simplify mode.
- prealloc
- golint
- revive
- unconvert
- misspell
- nakedret
Expand All @@ -136,7 +136,7 @@ issues:
- gosec
- scopelint
- unparam

# Ease some gocritic warnings on test files.
- path: _test\.go
text: "(unnamedResult|exitAfterDefer)"
Expand All @@ -148,31 +148,31 @@ issues:
# rather than using a pointer.
- text: "(hugeParam|rangeValCopy):"
linters:
- gocritic
- gocritic

# This "TestMain should call os.Exit to set exit code" warning is not clever
# enough to notice that we call a helper method that calls os.Exit.
- text: "SA3000:"
linters:
- staticcheck
- staticcheck

- text: "k8s.io/api/core/v1"
linters:
- goimports
- goimports

# This is a "potential hardcoded credentials" warning. It's triggered by
# any variable with 'secret' in the same, and thus hits a lot of false
# positives in Kubernetes land where a Secret is an object type.
- text: "G101:"
linters:
- gosec
- gas
- gosec
- gas

# This is an 'errors unhandled' warning that duplicates errcheck.
- text: "G104:"
linters:
- gosec
- gas
- gosec
- gas

# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
Expand Down
Loading

0 comments on commit c4a9d3c

Please sign in to comment.