Skip to content

Commit

Permalink
Merge pull request #10 from slidoapp/fix/5_xcode16_support
Browse files Browse the repository at this point in the history
  • Loading branch information
jozefizso authored Oct 29, 2024
2 parents 4cb8d03 + 6c699b3 commit 032c0ce
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 16 deletions.
50 changes: 36 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ on: # rebuild any PRs and main branch changes

jobs:
build: # make sure build/ci work properly
runs-on: macos-14
strategy:
fail-fast: false
matrix:
xcode: ['xcode16', 'xcode15']
include:
- xcode: 'xcode16'
xcode-path: '/Applications/Xcode_16.0.app'
macos: 'macos-15'
- xcode: 'xcode15'
xcode-path: '/Applications/Xcode_15.4.app'
macos: 'macos-14'
runs-on: ${{ matrix.macos }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -21,62 +32,73 @@ jobs:
- run: |
npm run all
test: # make sure the action works on a clean machine without building
runs-on: macos-14
strategy:
fail-fast: false
matrix:
xcode: ['xcode16', 'xcode15']
include:
- xcode: 'xcode16'
xcode-path: '/Applications/Xcode_16.0.app'
macos: 'macos-15'
- xcode: 'xcode15'
xcode-path: '/Applications/Xcode_15.4.app'
macos: 'macos-14'
runs-on: ${{ matrix.macos }}
steps:
- uses: actions/checkout@v4
- uses: ./
with:
path: __tests__/data/Example.xcresult
title: Example test report
title: 'Example test report (${{ matrix.xcode }})'
- uses: ./
with:
path: __tests__/data/Example.xcresult
title: Example Failures Only test report
title: 'Example Failures Only test report (${{ matrix.xcode }})'
show-passed-tests: false
- uses: ./
with:
path: __tests__/data/KeychainAccess.xcresult
title: KeychainAccess Failures Only test report
title: 'KeychainAccess Failures Only test report (${{ matrix.xcode }})'
show-passed-tests: false
- uses: ./
with:
path: __tests__/data/KeychainAccess.xcresult
title: KeychainAccess test report
title: 'KeychainAccess test report (${{ matrix.xcode }})'
- uses: ./
with:
path: __tests__/data/TAU.xcresult
title: TAU test report
title: 'TAU test report (${{ matrix.xcode }})'
- uses: ./
with:
path: __tests__/data/TestResults.xcresult
title: TestResults test report
title: 'TestResults test report (${{ matrix.xcode }})'
- uses: ./
with:
path: __tests__/data/Coverage.xcresult
title: Coverage test report
title: 'Coverage test report (${{ matrix.xcode }})'
- uses: ./
with:
path: __tests__/data/Coverage.xcresult
title: Hide Coverage test report
title: 'Hide Coverage test report (${{ matrix.xcode }})'
show-code-coverage: false
- uses: ./
with:
path: __tests__/data/UhooiPicBook.xcresult
title: UhooiPicBook test report
title: 'UhooiPicBook test report (${{ matrix.xcode }})'
- uses: ./
with:
path: __tests__/data/UhooiPicBook.xcresult
title: UhooiPicBook No Passed test report
title: 'UhooiPicBook No Passed test report (${{ matrix.xcode }})'
show-passed-tests: false
- uses: ./
with:
path: __tests__/data/UhooiPicBook.xcresult
title: UhooiPicBook No Code Coverage test report
title: 'UhooiPicBook No Code Coverage test report (${{ matrix.xcode }})'
show-code-coverage: false
- uses: ./
with:
path: |
__tests__/data/Example.xcresult
__tests__/data/KeychainAccess.xcresult
__tests__/data/TAU.xcresult
title: 'Multiple Paths'
title: 'Multiple Paths (${{ matrix.xcode }})'
67 changes: 67 additions & 0 deletions dist/index.js

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

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xcresulttool",
"version": "2.0.0",
"version": "3.0.1",
"private": false,
"description": "A GitHub Action that generates a human-readable test report from the Xcode result bundle and shows it on GitHub Checks.",
"main": "lib/main.js",
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ async function mergeResultBundle(
const args = ['xcresulttool', 'merge']
.concat(inputPaths)
.concat(['--output-path', outputPath])

const options = {
silent: !core.isDebug()
}
Expand Down
15 changes: 15 additions & 0 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import {promises} from 'fs'
import {getXcodeVersion} from './xcode'

const {readFile} = promises

export class Parser {
Expand All @@ -18,6 +20,8 @@ export class Parser {
}

async exportObject(reference: string, outputPath: string): Promise<Buffer> {
const xcodeVersion = await getXcodeVersion()

const args = [
'xcresulttool',
'export',
Expand All @@ -30,6 +34,11 @@ export class Parser {
'--id',
reference
]

if (xcodeVersion === 16) {
args.push('--legacy')
}

const options = {
silent: !core.isDebug()
}
Expand All @@ -56,6 +65,8 @@ export class Parser {
}

private async toJSON(reference?: string): Promise<string> {
const xcodeVersion = await getXcodeVersion()

const args = [
'xcresulttool',
'get',
Expand All @@ -69,6 +80,10 @@ export class Parser {
args.push(reference)
}

if (xcodeVersion === 16) {
args.push('--legacy')
}

let output = ''
const options = {
silent: !core.isDebug(),
Expand Down
25 changes: 25 additions & 0 deletions src/xcode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as core from '@actions/core'
import * as exec from '@actions/exec'

export async function getXcodeVersion(): Promise<number> {
let output = ''
const options = {
listeners: {
stdout: (data: Buffer) => {
output += data.toString()
}
},
silent: !core.isDebug()
}
await exec.exec('xcodebuild', ['-version'], options)
const match = output.match(/Xcode (\d+)/)
if (match) {
return parseInt(match[1], 10)
} else {
core.warning(
`Failed to determine Xcode version from command 'xcodebuild -version'.`
)
core.info(output)
return 0
}
}

0 comments on commit 032c0ce

Please sign in to comment.