Skip to content

Commit

Permalink
chore: add workflow (#9)
Browse files Browse the repository at this point in the history
* create build workflow

* add xcresulttool

* change min deployment target

* change min deployment target for tests

* run build first

* install pkl

* correct cache

* reduce test footprint for debug

* save test artifacts

* xcpretty and save on failure

* select xcode ver

* proper install pkl

* proper install pkl

* reenable xcresulttool

* restore all tests

* restore build step

* improve tests and add lint

* simplify xcode test args and add func tests

* install pkl for functional tests
  • Loading branch information
willswire committed Sep 18, 2024
1 parent bf81506 commit fa32f84
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 10 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint

on:
workflow_dispatch:
pull_request:
branches: [main]

jobs:
lint:
name: SwiftLint Linting
runs-on: macos-14
steps:
- uses: actions/checkout@v4

- name: Install SwiftLint
run: |
brew install swiftlint
swiftlint version
- name: Run SwiftLint
run: swiftlint
80 changes: 80 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Test

on:
workflow_dispatch:
pull_request:
branches: [main]

env:
DESTINATION: platform=macOS,arch=arm64
SCHEME: Cosmic
TEST_SCHEME: CosmicTests
XCODE_PATH: /Applications/Xcode_16.0.app/Contents/Developer
PKL_VERSION: 0.26.3
PKL_ARCH: macos-aarch64

jobs:
xcode_tests:
name: Xcode Tests
runs-on: macos-14
steps:
- uses: actions/checkout@v4

- name: Install pkl
run: |
curl -L -o pkl "https://github.com/apple/pkl/releases/download/${PKL_VERSION}/pkl-${PKL_ARCH}"
chmod +x pkl
sudo mv pkl /usr/local/bin/pkl
pkl --version
- name: Select Xcode version
run: sudo xcode-select -s "${XCODE_PATH}"

- uses: actions/cache@v4
with:
path: |
~/Library/Developer/Xcode/DerivedData/Cosmic-*/SourcePackages/
~/Library/Caches/org.swift.swiftpm/
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}

- name: Execute build
run: xcodebuild build -scheme "$SCHEME" -destination "$DESTINATION" CODE_SIGNING_ALLOWED='NO' | xcpretty && exit ${PIPESTATUS[0]}

- name: Execute test
run: xcodebuild test -resultBundlePath TestResults -scheme "$TEST_SCHEME" -destination "$DESTINATION" CODE_SIGNING_ALLOWED='NO' | xcpretty && exit ${PIPESTATUS[0]}

- name: Archive test results
uses: actions/upload-artifact@v4
with:
name: TestResults.xcresult
path: TestResults.xcresult/

functional_tests:
name: Functional Tests
runs-on: macos-14
steps:
- uses: actions/checkout@v4

- name: Install pkl
run: |
curl -L -o pkl "https://github.com/apple/pkl/releases/download/${PKL_VERSION}/pkl-${PKL_ARCH}"
chmod +x pkl
sudo mv pkl /usr/local/bin/pkl
pkl --version
- name: Select Xcode version
run: sudo xcode-select -s "${XCODE_PATH}"

- name: Build and archive Cosmic
run: |
xcodebuild archive -scheme "$SCHEME" -destination "$DESTINATION" CODE_SIGNING_ALLOWED='NO' -archivePath ./build/Cosmic.xcarchive
ls ./build
- name: Install Cosmic
run: |
sudo cp ./build/Cosmic.xcarchive/Products/usr/local/bin/cosmic /usr/local/bin/cosmic
cosmic --help
- name: Run Cosmic command
run: |
cosmic add k9s
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# .github/workflows/test.yml artifacts
build/
TestResults.xcresult
TestResults

# macOS
.DS_Store

Expand Down
4 changes: 4 additions & 0 deletions Cosmic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = QSQY64SHJ5;
ENABLE_HARDENED_RUNTIME = YES;
MACOSX_DEPLOYMENT_TARGET = 14.6;
PRODUCT_BUNDLE_IDENTIFIER = com.willswire.Cosmic;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -372,6 +373,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = QSQY64SHJ5;
ENABLE_HARDENED_RUNTIME = YES;
MACOSX_DEPLOYMENT_TARGET = 14.6;
PRODUCT_BUNDLE_IDENTIFIER = com.willswire.Cosmic;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -386,6 +388,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = QSQY64SHJ5;
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 14.6;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.willswire.CosmicTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -401,6 +404,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = QSQY64SHJ5;
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 14.6;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.willswire.CosmicTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
20 changes: 10 additions & 10 deletions CosmicTests/CosmicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ struct CosmicTests {
@Test(
"Install a package",
arguments: [
"k9s",
"zarf",
"age",
"hermes",
"dasel",
"apko",
"git-lfs",
"gitleaks",
"gh",
"sops"
"k9s"
//"zarf",
//"age",
//"hermes",
//"dasel",
//"apko",
//"git-lfs",
//"gitleaks",
//"gh",
//"sops",
])
func installPackage(packageName: String) async throws {
let addCommand = Cosmic.Add()
Expand Down

0 comments on commit fa32f84

Please # to comment.