Skip to content

Commit

Permalink
Migrate python emitter (#4182)
Browse files Browse the repository at this point in the history
Co-authored-by: iscai-msft <isabellavcai@gmail.com>
Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
  • Loading branch information
3 people authored Sep 18, 2024
1 parent 2b0cfe1 commit 8df0a9f
Show file tree
Hide file tree
Showing 304 changed files with 44,089 additions and 5 deletions.
1 change: 1 addition & 0 deletions .chronus/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ changelog: ["@chronus/github/changelog", { repo: "microsoft/typespec" }]
ignore:
- "@typespec/http-client-csharp"
- "@typespec/http-client-java"
- "@typespec/http-client-python"

changedFiles:
- "!**/*.md"
Expand Down
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
######################
/packages/http-client-java/ @srnagar @weidongxu-microsoft @haolingdong-msft @XiaofeiCao

######################
# Python
######################
/packages/http-client-python/ @iscai-msft @tadelesh @msyyc

######################
# Emiter Shared
######################
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,9 @@ BenchmarkDotnet.Artifacts/

# java emitter
!packages/http-client-java/package-lock.json

# python emitter
packages/http-client-python/test/**/generated/
packages/http-client-python/test/**/cadl-ranch-coverage.json
!packages/http-client-python/package-lock.json

66 changes: 66 additions & 0 deletions cspell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ dictionaries:
- typescript
words:
- Adoptium
- aiohttp
- alzimmer
- amqp
- AQID
- astimezone
- asyncio
- atrule
- atteo
- autorest
Expand All @@ -17,8 +20,10 @@ words:
- azurecr
- azuresdk
- bifilter
- blib
- blockful
- blockless
- buongiorno
- cadl
- cadleditor
- cadleng
Expand All @@ -32,31 +37,43 @@ words:
- createsorreplacesresource
- createsorupdatesresource
- CRUDL
- ctxt
- dbaeumer
- Dcodegen
- debouncer
- debugpy
- Declipse
- Dedupes
- destructures
- devdiv
- Diagnoser
- Dlog
- docutils
- dogfood
- Dorg
- Dosgi
- dotenv
- Dskip
- eastus
- ecmarkup
- elif
- EMBEDME
- Entra
- enumdiscriminator
- equalto
- esbenp
- esbuild
- espt
- ESRP
- etree
- fluentui
- genproto
- getpgid
- giacamo
- globby
- graalvm
- headasbooleanfalse
- headasbooleantrue
- Gson
- imple
- Infima
Expand All @@ -65,34 +82,55 @@ words:
- instanceid
- interner
- intrinsics
- IOHTTP
- isdigit
- isinstance
- issubclass
- itertype
- itor
- ivar
- Jacoco
- jdwp
- jobject
- jsyaml
- keyer
- killpg
- kwargs
- lifecyle
- LINUXNEXTVMIMAGE
- LINUXOS
- LINUXVMIMAGE
- ljust
- lmazuel
- lropaging
- lstrip
- lzutf
- MACVMIMAGE
- mday
- mgmt
- mgmtplane
- mocharc
- mqtt
- mros
- msbuild
- mspaint
- MSRC
- msrest
- multis
- munge
- mylib
- mypy
- nanos
- nexted
- nihao
- noformat
- noopener
- noreferrer
- nosec
- nostdlib
- noverify
- npmjs
- nspkg
- nupkg
- oapi
- ODATA
Expand All @@ -106,31 +144,51 @@ words:
- openapiv
- Perfolizer
- picocolors
- posargs
- prismjs
- proto
- protobuf
- protoc
- psscriptanalyzer
- ptvsd
- pwsh
- pyexpat
- pygen
- pylint
- pylintrc
- pyproject
- pyright
- pyrightconfig
- pytest
- rcfile
- reactivex
- recase
- regen
- repr
- respecify
- rjust
- rpaas
- rsplit
- rstrip
- rtype
- rushx
- safeint
- sdkcore
- segmentof
- serde
- sfixed
- sint
- snakeyaml
- srnagar
- ssdlrs
- sses
- ssvs
- statment
- strs
- syncpack
- TCGC
- timegm
- tomli
- triaging
- TRYIT
- tsdoc
Expand All @@ -140,6 +198,7 @@ words:
- tsvs
- typespec
- typespecvs
- tzname
- Uhoh
- uitestresults
- unassignable
Expand All @@ -155,19 +214,26 @@ words:
- unrepresentable
- unsourced
- unversioned
- venv
- venvtools
- VITE
- vitest
- vsix
- VSSDK
- Vsts
- vswhere
- wday
- weidxu
- westus
- WINDOWSVMIMAGE
- xiangyan
- xiaofei
- xlarge
- xmsclientrequestid
- xors
- xplat
- xxsubtype
- yamls
ignorePaths:
- "**/node_modules/**"
- "**/dist/**"
Expand Down
2 changes: 2 additions & 0 deletions eng/common/config/area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const isolatedEmitters = ["eng/emitters/"];
export const CIRules = {
CSharp: [...all, ...isolatedEmitters, ...AreaPaths["emitter:client:csharp"], ".editorconfig"],
Java: [...all, ...isolatedEmitters, ...AreaPaths["emitter:client:java"], ".editorconfig"],
Python: [...all, ...isolatedEmitters, ...AreaPaths["emitter:client:python"], ".editorconfig"],

Core: [
"**/*",
Expand All @@ -51,6 +52,7 @@ export const CIRules = {
...ignore(isolatedEmitters),
...ignore(AreaPaths["emitter:client:csharp"]),
...ignore(AreaPaths["emitter:client:java"]),
...ignore(AreaPaths["emitter:client:python"]),
],
};

Expand Down
6 changes: 6 additions & 0 deletions eng/common/pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ extends:
DependsOn: InitStage
Condition: eq('true', stageDependencies.InitStage.outputs['InitJob.InitStep.RunJava'])

# Run python stages if RunPython == true
- template: /packages/http-client-python/eng/pipeline/templates/ci-stages.yml
parameters:
DependsOn: InitStage
Condition: eq('true', stageDependencies.InitStage.outputs['InitJob.InitStep.RunPython'])

# Run core stages if RunCore == true
- template: /eng/tsp-core/pipelines/stages/ci-stages.yml
parameters:
Expand Down
20 changes: 16 additions & 4 deletions eng/common/scripts/utils/find-area-changed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ describe("paths that should trigger Java CI", () => {
});
});

