Skip to content
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
63 changes: 44 additions & 19 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
on:
pull_request:
paths:
- '*.ts'
- 'fixtures/**/*.swift'
- src/*.ts
- fixtures/**/*.swift
- .github/workflows/checks.yml
- dist/*
schedule:
Expand All @@ -14,18 +14,28 @@ concurrency:
cancel-in-progress: true

jobs:
verify-dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm i
- run: npm run prepare
- run: git diff --exit-code

defaults:
runs-on: macos-latest
needs: [verify-dist]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
with:
working-directory: fixtures/debug

xcodebuild-has-exited:
runs-on: macos-latest
needs: [verify-dist]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
with:
working-directory: fixtures/debug
Expand All @@ -37,8 +47,9 @@ jobs:

executable-runs:
runs-on: macos-latest
needs: [verify-dist]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
with:
action: build
Expand All @@ -52,8 +63,9 @@ jobs:

invalid-action-fails:
runs-on: macos-latest
needs: [verify-dist]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
id: xcodebuild
with:
Expand All @@ -67,8 +79,9 @@ jobs:

invalid-platform-fails:
runs-on: macos-latest
needs: [verify-dist]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
id: xcodebuild
with:
Expand All @@ -82,8 +95,9 @@ jobs:

invalid-swift-fails:
runs-on: macos-latest
needs: [verify-dist]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
id: xcodebuild
with:
Expand All @@ -97,8 +111,9 @@ jobs:

invalid-xcode-fails:
runs-on: macos-latest
needs: [verify-dist]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
id: xcodebuild
with:
Expand All @@ -112,8 +127,9 @@ jobs:

missing-api-key-id-fails:
runs-on: macos-latest
needs: [verify-dist]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
id: xcodebuild
with:
Expand All @@ -128,8 +144,9 @@ jobs:

missing-api-key-issuer-id-fails:
runs-on: macos-latest
needs: [verify-dist]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
id: xcodebuild
with:
Expand All @@ -144,6 +161,7 @@ jobs:

null-none-action:
runs-on: macos-latest
needs: [verify-dist]
strategy:
matrix:
action:
Expand All @@ -152,21 +170,22 @@ jobs:
- ''
- none
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
with:
working-directory: fixtures/debug
action: ${{ matrix.action }}

configurations:
runs-on: macos-latest
needs: [verify-dist]
strategy:
matrix:
configuration:
- debug
- release
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
with:
configuration: ${{ matrix.configuration }}
Expand All @@ -177,14 +196,15 @@ jobs:

verbosity:
runs-on: macos-latest
needs: [verify-dist]
strategy:
matrix:
verbosity:
- xcpretty
- quiet
- verbose
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
with:
verbosity: ${{ matrix.verbosity }}
Expand All @@ -193,6 +213,7 @@ jobs:
swift:
name: swift ${{ matrix.swift }}
runs-on: ${{ matrix.os }}
needs: [verify-dist]
strategy:
matrix:
swift:
Expand All @@ -210,7 +231,7 @@ jobs:
- swift: ~5.6
os: macos-12
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
with:
swift: ${{ matrix.swift }}
Expand All @@ -223,6 +244,7 @@ jobs:
xcode:
name: ${{ matrix.platform }} (${{ matrix.action }}, ${{ matrix.xcode }}${{ matrix.codecov && ', cc' || ''}})
runs-on: ${{ matrix.os || 'macos-11' }}
needs: [verify-dist]
strategy:
matrix:
platform:
Expand Down Expand Up @@ -252,7 +274,7 @@ jobs:
action: test
warnings-as-errors: false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
with:
platform: ${{ matrix.platform }}
Expand All @@ -268,6 +290,7 @@ jobs:
more-xcode:
name: ${{ matrix.platform }} (${{ matrix.action }}, ${{ matrix.xcode }}${{ matrix.codecov && ', cc' || ''}}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: [verify-dist]
strategy:
matrix:
os:
Expand All @@ -285,7 +308,7 @@ jobs:
warnings-as-errors:
- false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
with:
platform: ${{ matrix.platform }}
Expand All @@ -298,6 +321,7 @@ jobs:
verify-codecov:
name: ${{ matrix.platform }} (${{ matrix.action }}${{ matrix.codecov && ', cc' || ''}}${{ matrix.warnings-as-errors && ', warnings-as-errors' || ''}})
runs-on: macos-latest
needs: [verify-dist]
strategy:
matrix:
platform:
Expand All @@ -312,7 +336,7 @@ jobs:
- true
- false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
with:
platform: ${{ matrix.platform }}
Expand All @@ -325,8 +349,9 @@ jobs:
verify-swift-version:
name: .swift-version
runs-on: macos-10.15
needs: [verify-dist]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: mxcl/get-swift-version@v1
with:
requires: '>5.1'
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ inputs:
A scheme defined by an Xcode project or workspace.
If not specified, xcodebuild builds only the first target.
required: false
workspace:
description: |
The name of your workspace.
Use this option when your scheme is contained in an Xcode workspace.
required: false
warnings-as-errors:
description: Fails the build if any warnings in *non test targets*.
required: false
Expand Down
4 changes: 2 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

20 changes: 13 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ async function main() {
const destination = await getDestination(selected, platform)
const identity = getIdentity(core.getInput('code-sign-identity'), platform)
const xcpretty = verbosity() == 'xcpretty'
const workspace = core.getInput('workspace')

core.info(`» Selected Xcode ${selected}`)

Expand All @@ -57,7 +58,7 @@ async function main() {
await configureKeychain()
await configureProvisioningProfiles()

await build(await getScheme())
await build(await getScheme(workspace), workspace)

if (core.getInput('upload-logs') == 'always') {
await uploadLogs()
Expand Down Expand Up @@ -178,22 +179,27 @@ async function main() {
await createProvisioningProfiles(profiles, mobileProfiles)
}

async function build(scheme?: string) {
async function build(scheme?: string, workspace?: string) {
if (warningsAsErrors && actionIsTestable(action)) {
await xcodebuild('build', scheme)
await xcodebuild('build', scheme, workspace)
}
await xcodebuild(action, scheme)
await xcodebuild(action, scheme, workspace)
}

//// helper funcs

async function xcodebuild(action?: string, scheme?: string) {
async function xcodebuild(
action?: string,
scheme?: string,
workspace?: string
) {
if (action === 'none') return

const title = ['xcodebuild', action].filter((x) => x).join(' ')
await core.group(title, async () => {
let args = destination
if (scheme) args = args.concat(['-scheme', scheme])
if (workspace) args = args.concat(['-workspace', workspace])
if (identity) args = args.concat(identity)
if (verbosity() == 'quiet') args.push('-quiet')
if (configuration) args = args.concat(['-configuration', configuration])
Expand Down Expand Up @@ -223,14 +229,14 @@ async function main() {
}

//NOTE this is not nearly clever enough I think
async function getScheme(): Promise<string | undefined> {
async function getScheme(workspace?: string): Promise<string | undefined> {
const scheme = core.getInput('scheme')
if (scheme) {
return scheme
}

if (swiftPM) {
return getSchemeFromPackage()
return getSchemeFromPackage(workspace)
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,12 @@ interface Schemes {
}
}

export async function getSchemeFromPackage(): Promise<string> {
const out = await exec('xcodebuild', ['-list', '-json'])
export async function getSchemeFromPackage(
workspace?: string
): Promise<string> {
let args = ['-list', '-json']
if (workspace) args = args.concat(['-workspace', workspace])
const out = await exec('xcodebuild', args)
const json = parseJSON<Schemes>(out)
const schemes = (json?.workspace ?? json?.project)?.schemes
if (!schemes || schemes.length == 0)
Expand Down