Skip to content

Commit ee00555

Browse files
[tsp-client] Add gh action for tests (#8847)
* add gh action * review feedback * fix tests for latest update * add working dir * fix dir paths * sparse checkout * clean up code coverage * testing gh action - will revert * undo test commit --------- Co-authored-by: Catalina Peralta <caperal@microsoft.com>
1 parent 9d583e6 commit ee00555

2 files changed

Lines changed: 84 additions & 9 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: tsp-client - Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
paths:
9+
- .github/workflows/tsp-client-tests.yml
10+
- tools/tsp-client/**
11+
12+
jobs:
13+
tsp-client:
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, windows-latest]
17+
node-version: [18, 20]
18+
exclude:
19+
- os: ubuntu-latest
20+
node-version: 20
21+
- os: windows-latest
22+
node-version: 18
23+
24+
runs-on: ${{ matrix.os }}
25+
26+
steps:
27+
- if: runner.os == 'Windows'
28+
run: git config --global core.longpaths true
29+
shell: pwsh
30+
31+
- uses: actions/checkout@v4
32+
with:
33+
sparse-checkout: |
34+
.github/workflows
35+
tools/tsp-client
36+
37+
- name: Use Node ${{ matrix.node-version }}.x
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: ${{ matrix.node-version }}.x
41+
42+
- run: npm ci
43+
shell: pwsh
44+
working-directory: tools/tsp-client
45+
46+
- run: npm ls -a
47+
shell: pwsh
48+
continue-on-error: true
49+
working-directory: tools/tsp-client
50+
51+
- run: npm run build
52+
shell: pwsh
53+
working-directory: tools/tsp-client
54+
55+
- run: npm run test
56+
shell: pwsh
57+
working-directory: tools/tsp-client

tools/tsp-client/test/commands.spec.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ describe("Verify commands", async function () {
4545
await it("Sync example sdk", async function () {
4646
try {
4747
const args = {
48-
"output-dir": "./test/examples/sdk/contosowidgetmanager/contosowidgetmanager-rest",
48+
"output-dir": joinPaths(
49+
cwd(),
50+
"./test/examples/sdk/contosowidgetmanager/contosowidgetmanager-rest",
51+
),
4952
};
5053
await syncCommand(args);
5154
} catch (error) {
@@ -60,7 +63,7 @@ describe("Verify commands", async function () {
6063
await it("Sync example sdk with local spec", async function () {
6164
try {
6265
const args = {
63-
"output-dir": "./test/examples/sdk/local-spec-sdk",
66+
"output-dir": joinPaths(cwd(), "./test/examples/sdk/local-spec-sdk"),
6467
"local-spec-repo":
6568
"./test/examples/specification/contosowidgetmanager/Contoso.WidgetManager",
6669
};
@@ -75,7 +78,10 @@ describe("Verify commands", async function () {
7578
await it("Generate example sdk", async function () {
7679
try {
7780
const args = {
78-
"output-dir": "./test/examples/sdk/contosowidgetmanager/contosowidgetmanager-rest",
81+
"output-dir": joinPaths(
82+
cwd(),
83+
"./test/examples/sdk/contosowidgetmanager/contosowidgetmanager-rest",
84+
),
7985
"save-inputs": true,
8086
};
8187
await generateCommand(args);
@@ -91,7 +97,10 @@ describe("Verify commands", async function () {
9197
await it("Update example sdk", async function () {
9298
try {
9399
const args = {
94-
"output-dir": "./test/examples/sdk/contosowidgetmanager/contosowidgetmanager-rest",
100+
"output-dir": joinPaths(
101+
cwd(),
102+
"./test/examples/sdk/contosowidgetmanager/contosowidgetmanager-rest",
103+
),
95104
"save-inputs": true,
96105
};
97106
await updateCommand(args);
@@ -103,7 +112,10 @@ describe("Verify commands", async function () {
103112
await it("Update example sdk & pass tspconfig.yaml", async function () {
104113
try {
105114
const args = {
106-
"output-dir": "./test/examples/sdk/contosowidgetmanager/contosowidgetmanager-rest",
115+
"output-dir": joinPaths(
116+
cwd(),
117+
"./test/examples/sdk/contosowidgetmanager/contosowidgetmanager-rest",
118+
),
107119
"tsp-config":
108120
"https://github.com/Azure/azure-rest-api-specs/blob/db63bea839f5648462c94e685d5cc96f8e8b38ba/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml",
109121
"save-inputs": true,
@@ -117,7 +129,10 @@ describe("Verify commands", async function () {
117129
await it("Update example sdk & pass commit", async function () {
118130
try {
119131
const args = {
120-
"output-dir": "./test/examples/sdk/contosowidgetmanager/contosowidgetmanager-rest",
132+
"output-dir": joinPaths(
133+
cwd(),
134+
"./test/examples/sdk/contosowidgetmanager/contosowidgetmanager-rest",
135+
),
121136
commit: "db63bea839f5648462c94e685d5cc96f8e8b38ba",
122137
"save-inputs": true,
123138
};
@@ -130,7 +145,10 @@ describe("Verify commands", async function () {
130145
await it("Update example sdk & pass only --repo", async function () {
131146
try {
132147
const args = {
133-
"output-dir": "./test/examples/sdk/contosowidgetmanager/contosowidgetmanager-rest",
148+
"output-dir": joinPaths(
149+
cwd(),
150+
"./test/examples/sdk/contosowidgetmanager/contosowidgetmanager-rest",
151+
),
134152
repo: "foo",
135153
"save-inputs": true,
136154
};
@@ -147,7 +165,7 @@ describe("Verify commands", async function () {
147165
await it.skip("Init example sdk", async function () {
148166
try {
149167
const args = {
150-
"output-dir": "./test/examples/",
168+
"output-dir": joinPaths(cwd(), "./test/examples/"),
151169
"tsp-config":
152170
"https://github.com/Azure/azure-rest-api-specs/blob/7ed015e3dd1b8b1b0e71c9b5e6b6c5ccb8968b3a/specification/cognitiveservices/ContentSafety/tspconfig.yaml",
153171
};
@@ -169,7 +187,7 @@ describe("Verify commands", async function () {
169187
await it.skip("Init with --skip-sync-and-generate", async function () {
170188
try {
171189
const args = {
172-
"output-dir": "./test/examples/",
190+
"output-dir": joinPaths(cwd(), "./test/examples/"),
173191
"tsp-config":
174192
"https://github.com/Azure/azure-rest-api-specs/blob/7ed015e3dd1b8b1b0e71c9b5e6b6c5ccb8968b3a/specification/cognitiveservices/ContentSafety/tspconfig.yaml",
175193
"skip-sync-and-generate": true,

0 commit comments

Comments
 (0)