describe("paths that should trigger python CI", () => {
it.each([
["packages/http-client-python/emitter/src/emitter.ts"],
["packages/http-client-python/package.json"],
])("%s", (...paths) => {
const areas = findAreasChanged(paths);
expect(areas).toEqual(["Python"]);
});
});

describe("paths that should trigger Core CI", () => {
it.each([
"packages/compiler/package.json",
Expand All @@ -45,22 +55,23 @@ describe("paths that should trigger all isolated packages", () => {
"eng/emitters/pipelines/templates/jobs/test-job.yml",
])("%s", (path) => {
const areas = findAreasChanged([path]);
expect(areas).toEqual(["CSharp", "Java"]);
expect(areas).toEqual(["CSharp", "Java", "Python"]);
});
});

it("Should return a combination of core and isolated packages", () => {
const areas = findAreasChanged([
"packages/http-client-csharp/src/constants.ts",
"packages/http-client-java/src/emitter.ts",
"packages/http-client-python/src/emitter.ts",
"packages/compiler/package.json",
]);
expect(areas).toEqual(["CSharp", "Java", "Core"]);
expect(areas).toEqual(["CSharp", "Java", "Python", "Core"]);
});

it("Should return CSharp, Core and Java if .editorconfig is changed", () => {
const areas = findAreasChanged([".editorconfig"]);
expect(areas).toEqual(["CSharp", "Java", "Core"]);
expect(areas).toEqual(["CSharp", "Java", "Python", "Core"]);
});

it("Should not return Core for .prettierignore, .prettierrc.json, cspell.yaml, esling.config.json", () => {
Expand All @@ -71,8 +82,9 @@ it("Should not return Core for .prettierignore, .prettierrc.json, cspell.yaml, e
"esling.config.json",
"packages/http-client-csharp/emitter/src/constants.ts",
"packages/http-client-java/emitter/src/emitter.ts",
"packages/http-client-python/emitter/src/emitter.ts",
]);
expect(areas).toEqual(["CSharp", "Java"]);
expect(areas).toEqual(["CSharp", "Java", "Python"]);
});

it("should return Core for random files at the root", () => {
Expand Down
7 changes: 6 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ const allFilesConfig = tsEslint.config({
export function getTypeScriptProjectRules(root) {
return tsEslint.config({
files: ["**/packages/*/src/**/*.ts", "**/packages/*/src/**/*.tsx"],
ignores: ["**/packages/http-client-csharp/**/*", "**/packages/http-client-java/**/*"], // Ignore isolated modules
ignores: [
"**/packages/http-client-csharp/**/*",
"**/packages/http-client-java/**/*",
"**/packages/http-client-python/**/*",
], // Ignore isolated modules
plugins: {},
languageOptions: {
parserOptions: {
Expand Down Expand Up @@ -139,6 +143,7 @@ export default tsEslint.config(
"**/website/build/**/*",
"**/.docusaurus/**/*",
"packages/compiler/templates/**/*", // Ignore the templates which might have invalid code and not follow exactly our rules.
"**/venv/**/*", // Ignore python virtual env
// TODO: enable
"**/.scripts/**/*",
"eng/tsp-core/scripts/**/*",
Expand Down
Loading

0 comments on commit 8df0a9f

Please sign in to comment.