docs: update product description #165
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: iOS Cucumberworkflow | |
on: [push] | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
upload-reports: | |
name: Upload verification reports | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set paths | |
id: set_paths | |
run: | | |
path_system="${{ github.sha }}/system" | |
echo "path_system=$path_system" >> $GITHUB_ENV | |
- name: Create Dummy Verification Test Files | |
run: | | |
mkdir -p "$path_system" # Create the directory structure | |
echo '{"owner": '${{ github.repository_owner }}', "repository": '${{ github.repository }}', "branch": '${{ github.ref_name }}', "sha": '${{ github.sha }}', "verification": "system", "timestamp": '$(date +%s)'}' > "$path_system/cucumber-messages.ndjson" | |
env: | |
path_system: ${{ env.path_system }} | |
- name: Upload System Verificaiton | |
id: upload-system-ver | |
uses: coauthor-app/capture-action@v1 | |
with: | |
evidence: 'system-verification' | |
type: 'bdd' | |
format: 'cucumber+ndjson' | |
hostname: ${{ vars.UPLOAD_JOB }} | |
path: '${{ env.path_system }}/**' | |
build: | |
name: Build and Test default scheme using any available iPhone simulator | |
runs-on: macos-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Create path | |
id: set_paths | |
run: | | |
path_sbom="${{ github.sha }}/sbom" | |
mkdir -p $path_sbom # Create the directory structure | |
echo "path_sbom=$path_sbom" >> $GITHUB_ENV | |
path_test_reports="${{ github.sha }}/test-reports" | |
mkdir -p $path_test_reports # Create the directory structure | |
echo "path_test_reports=$path_test_reports" >> $GITHUB_ENV | |
- name: Set Default Scheme | |
run: | | |
scheme_list=$(xcodebuild -list -json | tr -d "\n") | |
default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['targets'][0]") | |
echo $default | cat >default | |
echo Using default scheme: $default | |
- name: Build | |
env: | |
scheme: ${{ 'default' }} | |
platform: ${{ 'iOS Simulator' }} | |
run: | | |
# xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959) | |
device=`xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{$1=$1;print}' | sed -e "s/ Simulator$//"` | |
if [ $scheme = default ]; then scheme=$(cat default); fi | |
if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi | |
file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` | |
xcodebuild build-for-testing -scheme "$scheme" -"$filetype_parameter" "$file_to_build" -destination "platform=$platform,name=$device" | |
- name: Use Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
- name: Install CDXGen and build SBOM | |
run: | | |
# Install CycloneDX generator and generate SBOM from build | |
npm install -g @cyclonedx/cdxgen | |
cdxgen -t swift -o ${{ env.path_sbom }}/bom.json -p --spec-version 1.6 | |
env: | |
path_sbom: ${{ env.path_sbom }} | |
- name: Upload SBOM to Coauthor | |
id: upload-sbom | |
uses: coauthor-app/capture-action@v1 | |
with: | |
evidence: 'cybersecurity' | |
type: 'sbom' | |
format: 'cyclonedx' | |
hostname: ${{ vars.UPLOAD_JOB }} | |
path: '${{ env.path_sbom }}/**' | |
- name: Install XCBeautify 2.11.0 | |
run: | | |
# Install xcbeautify from source, used to generate junit file from xcodebuild output | |
cd .. | |
git clone https://github.com/cpisciotta/xcbeautify.git | |
cd xcbeautify | |
git checkout tags/2.11.0 | |
make install | |
- name: Test | |
id: run-tests | |
env: | |
scheme: ${{ 'default' }} | |
platform: ${{ 'iOS Simulator' }} | |
TARGET_DEVICE_PLATFORM_NAME: ${{ 'iphonesimulator' }} | |
run: | | |
# xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959) | |
device=`xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{$1=$1;print}' | sed -e "s/ Simulator$//"` | |
if [ $scheme = default ]; then scheme=$(cat default); fi | |
if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi | |
file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` | |
# Run the tests and generate a junit report using xcbeautify, move the report to the test-reports directory | |
xcodebuild test-without-building -scheme "$scheme" -"$filetype_parameter" "$file_to_build" -destination "platform=$platform,name=$device" | xcbeautify --renderer github-actions --report junit | |
mv ./build/reports/junit.xml ${{ env.path_test_reports }}/junit.xml | |
# Display the junit file content | |
cat ${{ env.path_test_reports }}/junit.xml | |
# Retrieve TARGETNAME dynamically | |
TARGETNAME=$(xcodebuild -list | grep -A 1 "Targets:" | tail -n 1 | awk '{$1=$1;print}') | |
echo "TARGETNAME=$TARGETNAME" | |
report_file=$(find ~/Library/Developer/CoreSimulator/Devices/$TARGET_DEVICE_IDENTIFIER -name "CucumberTestResultsForCucumberSwiftSampleUITests.json" -print0 | xargs -r -0 ls -1 -t | head -1) | |
echo "Report file: $report_file" | |
echo "::set-output name=report_file::$report_file" | |
- name: Upload Item Verification (Unit Test Result) | |
uses: coauthor-app/capture-action@v1 | |
with: | |
evidence: 'item-verification' | |
type: 'test' | |
format: 'junit' | |
path: ${{ env.path_test_reports }} | |
hostname: ${{ vars.UPLOAD_JOB }} |