Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/preflight-pull-request-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Preflight Code Checks

on: pull_request

jobs:
Preflight-Code-Checks:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- name: Check for Changes
id: repo-fetch-changes
run: |
echo "-> Source: ${{ github.head_ref }} (${{ github.event.pull_request.head.sha }})"
echo "-> Target: ${{ github.base_ref }} (${{ github.event.pull_request.base.sha }})"
# Fetching base ref
git fetch --prune --no-tags --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/heads/${{ github.base_ref }}

against=${{ github.event.pull_request.base.sha }}
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)

echo "changed_files<<$EOF" >> $GITHUB_ENV

changed_files=$(git --no-pager diff-index --cached --diff-filter=ACMR --name-only --relative $against -- '*.swift')

echo "$changed_files" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: Code Format Validation
if: env.changed_files != ''
run: |
modified_file_list="${{ github.workspace }}/modified_file_list"

echo "${{ env.changed_files }}" > $modified_file_list

swiftformat --filelist "$modified_file_list" --lint --config ${{ github.workspace }}/.swiftformat --swiftversion 5 --reporter github-actions-log
- name: Linting Code
if: env.changed_files != ''
run: |
modified_files=$(cat "${{ github.workspace }}/modified_file_list")

swiftlint lint --config ${{ github.workspace }}/.swiftlint --reporter "github-actions-logging" $modified_files
11 changes: 6 additions & 5 deletions Examples/GopherExample/GopherExample/DownloadQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class DownloadQueue
{
enum Error: Swift.Error
{
case empty
case Empty
}

var count: Int
Expand All @@ -21,7 +21,7 @@ final class DownloadQueue

private var queue: [DownloadItem] = []

func add(url: URL, download_location: URL? = nil)
func add(url: URL, download_location _: URL? = nil)
{
queue.append(DownloadItem(url: url))
}
Expand All @@ -33,7 +33,8 @@ final class DownloadQueue

func clear()
{
queue.forEach { item in
queue.forEach
{ item in
switch item.status
{
case .in_progress:
Expand Down Expand Up @@ -154,7 +155,7 @@ extension DownloadQueue
return url
}

static private func imageFromFileSystem(for request: URLRequest) throws -> UIImage?
private static func imageFromFileSystem(for request: URLRequest) throws -> UIImage?
{
guard let url = fileName(for: request)
else
Expand All @@ -167,7 +168,7 @@ extension DownloadQueue
return UIImage(data: data)
}

static private func fileName(for urlRequest: URLRequest) -> URL?
private static func fileName(for urlRequest: URLRequest) -> URL?
{
guard let fileName = urlRequest.url?.absoluteString.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed),
let applicationSupport = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first
Expand Down
4 changes: 3 additions & 1 deletion Examples/GopherExample/GopherExample/MovieInfoProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ extension MovieInfoProvider
{
func popular() async throws
{
_ = URL(string: "https://road.to.nowhere")!
let result: MovieResult = try await service.invoke(resource: .popular)

DispatchQueue.main.async {
DispatchQueue.main.async
{
self.movies = result.results
}
}
Expand Down
12 changes: 6 additions & 6 deletions Examples/GopherExample/GopherExample/NetworkService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class NetworkService
init(service: Gopher)
{
self.service = service
self.download_queue = DownloadQueue()
download_queue = DownloadQueue()
}

func invoke<Model>(resource: TheMovieDatabase,
Expand Down Expand Up @@ -44,13 +44,13 @@ extension NetworkService

private enum Header
{
static let api_key = "api_key"
static let api_key = "api_key"
static let language = "language"
}

case auth_temp_token
case auth_new_session
case authenticate
case Auth_temp_token
case Auth_new_session
case Authenticate
case popular
case popular_persons
case topRated
Expand Down Expand Up @@ -139,7 +139,7 @@ extension NetworkService
}
}

static private func prepare_endpoint(with identifier: String = DefaultValue.empty_string,
private static func prepare_endpoint(with identifier: String = DefaultValue.empty_string,
resource: String) -> String
{
let endpoint: String
Expand Down