Skip to content

Commit

Permalink
Add format, lint, Makefile, and publish dry run
Browse files Browse the repository at this point in the history
  • Loading branch information
jtbandes committed Apr 15, 2024
1 parent 681f0db commit 33fe8fa
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 98 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@ name: CI
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
branches: [main]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
lfs: true

- run: make lint-ci
- run: make format-ci

build:
runs-on: macos-14
permissions:
# https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions
id-token: write
steps:
- uses: actions/[email protected]
with:
Expand All @@ -26,6 +41,6 @@ jobs:
key: v0-${{ runner.os }}-swiftpm-${{ hashFiles('**/Package.resolved') }}
restore-keys: v0-${{ runner.os }}-swiftpm-

- run: npm run build

- run: file build/Release/PreviewExtension.appex/Contents/MacOS/*
- run: npm publish --provenance --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
3 changes: 3 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--swiftversion 5.2
--indent 2
--maxwidth 120
15 changes: 15 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
strict: true

excluded:
- .build
- .swiftpm-packages

disabled_rules:
- function_body_length
- type_body_length
- file_length
- cyclomatic_complexity
- opening_brace # handled by swiftformat

trailing_comma:
mandatory_comma: true
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.PHONY: build
build:
# https://developer.apple.com/documentation/xcode/building-swift-packages-or-apps-that-use-them-in-continuous-integration-workflows
# https://stackoverflow.com/questions/4969932/separate-build-directory-using-xcodebuild
xcodebuild \
-disableAutomaticPackageResolution \
-clonedSourcePackagesDirPath .swiftpm-packages \
-destination generic/platform=macOS \
-scheme PreviewExtension \
SYMROOT=$(PWD)/build \
-configuration Release \
clean build
lipo build/Release/PreviewExtension.appex/Contents/MacOS/PreviewExtension -verify_arch arm64 x86_64
rm -rf dist
mkdir -p dist
cp -R build/Release/PreviewExtension.appex dist/
cp PreviewExtension/PreviewExtension.entitlements dist/

.PHONY: lint-ci
lint-ci:
docker run -t --rm -v $(PWD):/work -w /work ghcr.io/realm/swiftlint:0.53.0

.PHONY: format-ci
format-ci:
docker run -t --rm -v $(PWD):/work ghcr.io/nicklockwood/swiftformat:0.53.7 --lint /work
6 changes: 4 additions & 2 deletions PreviewExtension/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ struct Configuration {

extension Configuration {
static func fromMainBundle() throws -> Configuration {
guard let dict = (Bundle.main.localizedInfoDictionary ?? Bundle.main.infoDictionary)?["QLJS"] as? [String: Any] else {
guard let dict = (Bundle.main.localizedInfoDictionary ?? Bundle.main.infoDictionary)?["QLJS"] as? [String: Any]
else {
throw GenericError(message: "Could not read QLJS configuration from Info.plist")
}

Expand Down Expand Up @@ -46,6 +47,7 @@ extension Configuration {
return Configuration(
loadingStrategy: loadingStrategy,
pageURL: pageURL,
preferredContentSize: preferredContentSize)
preferredContentSize: preferredContentSize
)
}
}
Loading

0 comments on commit 33fe8fa

Please sign in to comment.