Skip to content

Commit

Permalink
Merge pull request #5692 from stephenchengCloud/sync_with_master
Browse files Browse the repository at this point in the history
Sync feature/py3 branch with master
  • Loading branch information
liulinC authored Jun 17, 2024
2 parents 5ea1f3b + 597e50c commit e4b0be9
Show file tree
Hide file tree
Showing 192 changed files with 13,813 additions and 1,603 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/generate-and-build-sdks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
shell: bash
run: opam exec -- make sdk

- name: Run CI for SDKs
uses: ./.github/workflows/sdk-ci

- name: Store C SDK source
uses: actions/upload-artifact@v4
with:
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/go-ci/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'Run CI for Go SDK'
runs:
using: 'composite'
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22.2'

- name: Lint for Go SDK
uses: golangci/golangci-lint-action@v4
with:
version: v1.57.2
working-directory: ${{ github.workspace }}/_build/install/default/xapi/sdk/go/src
args: --config=${{ github.workspace }}/.golangci.yml

- name: Run CI for Go SDK
shell: bash
run: |
cd ./ocaml/sdk-gen/component-test/
cp -r ${{ github.workspace }}/_build/install/default/xapi/sdk/go/src jsonrpc-client/go/goSDK
bash run-tests.sh
20 changes: 20 additions & 0 deletions .github/workflows/sdk-ci/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Run CI for Go SDK'
runs:
using: 'composite'
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '^3.12'

- name: Install dependencies for JsonRPC Server
shell: bash
run: |
python -m pip install --upgrade pip
cd ./ocaml/sdk-gen/component-test/jsonrpc-server
pip install -r requirements.txt
- name: Run CI for Go SDK
uses: ./.github/workflows/go-ci

# Run other tests here
142 changes: 142 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
run:
# Timeout for analysis, e.g. 30s, 5m.
# Default: 1m
timeout: 3m

linters:
disable-all: true
enable:
- errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases
- gosimple # specializes in simplifying a code
- govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- ineffassign # detects when assignments to existing variables are not used
- staticcheck # is a go vet on steroids, applying a ton of static analysis checks
- typecheck # like the front-end of a Go compiler, parses and type-checks Go code
- unused # checks for unused constants, variables, functions and types
- asasalint # checks for pass []any as any in variadic func(...any)
- asciicheck # checks that your code does not contain non-ASCII identifiers
- bidichk # checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- copyloopvar # detects places where loop variables are copied
- durationcheck # checks for two durations multiplied together
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
- execinquery # checks query string in Query function which reads your Go src files and warning it finds
- exhaustive # checks exhaustiveness of enum switch statements
- exportloopref # checks for pointers to enclosing loop variables
- forbidigo # forbids identifiers
- gocheckcompilerdirectives # validates go compiler directive comments (//go:)
- gochecknoinits # checks that no init functions are present in Go code
- gochecksumtype # checks exhaustiveness on Go "sum types"
- gocritic # provides diagnostics that check for bugs, performance and style issues
- goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt
- gomnd # detects magic numbers
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
- gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations
- goprintffuncname # checks that printf-like functions are named with f at the end
- gosec # inspects source code for security problems
- intrange # finds places where for loops could make use of an integer range
- loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
- makezero # finds slice declarations with non-zero initial length
- mirror # reports wrong mirror patterns of bytes/strings usage
- musttag # enforces field tags in (un)marshaled structs
- nilerr # finds the code that returns nil even if it checks that the error is not nil
- nilnil # checks that there is no simultaneous return of nil error and an invalid value
- noctx # finds sending http request without context.Context
- nolintlint # reports ill-formed or insufficient nolint directives
- nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL
- perfsprint # checks that fmt.Sprintf can be replaced with a faster alternative
- predeclared # finds code that shadows one of Go's predeclared identifiers
- promlinter # checks Prometheus metrics naming via promlint
- protogetter # reports direct reads from proto message fields when getters should be used
- reassign # checks that package variables are not reassigned
- revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint
- rowserrcheck # checks whether Err of rows is checked successfully
- sloglint # ensure consistent code style when using log/slog
- spancheck # checks for mistakes with OpenTelemetry/Census spans
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
- tenv # detects using os.Setenv instead of t.Setenv since Go1.17
- unconvert # removes unnecessary type conversions
- unparam # reports unused function parameters
- usestdlibvars # detects the possibility to use variables/constants from the Go standard library
- wastedassign # finds wasted assignment statements
- whitespace # detects leading and trailing whitespace
- gosmopolitan # reports certain i18n/l10n anti-patterns in your Go codebase
- importas # enforces consistent import aliases
- testableexamples # checks if examples are testable (have an expected output)
- testifylint # checks usage of github.com/stretchr/testify
- testpackage # makes you use a separate _test package
- decorder # checks declaration order and count of types, constants, variables and functions
- thelper # detects golang test helpers without t.Helper() call and checks the consistency of test helpers
- godox # detects FIXME, TODO and other comment keywords
- gci # controls golang package import order and makes it always deterministic
- tagalign # checks that struct tags are well aligned
- wrapcheck # checks that errors returned from external packages are wrapped
- dogsled # checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())


