Skip to content

Commit

Permalink
Merge pull request #47 from mxcl/no-action
Browse files Browse the repository at this point in the history
Allow selection only
  • Loading branch information
mxcl authored Jul 4, 2021
2 parents 36b6f27 + 0184e3e commit 2df1a6e
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 13 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ jobs:
with:
working-directory: fixtures/debug

null-none-action:
runs-on: macos-latest
strategy:
matrix:
action:
- null # treated as '' by GHA’s parser
- ~ # treated as '' by GHA’s parser
- ''
- none
steps:
- uses: actions/checkout@v2
- uses: ./
with:
working-directory: fixtures/debug
action: ${{ matrix.action }}

configurations:
runs-on: macos-latest
strategy:
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ jobs:
configuration: release # no default, ie. `xcodebuild` decides itself
```
> † check out https://devhints.io/semver for valid constraints
```yaml
jobs:
build:
Expand Down Expand Up @@ -115,7 +117,18 @@ jobs:
swift: ${{ matrix.swift }}
```
> † check out https://devhints.io/semver for valid constraints
You *can* use this action to just select Xcode and perform no action:
```yaml
jobs:
build:
runs-on: ${{ matrix.os }}
steps:
- use: mxcl/xcodebuild@v1
with:
action: none
- run: … # do your own thing
```
## Available Xcodes
Expand Down
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ inputs:
required: false
action:
description: |
The most common actions are `test`, `build`.
See the `xcodebuild` manual for available actions.
* The most common actions are `test`, `build`.
* See the `xcodebuild` manual for available actions.
* Specifying `none` skips the explicit `xcodebuild` step allowing you
to use this (GitHub) Action solely for selecting an Xcode version.
* Specifying `''`, `null` or `~` will cause xcodebuild to behave as it
does without an action specified (usually `build`)
required: false
default: test
code-coverage:
Expand Down
2 changes: 1 addition & 1 deletion 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.

9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ async function run() {

//// helper funcs

async function xcodebuild(action: string, scheme: string | undefined): Promise<void> {
async function xcodebuild(action: string | null, scheme: string | undefined): Promise<void> {
if (action === 'none') return

try {
core.startGroup(`\`xcodebuild ${action}\``)
const title = ['xcodebuild', action].filter(x=>x).join(' ')
core.startGroup(`\`${title}\``)
let args = destination
if (scheme) args = args.concat(['-scheme', scheme])
if (verbosity() == 'quiet') args.push('-quiet')
Expand All @@ -97,7 +100,7 @@ async function run() {
break
}

args.push(action)
if (action) args.push(action)

await xcodebuildX(args, xcpretty)
} finally {
Expand Down
10 changes: 5 additions & 5 deletions src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,19 @@ function getConfiguration() {

export type Platform = 'watchOS' | 'iOS' | 'tvOS' | 'macOS' | ''

export function getAction(platform: Platform, selectedXcode: string) {
const action = core.getInput('action').trim() || 'test'
export function getAction(platform: Platform, selectedXcode: string): string | null {
const action = core.getInput('action')
if (semver.gte(selectedXcode, '12.5.0')) {
return action
} else if (platform == 'watchOS' && actionIsTestable(action)) {
core.warning("Setting `action=build` for Apple Watch / Xcode <12.5")
core.info("Setting `action=build` for Apple Watch / Xcode <12.5")
return 'build'
} else {
return action
return action || null
}
}

const actionIsTestable = (action: string) => action == 'test' || action == 'build-for-testing'
const actionIsTestable = (action: string | null) => action == 'test' || action == 'build-for-testing'

export async function getDestination(platform: string): Promise<string[]> {
switch (platform.trim()) {
Expand Down

0 comments on commit 2df1a6e

Please sign in to comment.