Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(codegen): fix the yarn codegen job in ci.yaml #13

Closed
wants to merge 5 commits into from

Conversation

petermetz
Copy link
Owner

WORK IN PROGRESS

Fixes hyperledger-cacti#2618

Signed-off-by: Peter Somogyvari peter.somogyvari@accenture.com

Fixes hyperledger-cacti#2627

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
The "express-openapi-validator" package was crashing while trying to
parse our Fabric connector's Open API spec because of the typo that
in the specs the "description" field for some schema elements were named
"properties" which is a reserved field in the schema of the specs.

Fixing the typo in the spec document made the problem go away.

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
Primary changes:
---------------

1. Added robust debug logging to the express middleware of the API server
so that problems like this are easier to debug in the future (e.g.
trouble with the Open API spec documents themselves)
2. Refactored the ci.yaml document so that there are separate jobs for
each tape based Fabric connector integration test. This has reduced
(or potentially eliminated) the presence of the flake that we were
encountering during the contract deployment test cases. It also has the
upside of faster CI because of more parallelism in the CI jobs.
3. Updated the assertions in a couple of test cases where the newer Fabric
versions were causing the assertions to fail because the returned JSON
response in the example asset transfer chaincode is now referring to the
asset owner via a property named "Owner" not "owner" (casing difference)

Fixes hyperledger-cacti#1471

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
@petermetz petermetz force-pushed the petermetz/issue2618 branch 10 times, most recently from 6b52935 to 90530ee Compare August 23, 2023 19:57
1. If we run the codegen script and it generates a diff (e.g. changes files
that are under version control) that means that we have to send it back
to the person who is making the pull request and ask them to include
those changes in their commit so that we are adhering to the idea of
reproducible builds as much as possible.
2. These (env var) parameters of ./tools/ci.sh are now true by default:
  - `TOOLS_VALIDATE_BUNDLE_NAMES_DISABLED`
  - `CUSTOM_CHECKS_DISABLED`
  - `FULL_BUILD_DISABLED`
3. Refactored the custom-check that verifies the Open API specs' license parameters
(`tools/custom-checks/check-open-api-json-specs.ts`)
so that it does not fail for missing "identifier" properties UNLESS the spec's
version is 3.1.0 or higher. This was necessary because we cannot yet migrate the
specs to v3.1.0 due to the generator not supporting it properly (it ends up
mangling all of the types in the generated code from their actual type to `any`)
4. Additional logging was also added to the script mentioned in 3) to make it
easier in the future to debug what is the problem.
5. Added these environment variables to control the behavior of the
`tools/custom-checks/check-open-api-json-specs.ts` script:
  - `CACTI_CUSTOM_CHECKS_REQUIRED_OPENAPI_SPEC_VERSION`
  - `CACTI_CUSTOM_CHECKS_REQUIRED_OPENAPI_LICENSE_SPDX`
  - `CACTI_CUSTOM_CHECKS_REQUIRED_OPENAPI_LICENSE_URL`

Related to hyperledger-cacti#2618

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
BREAKING CHANGES:
1. Fabric connector endpoints are using base64 encoding instead of JSON
when needing to transfer otherwise binary data (UInt8Array)
2. Same as the above for the Iroha 1 and Iroha 2 connectors.

Primary changes:
-----------------
1. Removed the `"identifier": "Apache-2.0",` section from all OpenAPI
specification documents (./**/openapi.json) project-wide because the
OpenAPI generator is not yet compatible with it and because of that the
new property just makes it crash with a false-negative validation error.
2. Downgraded all OpenAPI specification documents version from `v3.1.0` to
`v3.0.3` (which is how it used to be) because the generator is not yet
compatible with it and it had caused types to be mangled.
3. Eliminated incorrect usage of the "format": "binary" declarations in
the OpenAPI specifications where the format was declared as binary but
the data was still traveling as JSON strings despite it (divergence
between our spec .json files and the implementation under the hood)
4. Updated the tests and their related endpoints to use base64 encoding
instead of JSON serializing UInt8Array instances: It is more efficient
this way and also has the benefit of honoring the specification. The
reason why it's more efficient is because JSON serializing a typed UInt8Array
results in an object literal that maps every single byte to a property
of said object, roughly tripling the size of the network transfer. It
probably also is slower to serialize/deserialize but I haven't actually
measured this.
5. All of the packages are now using the OpenAPI generator v6.6.0 instead
of some being stuck on v5.2.1. This might cause build issues in kotlin
API clients but because we don't have a freeze on breaking changes right
now (leading up to v2.0.0) it is the right time to make drastic changes
like this.

Fixes hyperledger-cacti#2618

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ci(codegen): fix the yarn codegen job in ci.yaml
1 participant