From 6fd539e4d55e8533b4359d2d49f58f0bd6ee7049 Mon Sep 17 00:00:00 2001 From: mojganii Date: Fri, 25 Oct 2024 09:51:42 +0200 Subject: [PATCH] Test --- .github/workflows/ios-end-to-end-tests.yml | 116 ++++----------------- 1 file changed, 23 insertions(+), 93 deletions(-) diff --git a/.github/workflows/ios-end-to-end-tests.yml b/.github/workflows/ios-end-to-end-tests.yml index 0245b0aabc47..ad32959b773a 100644 --- a/.github/workflows/ios-end-to-end-tests.yml +++ b/.github/workflows/ios-end-to-end-tests.yml @@ -1,7 +1,7 @@ ---- name: iOS end-to-end tests env: TEST_DEVICE_UDID: 00008130-0019181022F3803A + BRANCH_NAME: '' permissions: contents: read issues: write @@ -33,27 +33,20 @@ jobs: - name: Get Branch Name id: get_branch run: | - echo "Current branch: $GITHUB_REF" - # Extract the branch name from GITHUB_REF BRANCH_NAME="${GITHUB_REF##*/}" echo "branch_name=${BRANCH_NAME}" >> $GITHUB_OUTPUT - echo "Branch name is $BRANCH_NAME" - set-up-outputs-directory: - name: Set up outputs directory - runs-on: - - self-hosted - - macOS - - ios-test + + # Set branch name as a global environment variable + set-branch-name: + name: Set Branch Name as Environment Variable + runs-on: ubuntu-latest + needs: get-branch-name outputs: - job_outputs_directory: ${{ steps.set-up-job-outputs-directory.outputs.job_outputs_directory }} + branch_name_env: ${{ needs.get-branch-name.outputs.branch_name }} steps: - - name: Set up job outputs directory - id: set-up-job-outputs-directory - run: > - job_outputs_directory="$HOME/workflow-outputs/job-outputs-${{ github.run_id - }}" echo "job_outputs_directory=$job_outputs_directory" >> - "$GITHUB_OUTPUT" mkdir -p "$job_outputs_directory" - shell: bash + - name: Export Branch Name to Environment + run: echo "BRANCH_NAME=${{ needs.get-branch-name.outputs.branch_name }}" >> $GITHUB_ENV + build: name: Build for end-to-end testing runs-on: @@ -61,34 +54,25 @@ jobs: - macOS - ios-test needs: - - set-up-outputs-directory - - get-branch-name - timeout-minutes: 20 + - set-branch-name + env: + BRANCH_NAME: ${{ needs.set-branch-name.outputs.branch_name_env }} steps: - - name: Set commit hash or default to github.sha - id: set-commit-hash - run: | - if [ -z "${{ inputs.commit_hash }}" ]; then - echo "COMMIT_HASH=${{ github.sha }}" >> $GITHUB_ENV - else - echo "COMMIT_HASH=${{ inputs.commit_hash }}" >> $GITHUB_ENV - fi - shell: bash - name: Checkout repository to commit directory uses: actions/checkout@v4 with: - clean: true - fetch-depth: 1 ref: ${{ env.COMMIT_HASH }} path: $HOME/${{ env.COMMIT_HASH }} + - name: Configure Rust uses: actions-rs/toolchain@v1.0.6 with: toolchain: stable override: true target: aarch64-apple-ios + - name: Build iOS end-to-end tests action - uses: mullvad/mullvadvpn-app/.github/actions/build-ios-e2e-tests.yml@${{ needs.get-branch-name.outputs.branch_name }} + uses: mullvad/mullvadvpn-app/.github/actions/build-ios-e2e-tests.yml@${{ env.BRANCH_NAME }} with: test_name: ${{ github.event.inputs.user_supplied_test_name }} ios_device_pin_code: ${{ secrets.IOS_DEVICE_PIN_CODE }} @@ -97,25 +81,9 @@ jobs: no_time_account_number: ${{ secrets.IOS_NO_TIME_ACCOUNT_NUMBER_PRODUCTION }} test_device_udid: ${{ env.TEST_DEVICE_UDID }} partner_api_token: ${{ secrets.STAGEMOLE_PARTNER_AUTH }} - outputs_path: ${{ needs.set-up-outputs-directory.outputs.job_outputs_directory }} + outputs_path: ${{ needs.set-branch-name.outputs.branch_name_env }} base_directory: $HOME/${{ env.COMMIT_HASH }} - - name: Debug print job output directory - run: > - echo "Job output directory: ${{ - needs.set-up-outputs-directory.outputs.job_outputs_directory }}" - shell: bash - - name: Copy build output and project to output directory - run: > - JOB_OUTPUTS_DIRECTORY="${{ - needs.set-up-outputs-directory.outputs.job_outputs_directory }}" - mkdir -p "$JOB_OUTPUTS_DIRECTORY/derived-data" cp -R $HOME/${{ env.COMMIT_HASH }}/ios/derived-data "$JOB_OUTPUTS_DIRECTORY" cp -R $HOME/${{ env.COMMIT_HASH }} "$JOB_OUTPUTS_DIRECTORY/mullvadvpn-app" - shell: bash - - name: Clean up - run: | - rm -rf $HOME/${{ env.COMMIT_HASH }}/ios/Configurations/*.xcconfig - rm -rf $HOME/${{ env.COMMIT_HASH }}/ios/derived-data - shell: bash test: name: Run tests runs-on: @@ -123,53 +91,15 @@ jobs: - macOS - ios-test needs: - - get-branch-name + - set-branch-name - build - - set-up-outputs-directory - timeout-minutes: 60 + env: + BRANCH_NAME: ${{ needs.set-branch-name.outputs.branch_name_env }} steps: - name: Run iOS end-to-end tests action - uses: mullvad/mullvadvpn-app/.github/actions/run-ios-e2e-tests.yml@${{ needs.get-branch-name.outputs.branch_name }} + uses: mullvad/mullvadvpn-app/.github/actions/run-ios-e2e-tests.yml@${{ env.BRANCH_NAME }} with: test_name: MullvadVPNUITests/${{ matrix.test_suite }} test_device_udid: ${{ env.TEST_DEVICE_UDID }} - outputs_path: ${{ needs.set-up-outputs-directory.outputs.job_outputs_directory }} + outputs_path: ${{ needs.set-branch-name.outputs.branch_name_env }} base_directory: $HOME/${{ env.COMMIT_HASH }} - clean-up-outputs-directory: - if: always() - name: Clean up outputs directory - runs-on: - - self-hosted - - macOS - - ios-test - needs: - - test - - set-up-outputs-directory - steps: - - name: Clean up outputs directory - run: rm -rf ${{ needs.set-up-outputs-directory.outputs.job_outputs_directory }} - shell: bash - notify-on-failure: - if: failure() && github.event_name == 'pull_request' - name: Notify team on failure (if PR related) - runs-on: - - self-hosted - - macOS - - ios-test - needs: test - timeout-minutes: 5 - steps: - - name: Comment PR on test failure - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: > - const issue_number = context.issue.number; const run_id = context.runId; - const run_url = - `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${run_id}`; - github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issue_number, - body: `🚨 End-to-end tests failed. Please check the [failed workflow run](${run_url}).` - });