## disabled
#- tagliatelle # checks the struct tags
#- goconst # finds repeated strings that could be replaced by a constant
#- gochecknoglobals # checks that no global variables exist
#- gocyclo # computes and checks the cyclomatic complexity of functions
#- nestif # reports deeply nested if statements
#- gofumpt # [replaced by goimports, gofumports is not available yet] checks whether code was gofumpt-ed
#- funlen # tool for detection of long functions
#- godot # checks if comments end in a period
#- stylecheck # is a replacement for golint
#- gocognit # computes and checks the cognitive complexity of functions
#- nakedret # finds naked returns in functions greater than a specified function length
#- lll # reports long lines
#- nonamedreturns # reports all named returns
#- cyclop # checks function and package cyclomatic complexity
#- dupl # tool for code clone detection
#- exhaustruct # [highly recommend to enable] checks if all structure fields are initialized
#- ginkgolinter # [if you use ginkgo/gomega] enforces standards of using ginkgo and gomega
#- goheader # checks is file header matches to pattern
#- inamedparam # [great idea, but too strict, need to ignore a lot of cases by default] reports interfaces with unnamed method parameters
#- interfacebloat # checks the number of methods inside an interface
#- ireturn # accept interfaces, return concrete types
#- prealloc # [premature optimization, but can be used in some cases] finds slice declarations that could potentially be preallocated
#- varnamelen # [great idea, but too many false positives] checks that the length of a variable's name matches its scope
#- zerologlint # detects the wrong usage of zerolog that a user forgets to dispatch zerolog.Event
#- containedctx # detects struct contained context.Context field
#- contextcheck # [too many false positives] checks the function whether use a non-inherited context
#- depguard # [replaced by gomodguard] checks if package imports are in a list of acceptable packages
#- dupword # [useless without config] checks for duplicate words in the source code
#- errchkjson # [don't see profit + I'm against of omitting errors like in the first example https://github.com/breml/errchkjson] checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted
#- forcetypeassert # [replaced by errcheck] finds forced type assertions
#- goerr113 # [too strict] checks the errors handling expressions
#- gofmt # [replaced by goimports] checks whether code was gofmt-ed
#- grouper # analyzes expression groups
#- maintidx # measures the maintainability index of each function
#- misspell # [useless] finds commonly misspelled English words in comments
#- nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity
#- paralleltest # [too many false positives] detects missing usage of t.Parallel() method in your Go test
#- wsl # [too strict and mostly code is not more readable] whitespace linter forces you to use empty lines

