Skip to content

Commit

Permalink
Merge branch 'main' into add-droplets-relationships-main
Browse files Browse the repository at this point in the history
  • Loading branch information
gururajsh authored May 29, 2024
2 parents 7f1b0e0 + eef705c commit edb7507
Show file tree
Hide file tree
Showing 206 changed files with 1,026 additions and 1,004 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: golangci-lint

on:
push:
tags:
- "v9.*"
- "v8.*"
- "v7.*"
pull_request:
types:
- opened
- reopened
- synchronize
branches:
- main
- v9
- v8
- v7
paths-ignore:
- "doc/**"
- ".gitpod.yml"
- "README.md"

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.58
args: -v --exclude-dirs cf --exclude-dirs fixtures --exclude-dirs plugin --exclude-dirs command/plugin
format:
name: Run go fmt
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Set Up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
- name: Run go fmt
run: go fmt && git diff --exit-code
29 changes: 17 additions & 12 deletions .github/workflows/release-build-sign-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: cloudfoundry/CLAW
ref: develop
ref: master
path: CLAW
ssh-key: ${{ secrets.GIT_SSH_KEY_CLAW }}

Expand All @@ -1076,18 +1076,23 @@ jobs:
set -ex
pushd CLAW
echo "- ${VERSION_BUILD}" >> claw-variables.yml
git add claw-variables.yml
if ! [ -z "$(git status --porcelain)"]; then
git config user.name github-actions
git config user.email [email protected]
git commit -m "Add CF CLI ${VERSION_BUILD}"
if grep --quiet "${VERSION_BUILD}" "claw-variables.yml" ; then
echo 'Version already exists in CLAW.'
exit 1
else
echo "no new version to commit"
echo "- ${VERSION_BUILD}" >> claw-variables.yml
git add claw-variables.yml
if ! [ -z "$(git status --porcelain)"]; then
git config user.name github-actions
git config user.email [email protected]
git commit -m "Add CF CLI ${VERSION_BUILD}"
else
echo "no new version to commit"
fi
git push
fi
git push
popd
# vim: set sw=2 ts=2 sts=2 et tw=78 foldlevel=2 fdm=indent nospell:
17 changes: 0 additions & 17 deletions .github/workflows/tests-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,6 @@ defaults:
shell: bash

jobs:
lint:
name: Lint code
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v4

- name: Set Up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true

- name: Run go fmt
run: go fmt && git diff --exit-code

