add env for allure #66
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: Test | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
schedule: | |
- cron: '0 9 * * 1' | |
workflow_dispatch: | |
inputs: | |
test_plan_type: | |
description: "Select the test plan" | |
required: true | |
type: choice | |
options: | |
- Smoke | |
- Regression | |
default: Regression | |
env: | |
PROJECT: 'SwiftRadio.xcodeproj' | |
SCHEME: 'SwiftRadioUITests' | |
DERIVED_DATA_PATH: 'DerivedData' | |
TEST_RESULTS: './TestResults.xcresult' | |
ALLURE_RESULTS: 'allure-results' | |
SIMULATOR_VERSION: '18.0' | |
SIMULATOR_NAME: 'iPhone 16' | |
jobs: | |
build: | |
name: Build | |
runs-on: [macos-15] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Build Project | |
id: build | |
run: | | |
set -o pipefail | |
xcodebuild build-for-testing \ | |
-project ${{ env.PROJECT }} \ | |
-scheme ${{ env.SCHEME }} \ | |
-derivedDataPath ${{ env.DERIVED_DATA_PATH }} \ | |
-destination 'platform=iOS Simulator,name=${{ env.SIMULATOR_NAME }},OS=${{ env.SIMULATOR_VERSION }}' \ | |
CODE_SIGNING_ALLOWED='NO' | |
mkdir TestData | |
patterns=("*.xctest" "*.app" "*.xctestrun" "*.framework" "*.bundle") | |
for pattern in "${patterns[@]}"; do | |
find "${{ env.DERIVED_DATA_PATH }}" -name "$pattern" -print | pax -rw -pe "TestData"; | |
done | |
echo "artifacts_path=TestData/${{ env.DERIVED_DATA_PATH }}" >> $GITHUB_OUTPUT | |
- uses: actions/upload-artifact@v4 | |
with: | |
path: ${{ steps.build.outputs.artifacts_path }} | |
name: TestData | |
retention-days: 30 | |
test: | |
name: Run ${{ github.event.inputs.test_type }} tests | |
runs-on: [macos-15] | |
needs: build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: TestData | |
path: ${{ env.DERIVED_DATA_PATH }} | |
- name: Download Allure Parser of XCResults | |
run: | | |
curl -OL https://github.com/eroshenkoam/xcresults/releases/download/1.19.0/xcresults | |
chmod +x xcresults | |
- name: Install Allure | |
run: brew install allure | |
- name: Run Ui Tests | |
run: | | |
if [ -z "${{ github.event.inputs.test_plan_type }}" ]; then | |
xcodebuild test-without-building \ | |
-xctestrun DerivedData/Build/Products/SwiftRadioUITests_Regression_iphonesimulator18.0-arm64.xctestrun \ | |
-destination 'platform=iOS Simulator,name=${{ env.SIMULATOR_NAME }},OS=${{ env.SIMULATOR_VERSION }}' \ | |
-resultBundlePath ./TestResults.xcresult | |
else | |
xcodebuild test-without-building \ | |
-xctestrun DerivedData/Build/Products/SwiftRadioUITests_${{ github.event.inputs.test_plan_type }}_iphonesimulator18.0-arm64.xctestrun \ | |
-destination 'platform=iOS Simulator,name=${{ env.SIMULATOR_NAME }},OS=${{ env.SIMULATOR_VERSION }}' \ | |
-resultBundlePath ./TestResults.xcresult | |
fi | |
continue-on-error: true | |
- name: Set env for allure | |
run: | | |
MARKETING_VERSION=$(xcodebuild -showBuildSettings | grep MARKETING_VERSION | awk '{print $3}') | |
echo "MARKETING_VERSION=$MARKETING_VERSION" >> $GITHUB_ENV | |
BUILD_VERSION=$(xcodebuild -showBuildSettings | grep CURRENT_PROJECT_VERSION | awk '{print $3}') | |
echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV | |
ALLURE_VERSION=$(allure --version) | |
echo "ALLURE_VERSION=$ALLURE_VERSION" >> $GITHUB_ENV | |
- name: Generate Allure files | |
run: | | |
mkdir ${{ env.ALLURE_RESULTS }} | |
./xcresults export TestResults.xcresult -o ${{ env.ALLURE_RESULTS }} | |
chmod +x scripts/testOpsReportFormatter.sh | |
scripts/testOpsReportFormatter.sh | |
chmod +x scripts/create_allure_environment.sh | |
scripts/create_allure_environment.sh | |
mkdir allure-report | |
allure generate ${{ env.ALLURE_RESULTS }} --report-dir allure-report | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: allure-results | |
path: | | |
allure-results/ | |
retention-days: 1 | |
report: | |
runs-on: [ubuntu-latest] | |
name: Report to Allure | |
needs: test | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: allure-results | |
path: allure-results | |
- name: Load test report history | |
uses: actions/checkout@v3 | |
if: always() | |
continue-on-error: true | |
with: | |
ref: gh-pages | |
path: gh-pages | |
- name: Build test report | |
uses: simple-elf/[email protected] | |
if: always() | |
with: | |
gh_pages: gh-pages | |
allure_history: allure-history | |
allure_results: ./allure-results | |
- name: Publish test report | |
uses: peaceiris/actions-gh-pages@v3 | |
if: always() | |
with: | |
github_token: ${{ secrets.TOKEN }} | |
publish_branch: gh-pages | |
publish_dir: allure-history |