Skip to content

[Chore]: Add workflows for swiftlint, test, and build-documentation #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 10, 2022
Merged
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
20 changes: 20 additions & 0 deletions .github/scripts/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

ARCH=""

if [ $1 = "arm" ]
then
ARCH="arm64"
else
ARCH="x86_64"
fi

echo "Building with arch: ${ARCH}"

export LC_CTYPE=en_US.UTF-8

set -o pipefail && arch -"${ARCH}" xcodebuild \
-scheme CodeEditKit \
-derivedDataPath ".build" \
-destination "platform=macos,arch=${ARCH}" \
clean test | xcpretty
42 changes: 42 additions & 0 deletions .github/workflows/build-documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: build-documentation
on:
push:
branches:
- 'main'
paths:
- 'Sources/**'
jobs:
build-docc:
runs-on: macos-12
steps:
- name: Checkout repository
uses: actions/checkout@v1
- uses: actions/cache@v3
with:
path: '.build'
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- uses: fwcd/[email protected]
with:
target: CodeEditKit
output: ./docs
hosting-base-path: CodeEditKit
disable-indexing: 'true'
transform-for-static-hosting: 'true'
- name: Init new repo in dist folder and commit generated files
run: |
cd docs
git init
git add -A
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -m 'deploy'

- name: Force push to destination branch
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: docs
force: true
directory: ./docs
25 changes: 25 additions & 0 deletions .github/workflows/swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: SwiftLint
on:
push:
branches:
- 'main'
paths:
- '.github/workflows/swiftlint.yml'
- '.swiftlint.yml'
- '**/*.swift'
pull_request:
branches:
- 'main'
paths:
- '.github/workflows/swiftlint.yml'
- '.swiftlint.yml'
- '**/*.swift'
jobs:
SwiftLint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: GitHub Action for SwiftLint with --strict
uses: norio-nomura/[email protected]
with:
args: --strict
28 changes: 28 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: tests
on:
push:
branches:
- 'main'
paths:
- 'Sources/**'
- 'Tests/**'
pull_request:
branches:
- 'main'
jobs:
code-edit-text-view-tests:
name: Testing CodeEditTextView
runs-on: macos-12
steps:
- name: Checkout repository
uses: actions/checkout@v1
- uses: actions/cache@v3
with:
path: '.build'
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: Make executeable
run: chmod +x ./.github/scripts/tests.sh
- name: Testing Package
run: exec ./.github/scripts/tests.sh
16 changes: 16 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
disabled_rules:
- todo
- trailing_comma
- nesting

type_name:
excluded:
- ID

identifier_name:
min_length: 2
allowed_symbols: ['_']
excluded:
- c
- id
- vc
16 changes: 16 additions & 0 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let package = Package(
targets: ["CodeEditKit"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
Expand Down
7 changes: 7 additions & 0 deletions Sources/CodeEditKit/Documentation.docc/Documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ``CodeEditKit``

CodeEditKit is a dynamic library which is shared between CodeEdit and it's extensions. It allows them to communicate with and understand one another.

## Overview

This is still work in progress.
18 changes: 11 additions & 7 deletions Sources/CodeEditKit/Targets/Target.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public struct Target: Identifiable {
* - Parameter executable: The executable to launch inside the pseudo terminal
* - Parameter args: an array of strings that is passed as the arguments to the underlying process
* - Parameter environment: an array of environment variables to pass to the child process.
* - Parameter execName: If provided, this is used as the Unix argv[0] parameter, otherwise, the executable is used as the args [0], this is used when the intent is to set a different process name than the file that backs it.
* - Parameter execName: If provided, this is used as the Unix argv[0] parameter, otherwise,
* the executable is used as the args [0], this is used when the intent is to set a different process name
* than the file that backs it.
*/
public init(id: String, displayName: String,
executable: String, args: [String] = [],
Expand All @@ -30,21 +32,23 @@ public struct Target: Identifiable {
self.execName = execName
}

/// ``id`` is a unique identifier of the target set by the extension
/// `id` is a unique identifier of the target set by the extension
public var id: String

/// ``displayName`` is a name to be displayed in the UI to represent target
/// `displayName` is a name to be displayed in the UI to represent target
public var displayName: String

/// ``executable`` is the executable to launch inside the pseudo terminal
/// `executable` is the executable to launch inside the pseudo terminal
public var executable: String

/// ``args`` is an array of strings that is passed as the arguments to the underlying process
/// `args` is an array of strings that is passed as the arguments to the underlying process
public var args: [String] = []

/// ``environment`` is an array of environment variables to pass to the child process.
/// `environment` is an array of environment variables to pass to the child process.
public var environment: [String]?

/// ``execName`` If provided, this is used as the Unix argv[0] parameter, otherwise, the executable is used as the args [0], this is used when the intent is to set a different process name than the file that backs it.
/// `execName` If provided, this is used as the Unix argv[0] parameter, otherwise,
/// the executable is used as the args [0], this is used when the intent is to set a different
/// process name than the file that backs it.
public var execName: String?
}
4 changes: 1 addition & 3 deletions Tests/CodeEditKitTests/CEExtensionKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import XCTest

final class CEExtensionKitTests: XCTestCase {
func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct
// results.
XCTAssertTrue(true)
}
}