teamdigitale/italia-app

View on GitHub
.github/workflows/test-e2e.yml

Summary

Maintainability
Test Coverage
name: Run e2e tests
on:
  workflow_dispatch:
  push:
    branches:
      - master
jobs:
  run-static-checks:
   uses: ./.github/workflows/staticcheck.yaml
  build-detox-app:
    needs: run-static-checks
    runs-on: macos-12
    concurrency:
      group: ${{ github.workflow }}-e2e-tests-${{ github.ref || github.run_id }}
      cancel-in-progress: true
    steps:
      - id: checkout
        uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      - id: setup
        uses: ./.github/actions/setup-composite
        with:
          use-cache: 'true'
      - id: setup-ruby
        uses: ruby/setup-ruby@5f19ec79cedfadb78ab837f95b87734d0003c899 #v1.173.0
        with:
          bundler-cache: true
      - id: prepare-dependencies
        run: |
          cp .env.local .env
          yarn run postinstall
        shell: bash
      - id: cache-cocoapods
        uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
        with:
          path: ios/Pods
          key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }}
      - id: install-applesimutils
        run: |
          brew tap wix/brew
          brew install applesimutils
        shell: bash
      - id: detox-rebuild-framework-cache
        run: yarn detox rebuild-framework-cache
      - id: cache-detox-build
        uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
        with:
          path: ios/build
          key: ${{ runner.os }}-detox-build
      - id: setup-pods
        run: cd ios ; bundle exec pod install --verbose ; cd ..
        shell: bash
      - id: prepare-detox-build
        run: RN_SRC_EXT=e2e.ts yarn detox build -c ios.sim.release
        shell: bash
      - id: upload-detox-build
        uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.0.3
        with:
          name: IO.app
          path: ios/build/Build/Products/Release-iphonesimulator/IO.app
          retention-days: 2
  run-e2e-tests:    
    needs: build-detox-app
    runs-on: macos-12
    environment: dev
    strategy: 
      fail-fast: false
      matrix:
        include:
          - test: "ts/__e2e__/"
            name: "Base_e2e"
          - test: "ts/features/bonus/cgn/__e2e__/"
            name: "cgn_e2e"
          - test: "ts/features/messages/__e2e__/"
            name: "messages_e2e"
          - test: "ts/features/euCovidCert/__e2e__/"
            name: "eucovidcert_e2e"
          - test: "ts/features/wallet/onboarding/__e2e__/"
            name: "wallet_onboarding_e2e"
    steps:
      - id: install-applesimutils
        run: |
          brew tap wix/brew
          brew install applesimutils
        shell: bash
      - id: checkout
        uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      - id: download-detox-build
        uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
        with:
          name: IO.app
          path: ios/build/Build/Products/Release-iphonesimulator/IO.app
      - id: setup
        uses: ./.github/actions/setup-composite
        with:
          use-cache: 'true'
      - id: checkout-dev-server
        uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
        with:
          repository: pagopa/io-dev-api-server
          path: './_io-dev-api-server_'
      - id: run-e2e-tests
        run: bash ./.github/scripts/run-e2e-tests.sh ${{ matrix.test }}
#     - id: notify-test-failure
#        if: failure()
#        uses: ./.github/actions/notify-e2e
#        env:
#         TEST: ${{ matrix.name }}
#          IO_APP_SLACK_HELPER_BOT_TOKEN: ${{ secrets.IO_APP_SLACK_HELPER_BOT_TOKEN }}
      - id: upload-artifacts
        uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v.3.1.2        
        if: always()
        with:
          name: detox-artifacts-${{ matrix.name }}
          path: /tmp/e2e_artifacts/
          retention-days: 2