Skip to content

Commit

Permalink
Merge pull request #514 from ably/use-trainer-to-generate-junit-report
Browse files Browse the repository at this point in the history
Use Fastlane’s `trainer` to generate JUnit report
  • Loading branch information
lawrence-forooghian authored Dec 15, 2022
2 parents e83f62d + 6f4788b commit 86b3a9f
Showing 5 changed files with 218 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -37,14 +37,14 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: xcodebuild-logs
path: ~/Library/Developer/Xcode/DerivedData/*/Logs
path: test-results/xcodebuild-logs/Logs

- name: Upload test results
if: always()
uses: ably/test-observability-action@v1
with:
server-auth: ${{ secrets.TEST_OBSERVABILITY_SERVER_AUTH_KEY }}
path: '.'
path: 'test-results/junit'

check-log-parser:
runs-on: macos-latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ xcuserdata/

# Build products
archives/
test-results/

# Fastlane reports
/fastlane/report.xml
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -2,3 +2,4 @@ source "https://rubygems.org"

gem "xcpretty"
gem "jazzy"
gem "fastlane"
186 changes: 185 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -14,7 +14,25 @@ GEM
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.2.0)
aws-partitions (1.676.0)
aws-sdk-core (3.168.4)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.61.0)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.117.2)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.4)
aws-sigv4 (1.5.2)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
claide (1.1.0)
cocoapods (1.11.3)
addressable (~> 2.8)
@@ -53,15 +71,135 @@ GEM
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored (1.2)
colored2 (3.1.2)
commander (4.6.0)
highline (~> 2.0.0)
concurrent-ruby (1.1.10)
declarative (0.0.20)
digest-crc (0.6.4)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.8.1)
emoji_regex (3.2.3)
escape (0.0.4)
ethon (0.15.0)
ffi (>= 1.15.0)
excon (0.95.0)
faraday (1.10.2)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-cookie_jar (0.0.7)
faraday (>= 0.8.0)
http-cookie (~> 1.0.0)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.2.6)
fastlane (2.211.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
aws-sdk-s3 (~> 1.0)
babosa (>= 1.0.3, < 2.0.0)
bundler (>= 1.12.0, < 3.0.0)
colored
commander (~> 4.6)
dotenv (>= 2.1.1, < 3.0.0)
emoji_regex (>= 0.1, < 4.0)
excon (>= 0.71.0, < 1.0.0)
faraday (~> 1.0)
faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 1.0)
fastimage (>= 2.1.0, < 3.0.0)
gh_inspector (>= 1.1.2, < 2.0.0)
google-apis-androidpublisher_v3 (~> 0.3)
google-apis-playcustomapp_v1 (~> 0.1)
google-cloud-storage (~> 1.31)
highline (~> 2.0)
json (< 3.0.0)
jwt (>= 2.1.0, < 3)
mini_magick (>= 4.9.4, < 5.0.0)
multipart-post (~> 2.0.0)
naturally (~> 2.2)
optparse (~> 0.1.1)
plist (>= 3.1.0, < 4.0.0)
rubyzip (>= 2.0.0, < 3.0.0)
security (= 0.1.3)
simctl (~> 1.6.3)
terminal-notifier (>= 2.0.0, < 3.0.0)
terminal-table (>= 1.4.5, < 2.0.0)
tty-screen (>= 0.6.3, < 1.0.0)
tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
ffi (1.15.5)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.32.0)
google-apis-core (>= 0.9.1, < 2.a)
google-apis-core (0.9.2)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-iamcredentials_v1 (0.16.0)
google-apis-core (>= 0.9.1, < 2.a)
google-apis-playcustomapp_v1 (0.12.0)
google-apis-core (>= 0.9.1, < 2.a)
google-apis-storage_v1 (0.19.0)
google-apis-core (>= 0.9.0, < 2.a)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.3.0)
google-cloud-storage (1.44.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.19.0)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
googleauth (1.3.0)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
highline (2.0.3)
http-cookie (1.0.5)
domain_name (~> 0.5)
httpclient (2.8.3)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
@@ -75,29 +213,72 @@ GEM
sassc (~> 2.1)
sqlite3 (~> 1.3)
xcinvoke (~> 0.3.0)
jmespath (1.6.2)
json (2.6.2)
jwt (2.5.0)
liferaft (0.0.6)
memoist (0.16.2)
mini_magick (4.12.0)
mini_mime (1.1.2)
mini_portile2 (2.8.0)
minitest (5.16.3)
molinillo (0.8.0)
multi_json (1.15.0)
multipart-post (2.0.0)
mustache (1.1.1)
nanaimo (0.3.0)
nap (1.1.0)
naturally (2.2.1)
netrc (0.11.0)
open4 (1.3.4)
optparse (0.1.1)
os (1.1.4)
plist (3.6.0)
public_suffix (4.0.7)
rake (13.0.6)
redcarpet (3.5.1)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.2.5)
rouge (2.0.7)
ruby-macho (2.5.1)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
sassc (2.4.0)
ffi (~> 1.9)
security (0.1.3)
signet (0.17.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simctl (1.6.8)
CFPropertyList
naturally
sqlite3 (1.5.3)
mini_portile2 (~> 2.8.0)
terminal-notifier (2.0.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
trailblazer-option (0.1.2)
tty-cursor (0.7.1)
tty-screen (0.8.1)
tty-spinner (0.9.3)
tty-cursor (~> 0.7)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (1.8.0)
webrick (1.7.0)
word_wrap (1.0.0)
xcinvoke (0.3.0)
liferaft (~> 0.0.6)
xcodeproj (1.22.0)
@@ -109,14 +290,17 @@ GEM
rexml (~> 3.2.4)
xcpretty (0.3.0)
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.1)
xcpretty (~> 0.2, >= 0.0.7)
zeitwerk (2.6.1)

PLATFORMS
ruby

DEPENDENCIES
fastlane
jazzy
xcpretty

BUNDLED WITH
2.3.6
2.3.26
37 changes: 29 additions & 8 deletions Scripts/test.sh
Original file line number Diff line number Diff line change
@@ -23,18 +23,39 @@ struct Secrets {
}
EOF

# We want to specify a custom derived data directory so that we know where to
# find the test result .xcresult bundle. However, it appears that putting the
# derived data directory inside a Swift package’s repo causes build errors (see
# https://forums.swift.org/t/xcode-and-swift-package-manager/44704/6). So I’m
# following the suggestion there of placing the derived data directory outside
# the repo.
temp_dir=`mktemp -d -t ably-asset-tracking-swift`
derived_data_dir="${temp_dir}/DerivedData"

# If xcodebuild fails (e.g. due to failed tests), we want to defer the failure
# of this script until we’ve had a chance to copy the test results JUnit report
# to the place where test-observability-action expects it to be. Hence we
# temporarily disable the -e option.
# of this script until we’ve had a chance to process and copy the logs that
# xcodebuild created. Hence we temporarily disable the -e option.
set +e
# --report: "Creates a JUnit-style XML report at build/reports/junit.xml"
set -o pipefail && xcodebuild test -scheme "ably-asset-tracking-swift-Package" -destination 'platform=iOS Simulator,name=iPhone 12' \
| xcpretty --report junit
set -o pipefail && xcodebuild test -scheme "ably-asset-tracking-swift-Package" -destination 'platform=iOS Simulator,name=iPhone 12' -derivedDataPath "${derived_data_dir}" \
| xcpretty
xcodebuild_exit_status=$?
set -e

# test-observability-action looks for .junit files
cp build/reports/junit.xml results.junit
# Create a directory to store all of the files that we wish to pass to
# subsequent actions in the GitHub workflow that called this script.
mkdir test-results

derived_data_logs_dir="${derived_data_dir}/Logs"

# Convert the .xcresult bundle into a JUnit report file for test-observability-action
mkdir test-results/junit

derived_data_test_logs_dir="${derived_data_logs_dir}/Test"
bundle exec fastlane run trainer "path:${derived_data_test_logs_dir}" extension:".junit" fail_build:"false"
cp "${derived_data_test_logs_dir}"/*.junit test-results/junit

# Copy the Logs directory from derived data for the "Xcodebuild Logs Artifact" step in check.yml
mkdir test-results/xcodebuild-logs
cp -r "${derived_data_logs_dir}" test-results/xcodebuild-logs

exit $xcodebuild_exit_status

0 comments on commit 86b3a9f

Please sign in to comment.