Skip to content

Commit

Permalink
Splitit C# generator changes + Add C# to CI + Add Splitit C# test to …
Browse files Browse the repository at this point in the history
…CI (#338)

* template fix for C# tests

* intellij run config

* fix "git not found" error in CI when writing readme

* add c# install to earthly CI

* add C# integration test

* generated c# sdk for integration test

* add dotnet 5.0 and 3.1 to image for testing

* change test to snapshot of current splitit C# sdk
  • Loading branch information
eddiechayes authored Nov 6, 2023
1 parent c83d71f commit e89e7c8
Show file tree
Hide file tree
Showing 242 changed files with 31,914 additions and 35 deletions.
34 changes: 22 additions & 12 deletions generator/konfig-dash/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,33 @@ VERSION 0.7
FROM node:16-slim
WORKDIR /konfig-dash

build-konfig-dash:
RUN apt-get update

### PYTHON
konfig-test-dependencies:
# TODO: Once we figure out how to better package/extract konfig-cli from konfig-dash, move this to
# generator/konfig-integration-tests/Earthfile as the base image for +integration-tests
ENV PYTHONDONTWRITEBYTECODE=1 # Don't write .pyc files, which are not needed in a container
ENV PIP_DEFAULT_TIMEOUT=100

# lsof required for killing mock server after test
RUN apt-get install -y lsof python3 python3-pip
ENV PIP_DEFAULT_TIMEOUT=100 # Increase pip timeout to avoid timeouts when installing python packages
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true # Avoids error when running dotnet
# lsof: used by konfig test
# openssl: used by prisma
# wget: used to get C# install script
RUN apt-get update
RUN apt-get install -y lsof python3 python3-pip openssl wget
## node comes from base image
## csharp
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
RUN chmod +x ./dotnet-install.sh
RUN ./dotnet-install.sh --channel 7.0
RUN ./dotnet-install.sh --channel 5.0
RUN ./dotnet-install.sh --channel 3.1
ENV PATH=$PATH:/root/.dotnet
## python
RUN pip3 install --upgrade pip
RUN pip3 install poetry
# Clean up python installations
# Clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# not present in node:16-slim but required by prisma
RUN apt-get install -y openssl

build-konfig-dash:
FROM +konfig-test-dependencies
# Copy everything we need to run `yarn` without copying the source code so that dependencies are cached
COPY package.json yarn.lock .yarnrc.yml redwood.toml .
COPY .yarn .yarn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import * as shell from 'shelljs'

export function getGitRepositoryName(): string {
// get remote url e.g. "https://github.com/konfig-dev/my-sdks.git"
const remoteUrl = shell
.exec('git config --get remote.origin.url')
.stdout.trim()
let remoteUrl = ''
try {
remoteUrl = shell.exec('git config --get remote.origin.url').stdout.trim()
} catch (e) {
console.error(
'Warning! Encountered error when trying to use git. If running in CI, this can be safely ignored.'
)
}

const remoteUrlWithoutTrailingSlash = remoteUrl.replace(/\/$/, '')

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ var {{nameInCamelCaseLowerFirst}} = "{{{nameInCamelCaseLowerFirst}}}_example";{{
var {{nameInCamelCaseLowerFirst}} = {{{../dataType}}}.{{{enumName}}}.{{> api_doc_example_enum_param}};{{#description}} // {{{.}}}{{/description}}
{{/isEnum}}
{{/isString}}
{{#isBoolean}}
var {{nameInCamelCaseLowerFirst}} = false;{{#description}} // {{{.}}}{{/description}}
{{/isBoolean}}
{{#isAnyType}}
var {{nameInCamelCaseLowerFirst}} = "{{{nameInCamelCaseLowerFirst}}}_example";{{#description}} // {{{.}}}{{/description}}
{{/isAnyType}}
{{/example}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{#isArray}}
var {{nameInCamelCaseLowerFirst}} = new {{{dataType}}}();{{#description}} // {{{.}}}{{/description}}
{{/isArray}}
{{/isPrimitiveType}}
{{/isEnumRef}}
{{/vars}}
3 changes: 2 additions & 1 deletion generator/konfig-integration-tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,5 @@ dist

# don't check in things that often change and have no functional value
generate-id.txt
STATISTICS.md
STATISTICS.md
*.Net.sln
6 changes: 1 addition & 5 deletions generator/konfig-integration-tests/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ VERSION 0.7
FROM ../konfig-dash+build-konfig-dash
WORKDIR /konfig-integration-tests

konfig-test-dependencies:
### NODE comes from base image

integration-tests:
FROM +konfig-test-dependencies
COPY package.json yarn.lock .
COPY package.json yarn.lock logo.png .
RUN yarn
COPY tsconfig.json vitest.config.ts util.ts .
COPY sdks sdks
Expand Down
27 changes: 16 additions & 11 deletions generator/konfig-integration-tests/bootstrap-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,33 @@ generators:
${language}:
version: 1.0.0
outputDirectory: ${language}
clientName: ${toCamelCase(testName)}
clientName: ${toCamelCase(testName)}Client
${languageSpecificFields}
git:
userId: konfig-dev
repoId: konfig/tree/main/${language}`;
}

function generateKonfigYamlFieldsForLanguage(language, testName) {
if (language == "python") {
return `packageName: ${testName.replace(/-/g, "_")}
projectName: ${testName}`;
} else if (language == "typescript") {
return `npmName: ${testName}`;
if (language == 'python') {
return `packageName: ${testName.replace(/-/g, '_')}
projectName: ${testName}`
} else if (language == 'typescript') {
return `npmName: ${testName}`
} else if (language == 'csharp') {
return `packageName: ${toCamelCase(testName)}.Net
logoPath: ../../logo.png`
}
}

const supportedLanguages = ['python', 'typescript', 'csharp'];
// Prompt for language
rl.question(
"Which language would you like to create a test for? (python/typescript) ",
(languageInput) => {
const language =
languageInput.toLowerCase() === "python" ? "python" : "typescript";
rl.question(`Which language would you like to create a test for? (${supportedLanguages.join("/")}) `, (languageInput) => {
const language = languageInput.toLowerCase();
if (!supportedLanguages.includes(language)) {
console.error(`Language ${language} is not supported.`);
process.exit(1);
}

// Prompt for test name
rl.question("What would you like to name your test? ", (testName) => {
Expand Down
Binary file added generator/konfig-integration-tests/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
description: Splitit's Web API
examples: {}
examples_2: {}
fixOnlyOneTagName: false
operationIds: {}
operationTags: {}
renameTags: {}
requestSchemaNames: {}
responseDescriptions: {}
responseSchemaNames: {}
securityParameters:
Authorization:
header:
flows:
clientCredentials:
scopes:
api.v3: ''
tokenUrl: https://id.production.splitit.com/connect/token
securityName: oauth
type: oauth2
X-Splitit-IdempotencyKey:
header: false
X-Splitit-TestMode:
header: false
X-Splitit-TouchPoint:
header: false
extendedParams:
query: false
installmentPlanNumber:
query: false
refOrderNumber:
query: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (c) 2023- Konfig, Inc. (https://konfigthis.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# konfig

|Language|Version|Package Manager|Documentation|Source|
|-|-|-|-|-|
|C#|1.0.0|[NuGet](https://nuget.org/packages/CsharpSplitit.Net/1.0.0)|[Documentation](https://github.com/konfig-dev/konfig/tree/main/csharp/README.md)|[Source](https://github.com/konfig-dev/konfig/tree/main/csharp)|
Loading

0 comments on commit e89e7c8

Please sign in to comment.