#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

on:
  pull_request:
    paths-ignore:
      - '**/*.md'
      - 'dolphinscheduler-python/pydolphinscheduler'
  push:
    paths-ignore:
      - '**/*.md'
      - 'dolphinscheduler-python/pydolphinscheduler'
    branches:
      - dev

name: E2E

concurrency:
  group: e2e-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  e2e:
    name: ${{ matrix.case.name }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        case:
          - name: Tenant
            class: org.apache.dolphinscheduler.e2e.cases.TenantE2ETest
          - name: Project
            class: org.apache.dolphinscheduler.e2e.cases.ProjectE2ETest
          - name: Workflow
            class: org.apache.dolphinscheduler.e2e.cases.WorkflowE2ETest
    env:
      RECORDING_PATH: /tmp/recording-${{ matrix.case.name }}
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - name: Sanity Check
        uses: ./.github/actions/sanity-check
      - name: Cache local Maven repository
        uses: actions/cache@v2
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: ${{ runner.os }}-maven-
      - name: Build Image
        run: |
          ./mvnw -B clean install \
          -Dmaven.test.skip \
          -Dmaven.javadoc.skip \
          -Dmaven.checkstyle.skip \
          -Pdocker,release -Ddocker.tag=ci \
          -pl dolphinscheduler-standalone-server -am
      - name: Run Test
        run: |
          ./mvnw -B -f dolphinscheduler-e2e/pom.xml -am \
            -DfailIfNoTests=false \
            -Dtest=${{ matrix.case.class }} test
      - uses: actions/upload-artifact@v2
        if: always()
        name: Upload Recording
        with:
          name: recording-${{ matrix.case.name }}
          path: ${{ env.RECORDING_PATH }}
          retention-days: 1