output:
# Sort results by the order defined in `sort-order`.
# Default: false
sort-results: true
# Order to use when sorting results.
# Require `sort-results` to `true`.
# Possible values: `file`, `linter`, and `severity`.
#
# If the severity values are inside the following list, they are ordered in this order:
# 1. error
# 2. warning
# 3. high
# 4. medium
# 5. low
# Either they are sorted alphabetically.
#
# Default: ["file"]
sort-order:
- linter
- severity
- file # filepath, line, and column.
# Show statistics per linter.
# Default: false
show-stats: true
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test:
ulimit -S -t $(TEST_TIMEOUT); \
(sleep $(TEST_TIMEOUT) && ps -ewwlyF --forest)& \
PSTREE_SLEEP_PID=$$!; \
trap "kill $${PSTREE_SLEEP_PID}" SIGINT SIGTERM EXIT; \
trap "kill $${PSTREE_SLEEP_PID}" INT TERM EXIT; \
timeout --foreground $(TEST_TIMEOUT2) \
dune runtest --profile=$(PROFILE) --error-reporting=twice -j $(JOBS)
dune build @runtest-python --profile=$(PROFILE)
Expand Down Expand Up @@ -95,22 +95,26 @@ sdk:
ocaml/sdk-gen/c/gen_c_binding.exe \
ocaml/sdk-gen/csharp/gen_csharp_binding.exe \
ocaml/sdk-gen/java/main.exe \
ocaml/sdk-gen/powershell/gen_powershell_binding.exe
ocaml/sdk-gen/powershell/gen_powershell_binding.exe \
ocaml/sdk-gen/go/gen_go_binding.exe
dune build --profile=$(PROFILE) -f\
@ocaml/sdk-gen/c/generate \
@ocaml/sdk-gen/csharp/generate \
@ocaml/sdk-gen/java/generate \
@ocaml/sdk-gen/powershell/generate
@ocaml/sdk-gen/powershell/generate \
@ocaml/sdk-gen/go/generate
rm -rf $(XAPISDK)
mkdir -p $(XAPISDK)/c
mkdir -p $(XAPISDK)/csharp
mkdir -p $(XAPISDK)/java
mkdir -p $(XAPISDK)/powershell
mkdir -p $(XAPISDK)/python
mkdir -p $(XAPISDK)/go
cp -r _build/default/ocaml/sdk-gen/c/autogen/* $(XAPISDK)/c
cp -r _build/default/ocaml/sdk-gen/csharp/autogen/* $(XAPISDK)/csharp
cp -r _build/default/ocaml/sdk-gen/java/autogen/* $(XAPISDK)/java
cp -r _build/default/ocaml/sdk-gen/powershell/autogen/* $(XAPISDK)/powershell
cp -r _build/default/ocaml/sdk-gen/go/autogen/* $(XAPISDK)/go
cp scripts/examples/python/XenAPI/XenAPI.py $(XAPISDK)/python
sh ocaml/sdk-gen/windows-line-endings.sh $(XAPISDK)/csharp
sh ocaml/sdk-gen/windows-line-endings.sh $(XAPISDK)/powershell
Expand Down
73 changes: 73 additions & 0 deletions doc/assets/css/misc.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
.revision-table {
width: 50%;
margin: 1em auto 1em auto;
font-size: 80%;
}

.label {
display: inline;
padding: .2em .6em .3em;
font-size: 75%;
font-weight: 700;
line-height: 1;
color: #fff;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: .25em;
}

.label.label-default {
background-color: #777;
}

.label.label-info {
background-color: #5bc0de;
}

.label.label-danger {
background-color: #d9534f;
}

.label.label-warning {
background-color: #f0ad4e;
}

.label.label-success {
background-color: #5cb85c;
}

.table-condensed > thead > tr > th,
.table-condensed > tbody > tr > th,
.table-condensed > tfoot > tr > th,
.table-condensed > thead > tr > td,
.table-condensed > tbody > tr > td,
.table-condensed > tfoot > tr > td {
padding: 5px;

}

.table-striped > tbody > tr:nth-child(odd) {
background-color: #f9f9f9;
}

.btn {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-weight: normal;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
cursor: pointer;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
}

.btn-link {
font-weight: normal;
color: #337ab7;
border-radius: 0;
}
Loading

0 comments on commit e4b0be9

Please sign in to comment.