Skip to content

Commit 147035c

Browse files
authored
feat(swift): initial generation (#2370)
1 parent 4b30c39 commit 147035c

File tree

73 files changed

+4720
-25
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+4720
-25
lines changed

.github/actions/setup/action.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ runs:
7676
echo "PYTHON_VERSION=$(cat config/.python-version)" >> $GITHUB_OUTPUT
7777
echo "RUBY_VERSION=$(cat config/.ruby-version)" >> $GITHUB_OUTPUT
7878
echo "CSHARP_VERSION=$(cat config/.csharp-version)" >> $GITHUB_OUTPUT
79+
echo "SWIFT_VERSION=$(cat config/.swift-version)" >> $GITHUB_OUTPUT
7980
8081
# JavaScript client deps
8182
- name: Get yarn js-client cache directory path
@@ -178,3 +179,29 @@ runs:
178179
uses: actions/setup-dotnet@v4
179180
with:
180181
dotnet-version: ${{ steps.versions.outputs.CSHARP_VERSION }}
182+
183+
# Swift deps
184+
- name: Install swift
185+
if: ${{ inputs.language == 'swift' }}
186+
uses: swift-actions/setup-swift@v1
187+
with:
188+
swift-version: ${{ steps.versions.outputs.SWIFT_VERSION }}
189+
190+
- name: Set up Homebrew
191+
if: ${{ inputs.language == 'swift' }}
192+
id: set-up-homebrew
193+
uses: Homebrew/actions/setup-homebrew@master
194+
195+
- name: Cache Homebrew Bundler RubyGems
196+
if: ${{ inputs.language == 'swift' }}
197+
id: cache
198+
uses: actions/cache@v3
199+
with:
200+
path: ${{ steps.set-up-homebrew.outputs.gems-path }}
201+
key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
202+
restore-keys: ${{ runner.os }}-rubygems-
203+
204+
- name: Install swift-format
205+
if: ${{ inputs.language == 'swift' && steps.cache.outputs.cache-hit != 'true' }}
206+
shell: bash
207+
run: brew install swift-format

.github/workflows/check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ jobs:
299299
path: clients-javascript.zip
300300

301301
client_gen:
302-
timeout-minutes: 15
303-
runs-on: ubuntu-22.04
302+
timeout-minutes: 20
303+
runs-on: ${{ matrix.client.language == 'swift' && 'macos-12' || 'ubuntu-22.04' }}
304304
needs:
305305
- setup
306306
- specs

.github/workflows/pr-title.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ jobs:
1616
- name: Pull Request title rules
1717
uses: Slashgear/[email protected]
1818
with:
19-
regexp: '^(docs|chore)|((?:feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)\((?:clients|generators|playground|javascript|php|java|go|kotlin|dart|python|ruby|scala|csharp|cts|specs|scripts|ci|templates|deps)\)): .+'
19+
regexp: '^(docs|chore)|((?:feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)\((?:clients|generators|playground|javascript|php|java|go|kotlin|dart|python|ruby|scala|csharp|swift|cts|specs|scripts|ci|templates|deps)\)): .+'

Dockerfile

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ ARG NODE_VERSION
44
ARG PHP_VERSION
55
ARG PYTHON_VERSION
66
ARG CSHARP_VERSION
7+
ARG SWIFT_VERSION
78

89
FROM dart:${DART_VERSION} AS dart-builder
910
FROM mcr.microsoft.com/dotnet/sdk:${CSHARP_VERSION} AS csharp-builder
1011
FROM golang:${GO_VERSION}-bullseye AS go-builder
11-
FROM python:${PYTHON_VERSION}-bullseye AS python-builder
12-
FROM php:${PHP_VERSION}-bullseye AS builder
12+
FROM swift:${SWIFT_VERSION}-jammy AS builder
1313

1414
ENV DOCKER=true
1515

@@ -18,25 +18,29 @@ SHELL ["/bin/bash", "--login", "-c"]
1818

1919
# Global (and librairies for ruby)
2020
RUN apt-get update && apt-get install -y --no-install-recommends \
21-
curl zip unzip git openssh-server \
22-
build-essential bison zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev \
23-
&& apt-get clean \
24-
&& rm -rf /var/lib/apt/lists/*
21+
curl zip unzip git openssh-server ca-certificates \
22+
build-essential bison zlib1g-dev libyaml-dev libssl-dev openssl libgdbm-dev libreadline-dev libncurses5-dev libffi-dev
2523

2624
# JavaScript
27-
COPY .nvmrc .nvmrc
28-
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash && source ~/.profile \
29-
&& nvm install \
30-
&& npm install -g yarn
25+
RUN mkdir -p /etc/apt/keyrings \
26+
&& curl -sL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee /etc/apt/keyrings/nodesource.gpg >/dev/null \
27+
&& NODE_MAJOR=$(echo $NODE_VERSION | sed -E -n 's/v?([0-9]+)\..*/\1/p') \
28+
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x jammy main" | tee /etc/apt/sources.list.d/nodesource.list \
29+
&& apt-get update && apt-get install -y --no-install-recommends nodejs
30+
RUN npm install -g yarn
3131

3232
# Python
33-
COPY --from=python-builder /usr/local/bin/ /usr/local/bin/
34-
COPY --from=python-builder /usr/local/lib/ /usr/local/lib/
35-
RUN echo "export PATH=$PATH:/usr/local/bin/python" >> ~/.profile \
36-
&& echo "export PATH=$PATH:/usr/local/bin/pip" >> ~/.profile \
33+
RUN curl -L "https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz" -o python.tgz \
34+
&& tar -xvf python.tgz && cd Python-$PYTHON_VERSION \
35+
&& ./configure --enable-optimizations \
36+
&& make install \
37+
&& cd .. && rm -rf Python-$PYTHON_VERSION python.tgz \
38+
&& ln -s /usr/local/bin/pip3 /usr/bin/pip \
39+
&& ln -s /usr/local/bin/python3 /usr/bin/python \
3740
&& pip install --upgrade pip pipx && pipx ensurepath \
3841
&& pipx install poetry
3942

43+
4044
# Go
4145
COPY --from=go-builder /usr/local/go/ /usr/local/go/
4246
RUN echo "export PATH=$PATH:/usr/local/go/bin:/root/go/bin" >> ~/.profile
@@ -50,6 +54,10 @@ RUN echo "export PATH=/usr/lib/dart/bin:/root/.pub-cache/bin:$PATH" >> ~/.profil
5054

5155
# PHP
5256
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
57+
RUN apt-get update && apt-get install -y --no-install-recommends \
58+
php${PHP_VERSION}-cli php${PHP_VERSION}-curl php${PHP_VERSION}-mbstring php${PHP_VERSION}-xml php${PHP_VERSION}-zip \
59+
&& apt-get clean \
60+
&& rm -rf /var/lib/apt/lists/*
5361

5462
# SDKMAN
5563
RUN curl -s "https://get.sdkman.io" | bash
@@ -73,6 +81,20 @@ RUN curl -L -o ruby.tar.gz https://github.com/postmodern/ruby-install/releases/d
7381
COPY --from=csharp-builder /usr/share/dotnet /usr/share/dotnet
7482
RUN echo "export PATH=$PATH:/usr/share/dotnet" >> ~/.profile && source ~/.profile
7583

84+
# Swift
85+
RUN git clone https://github.com/apple/swift-format.git \
86+
&& cd swift-format \
87+
&& git checkout "release/$SWIFT_VERSION" \
88+
&& swift build -c release \
89+
&& swift test --parallel \
90+
&& mv .build/release/swift-format /usr/bin \
91+
&& cd .. \
92+
&& rm -rf swift-format
93+
94+
# Clean up
95+
RUN apt-get clean \
96+
&& rm -rf /var/lib/apt/lists/*
97+
7698
WORKDIR /app
7799

78100
CMD bash
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/xcode,swift
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=xcode,swift
3+
4+
### Swift ###
5+
# Xcode
6+
#
7+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
8+
9+
## User settings
10+
xcuserdata/
11+
12+
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
13+
*.xcscmblueprint
14+
*.xccheckout
15+
16+
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
17+
build/
18+
DerivedData/
19+
*.moved-aside
20+
*.pbxuser
21+
!default.pbxuser
22+
*.mode1v3
23+
!default.mode1v3
24+
*.mode2v3
25+
!default.mode2v3
26+
*.perspectivev3
27+
!default.perspectivev3
28+
29+
## Obj-C/Swift specific
30+
*.hmap
31+
32+
## App packaging
33+
*.ipa
34+
*.dSYM.zip
35+
*.dSYM
36+
37+
## Playgrounds
38+
timeline.xctimeline
39+
playground.xcworkspace
40+
41+
# Swift Package Manager
42+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
43+
# Packages/
44+
# Package.pins
45+
Package.resolved
46+
# *.xcodeproj
47+
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
48+
# hence it is not needed unless you have added a package configuration file to your project
49+
.swiftpm
50+
51+
.build/
52+
53+
# CocoaPods
54+
# We recommend against adding the Pods directory to your .gitignore. However
55+
# you should judge for yourself, the pros and cons are mentioned at:
56+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
57+
# Pods/
58+
# Add this line if you want to avoid checking in source code from the Xcode workspace
59+
# *.xcworkspace
60+
61+
# Carthage
62+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
63+
# Carthage/Checkouts
64+
65+
Carthage/Build/
66+
67+
# Accio dependency management
68+
Dependencies/
69+
.accio/
70+
71+
# fastlane
72+
# It is recommended to not store the screenshots in the git repo.
73+
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
74+
# For more information about the recommended setup visit:
75+
# https://docs.fastlane.tools/best-practices/source-control/#source-control
76+
77+
fastlane/report.xml
78+
fastlane/Preview.html
79+
fastlane/screenshots/**/*.png
80+
fastlane/test_output
81+
82+
# Code Injection
83+
# After new code Injection tools there's a generated folder /iOSInjectionProject
84+
# https://github.com/johnno1962/injectionforxcode
85+
86+
iOSInjectionProject/
87+
88+
### Xcode ###
89+
90+
## Xcode 8 and earlier
91+
92+
### Xcode Patch ###
93+
*.xcodeproj/*
94+
!*.xcodeproj/project.pbxproj
95+
!*.xcodeproj/xcshareddata/
96+
!*.xcworkspace/contents.xcworkspacedata
97+
/*.gcno
98+
**/xcshareddata/WorkspaceSettings.xcsettings
99+
100+
# End of https://www.toptal.com/developers/gitignore/api/xcode,swift
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# For rules on SwiftFormat, please refer to https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md
2+
#
3+
# file options
4+
5+
# uncomment below to exclude files, folders
6+
#--exclude path/to/test1.swift,Snapshots,Build
7+
8+
# format options
9+
10+
--allman false
11+
--binarygrouping 4,8
12+
--commas always
13+
--comments indent
14+
--decimalgrouping 3,6
15+
--elseposition same-line
16+
--empty void
17+
--exponentcase lowercase
18+
--exponentgrouping disabled
19+
--fractiongrouping disabled
20+
--header ignore
21+
--hexgrouping 4,8
22+
--hexliteralcase uppercase
23+
--ifdef indent
24+
--indent 4
25+
--indentcase false
26+
--importgrouping testable-bottom
27+
--linebreaks lf
28+
--maxwidth none
29+
--octalgrouping 4,8
30+
--operatorfunc spaced
31+
--patternlet hoist
32+
--ranges spaced
33+
--self remove
34+
--semicolons inline
35+
--stripunusedargs always
36+
--swiftversion 5.4
37+
--trimwhitespace always
38+
--wraparguments preserve
39+
--wrapcollections preserve
40+
41+
# rules
42+
43+
--enable isEmpty
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github "Flight-School/AnyCodable" ~> 0.6
2+
github "apple/swift-log" ~> 1.4
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Algolia
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)