units:
name: Units
strategy:
Expand Down
14 changes: 6 additions & 8 deletions .golangci.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"run": {
"concurrency": 4,
"timeout": "20m",
"skip-files": [
"integration/helpers/fake_server.go"
]
"timeout": "20m"
},
"linters": {
"disable-all": true,
Expand All @@ -14,15 +11,16 @@
"errcheck",
"staticcheck",
"unused",
"structcheck",
"varcheck",
"ineffassign",
"deadcode"
"ineffassign"
]
},
"linters-settings": {},
"issues": {
"max-same-issue": 0,
"exclude-files": [
"integration/helpers/fake_server.go",
"command/plugin/*.go$"
],
"exclude": [
"Error return value of `client.GetApplicationTasks` is not checked",
"Error return value of `logger.output.Stop` is not checked",
Expand Down
12 changes: 4 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,9 @@ integration-tests-full-ci: install-test-deps integration-cleanup
integration/shared/isolated integration/v7/isolated integration/shared/plugin integration/shared/experimental integration/v7/experimental integration/v7/push
$(ginkgo_int) -flake-attempts $(FLAKE_ATTEMPTS) integration/shared/global integration/v7/global

lint: ## Runs all linters and formatters
lint: format ## Runs all linters and formatters
@echo "Running linters..."
go list -f "{{.Dir}}" ./... \
| grep -v -e "/cf/" -e "/fixtures/" -e "/assets/" -e "/plugin/" -e "/command/plugin" -e "fakes" \
| xargs golangci-lint run
golangci-lint run --exclude-dirs cf --exclude-dirs fixtures --exclude-dirs plugin --exclude-dirs command/plugin
@echo "No lint errors!"

# TODO: version specific tagging for all these builds
Expand Down Expand Up @@ -206,15 +204,13 @@ units-non-plugin: install-test-deps
@rm -f $(wildcard fixtures/plugins/*.exe)
@ginkgo version
CF_HOME=$(CURDIR)/fixtures CF_USERNAME="" CF_PASSWORD="" $(ginkgo_units) \
-skip-package integration,cf\ssh,plugin,cf\actors\plugin,cf\commands\plugin,cf\actors\plugin,util\randomword
CF_HOME=$(CURDIR)/fixtures $(ginkgo_units) -flake-attempts 3 cf/ssh
-skip-package integration,plugin,cf\actors\plugin,cf\commands\plugin,cf\actors\plugin,util\randomword
else
units-non-plugin: install-test-deps
@rm -f $(wildcard fixtures/plugins/*.exe)
@ginkgo version
CF_HOME=$(CURDIR)/fixtures CF_USERNAME="" CF_PASSWORD="" $(ginkgo_units) \
-skip-package integration,cf/ssh,plugin,cf/actors/plugin,cf/commands/plugin,cf/actors/plugin,util/randomword
CF_HOME=$(CURDIR)/fixtures $(ginkgo_units) -flake-attempts 3 cf/ssh
-skip-package integration,plugin,cf/actors/plugin,cf/commands/plugin,cf/actors/plugin,util/randomword
endif

units-full: build units-plugin units-non-plugin
Expand Down
5 changes: 2 additions & 3 deletions actor/pluginaction/checksum_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package pluginaction_test

import (
"io/ioutil"
"os"

. "code.cloudfoundry.org/cli/actor/pluginaction"
Expand All @@ -25,11 +24,11 @@ var _ = Describe("Checksums", func() {
var file *os.File
BeforeEach(func() {
var err error
file, err = ioutil.TempFile("", "")
file, err = os.CreateTemp("", "")
Expect(err).NotTo(HaveOccurred())
defer file.Close()

err = ioutil.WriteFile(file.Name(), []byte("foo"), 0600)
err = os.WriteFile(file.Name(), []byte("foo"), 0600)
Expect(err).NotTo(HaveOccurred())
})

Expand Down
3 changes: 1 addition & 2 deletions actor/pluginaction/install.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package pluginaction

import (
"io/ioutil"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -189,7 +188,7 @@ func (actor Actor) InstallPluginFromPath(path string, plugin configv3.Plugin) er
}

func makeTempFile(tempDir string) (*os.File, error) {
tempFile, err := ioutil.TempFile(tempDir, "")
tempFile, err := os.CreateTemp(tempDir, "")
if err != nil {
return nil, err
}
Expand Down
17 changes: 8 additions & 9 deletions actor/pluginaction/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package pluginaction_test

import (
"errors"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -32,7 +31,7 @@ var _ = Describe("install actions", func() {
actor = NewActor(fakeConfig, fakeClient)

var err error
tempPluginDir, err = ioutil.TempDir("", "")
tempPluginDir, err = os.MkdirTemp("", "")
Expect(err).ToNot(HaveOccurred())
})

Expand All @@ -46,7 +45,7 @@ var _ = Describe("install actions", func() {
var pluginPath string

BeforeEach(func() {
tempFile, err := ioutil.TempFile("", "")
tempFile, err := os.CreateTemp("", "")
Expect(err).ToNot(HaveOccurred())

_, err = tempFile.WriteString("cthulhu")
Expand All @@ -66,7 +65,7 @@ var _ = Describe("install actions", func() {
copyPath, err := actor.CreateExecutableCopy(pluginPath, tempPluginDir)
Expect(err).ToNot(HaveOccurred())

contents, err := ioutil.ReadFile(copyPath)
contents, err := os.ReadFile(copyPath)
Expect(err).ToNot(HaveOccurred())
Expect(contents).To(BeEquivalentTo("cthulhu"))
})
Expand Down Expand Up @@ -101,14 +100,14 @@ var _ = Describe("install actions", func() {
BeforeEach(func() {
data = []byte("some test data")
fakeClient.DownloadPluginStub = func(_ string, path string, _ plugin.ProxyReader) error {
err := ioutil.WriteFile(path, data, 0700)
err := os.WriteFile(path, data, 0700)
Expect(err).ToNot(HaveOccurred())
return nil
}
})
It("returns the path to the file and the size", func() {
Expect(downloadErr).ToNot(HaveOccurred())
fileData, err := ioutil.ReadFile(path)
fileData, err := os.ReadFile(path)
Expect(err).ToNot(HaveOccurred())
Expect(fileData).To(Equal(data))

Expand Down Expand Up @@ -139,7 +138,7 @@ var _ = Describe("install actions", func() {

When("the file exists", func() {
BeforeEach(func() {
pluginFile, err := ioutil.TempFile("", "")
pluginFile, err := os.CreateTemp("", "")
Expect(err).NotTo(HaveOccurred())
err = pluginFile.Close()
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -701,14 +700,14 @@ var _ = Describe("install actions", func() {
},
}

pluginFile, err := ioutil.TempFile("", "")
pluginFile, err := os.CreateTemp("", "")
Expect(err).NotTo(HaveOccurred())
err = pluginFile.Close()
Expect(err).NotTo(HaveOccurred())

pluginPath = pluginFile.Name()

tempDir, err = ioutil.TempDir("", "")
tempDir, err = os.MkdirTemp("", "")
Expect(err).ToNot(HaveOccurred())

pluginHomeDir = filepath.Join(tempDir, ".cf", "plugin")
Expand Down
9 changes: 4 additions & 5 deletions actor/pluginaction/install_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package pluginaction_test

import (
"io/ioutil"
"os"
"path/filepath"

Expand All @@ -26,7 +25,7 @@ var _ = Describe("install actions", func() {
BeforeEach(func() {
fakeConfig = new(pluginactionfakes.FakeConfig)
var err error
tempPluginDir, err = ioutil.TempDir("", "")
tempPluginDir, err = os.MkdirTemp("", "")
Expect(err).ToNot(HaveOccurred())
actor = NewActor(fakeConfig, nil)
})
Expand All @@ -41,7 +40,7 @@ var _ = Describe("install actions", func() {
var pluginPath string

BeforeEach(func() {
tempFile, err := ioutil.TempFile("", "")
tempFile, err := os.CreateTemp("", "")
Expect(err).ToNot(HaveOccurred())

_, err = tempFile.WriteString("cthulhu")
Expand Down Expand Up @@ -86,14 +85,14 @@ var _ = Describe("install actions", func() {
},
}

pluginFile, err := ioutil.TempFile("", "")
pluginFile, err := os.CreateTemp("", "")
Expect(err).NotTo(HaveOccurred())
err = pluginFile.Close()
Expect(err).NotTo(HaveOccurred())

pluginPath = pluginFile.Name()

tempDir, err = ioutil.TempDir("", "")
tempDir, err = os.MkdirTemp("", "")
Expect(err).ToNot(HaveOccurred())

pluginHomeDir = filepath.Join(tempDir, ".cf", "plugin")
Expand Down
5 changes: 2 additions & 3 deletions actor/pluginaction/install_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package pluginaction_test

import (
"io/ioutil"
"os"

. "code.cloudfoundry.org/cli/actor/pluginaction"
Expand All @@ -23,7 +22,7 @@ var _ = Describe("install actions", func() {
BeforeEach(func() {
fakeConfig = new(pluginactionfakes.FakeConfig)
var err error
tempPluginDir, err = ioutil.TempDir("", "")
tempPluginDir, err = os.MkdirTemp("", "")
Expect(err).ToNot(HaveOccurred())
actor = NewActor(fakeConfig, nil)
})
Expand All @@ -38,7 +37,7 @@ var _ = Describe("install actions", func() {
var pluginPath string

BeforeEach(func() {
tempFile, err := ioutil.TempFile("", "")
tempFile, err := os.CreateTemp("", "")
Expect(err).ToNot(HaveOccurred())

_, err = tempFile.WriteString("cthulhu")
Expand Down
Loading

0 comments on commit edb7507

Please sign in to comment.