Skip to content

Commit 8ecec05

Browse files
authored
chore(scripts): reuse the swift build folder (#5484)
1 parent a2ac24f commit 8ecec05

File tree

7 files changed

+26
-34
lines changed

7 files changed

+26
-34
lines changed

.github/actions/setup/action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ runs:
187187
with:
188188
path: |
189189
clients/algoliasearch-client-swift/.build
190-
tests/output/swift/.build
191190
key: swift-build-${{ inputs.version }}-${{ runner.os }}
192191

193192
- name: Set swiftformat version

clients/algoliasearch-client-swift/Sources/Core/Helpers/APIHelper.swift

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,6 @@ public enum APIHelper {
3636
}
3737
}
3838

39-
public static func convertBoolToString(_ source: [String: Any]?) -> [String: Any]? {
40-
guard let source else {
41-
return nil
42-
}
43-
44-
return source.reduce(into: [String: Any]()) { result, item in
45-
switch item.value {
46-
case let x as Bool:
47-
result[item.key] = x.description
48-
default:
49-
result[item.key] = item.value
50-
}
51-
}
52-
}
53-
5439
public static func convertAnyToString(_ value: Any?) -> String? {
5540
guard let value else { return nil }
5641
if let value = value as? any RawRepresentable {

playground/swift/Package.resolved

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/buildLanguages.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { existsSync } from 'node:fs';
22

33
import { createClientName, run, toAbsolutePath } from './common.ts';
4-
import { getLanguageFolder } from './config.ts';
4+
import { getLanguageFolder, getSwiftBuildFolder } from './config.ts';
55
import { formatter } from './formatter.ts';
66
import { createSpinner } from './spinners.ts';
77
import type { Generator, Language } from './types.ts';
@@ -91,10 +91,7 @@ async function buildLanguage(language: Language, gens: Generator[], buildType: B
9191
await run('sbt --batch -Dsbt.server.forcestart=true +compile', { cwd, language });
9292
break;
9393
case 'swift':
94-
// make this work in the playground
95-
if (buildType !== 'playground') {
96-
await run('swift build -Xswiftc -suppress-warnings', { cwd, language });
97-
}
94+
await run(`swift build -Xswiftc -suppress-warnings --build-path ${getSwiftBuildFolder()}`, { cwd, language });
9895
break;
9996
default:
10097
}

scripts/config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import clientsConfig from '../config/clients.config.json' with { type: 'json' };
22

3-
import { CI, createClientName } from './common.ts';
3+
import { CI, createClientName, toAbsolutePath } from './common.ts';
44
import type { Generator, Language, LanguageConfig } from './types.ts';
55

66
export function getClientsConfigField(
@@ -57,6 +57,10 @@ export function getDockerImage(language?: Language): string | undefined {
5757
return getClientsConfigField(language, 'dockerImage', false);
5858
}
5959

60+
export function getSwiftBuildFolder(): string {
61+
return toAbsolutePath(getLanguageFolder('swift') + '/.build');
62+
}
63+
6064
/**
6165
* Returns the version of the package from clients.config.json, except for JavaScript where it returns the version of javascript-search.
6266
*/

scripts/cts/runCts.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fsp from 'fs/promises';
22

33
import { exists, isVerbose, run, runComposerInstall, toAbsolutePath } from '../common.ts';
4-
import { getTestOutputFolder } from '../config.ts';
4+
import { getSwiftBuildFolder, getTestOutputFolder } from '../config.ts';
55
import { createSpinner } from '../spinners.ts';
66
import type { Language } from '../types.ts';
77

@@ -115,10 +115,13 @@ async function runCtsOne(language: Language, suites: Record<CTSType, boolean>):
115115
});
116116
break;
117117
case 'swift':
118-
await run(`swift test -Xswiftc -suppress-warnings --parallel ${filter((f) => `--filter "${f}.*"`)}`, {
119-
cwd,
120-
language,
121-
});
118+
await run(
119+
`swift test -Xswiftc -suppress-warnings --build-path ${getSwiftBuildFolder()} --parallel ${filter((f) => `--filter "${f}.*"`)}`,
120+
{
121+
cwd,
122+
language,
123+
},
124+
);
122125
break;
123126
default:
124127
spinner.warn(`skipping unknown language '${language}' to run the CTS`);

scripts/playground.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { AllLanguage } from './cli/utils.ts';
22
import { createClientName, run, runComposerInstall } from './common.ts';
3+
import { getSwiftBuildFolder } from './config.ts';
34

45
export async function playground({ language, client }: { language: AllLanguage; client: string }): Promise<void> {
56
switch (language) {
@@ -56,7 +57,10 @@ export async function playground({ language, client }: { language: AllLanguage;
5657
await run(`sbt \\"runMain ${createClientName(client, 'scala')}\\"`, { cwd: 'playground/scala', language });
5758
break;
5859
case 'swift':
59-
await run(`swift run ${client}-playground`, { cwd: 'playground/swift', language });
60+
await run(`swift run --build-path ${getSwiftBuildFolder()} ${client}-playground`, {
61+
cwd: 'playground/swift',
62+
language,
63+
});
6064
break;
6165
default:
6266
}

0 commit comments

Comments
 (0)