diff --git a/.github/workflows/kind-e2e-tests.yaml b/.github/workflows/kind-e2e-tests.yaml index 0d94b2632..6f2f20a87 100644 --- a/.github/workflows/kind-e2e-tests.yaml +++ b/.github/workflows/kind-e2e-tests.yaml @@ -11,9 +11,10 @@ on: required: false default: false pull_request_target: - types: [ opened, synchronize, reopened ] + types: [opened, synchronize, reopened] paths: - "**.go" + jobs: e2e-tests: concurrency: @@ -21,6 +22,9 @@ jobs: cancel-in-progress: true name: e2e tests runs-on: ubuntu-latest + strategy: + matrix: + provider: [githubgitlab, others] env: KO_DOCKER_REPO: localhost:5000 CONTROLLER_DOMAIN_URL: controller.paac-127-0-0-1.nip.io @@ -77,7 +81,8 @@ jobs: - name: Run E2E Tests on pull_request if: ${{ github.event_name != 'schedule' }} run: | - ./hack/gh-workflow-ci.sh run_e2e_tests \ + ./hack/gh-workflow-ci.sh run_e2e_tests + ${{ matrix.provider }} \ "${{ secrets.BITBUCKET_CLOUD_TOKEN }}" \ "${{ secrets.WEBHOOK_SECRET }}" \ "${{ secrets.TEST_GITEA_SMEEURL }}" \ @@ -93,7 +98,8 @@ jobs: if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} run: | export NIGHTLY_E2E_TEST="true" - ./hack/gh-workflow-ci.sh run_e2e_tests \ + ./hack/gh-workflow-ci.sh run_e2e_tests + ${{ matrix.provider }} \ "${{ secrets.BITBUCKET_CLOUD_TOKEN }}" \ "${{ secrets.WEBHOOK_SECRET }}" \ "${{ secrets.TEST_GITEA_SMEEURL }}" \ diff --git a/hack/gh-workflow-ci.sh b/hack/gh-workflow-ci.sh index 3ca85185c..b93aed406 100755 --- a/hack/gh-workflow-ci.sh +++ b/hack/gh-workflow-ci.sh @@ -64,17 +64,33 @@ create_second_github_app_controller_on_ghe() { kubectl -n pipelines-as-code delete pod -l app.kubernetes.io/name=ghe-controller } +get_tests() { + target=$1 + mapfile -t testfiles < <(find test/ -maxdepth 1 -name '*.go') + ghglabre="Github|Gitlab" + if [[ ${target} == "githubgitlab" ]]; then + grep -hioP "^func Test.*(${ghglabre})(\w+)\(" "${testfiles[@]}" | sed -e 's/func[ ]*//' -e 's/($//' + elif [[ ${target} == "others" ]]; then + grep -hioP '^func Test(\w+)\(' "${testfiles[@]}" | grep -iPv "(${ghglabre})" | sed -e 's/func[ ]*//' -e 's/($//' + else + echo "Invalid target: ${target}" + echo "supported targets: githubgitlab, others" + fi +} + run_e2e_tests() { - bitbucket_cloud_token="${1}" - webhook_secret="${2}" - test_gitea_smeeurl="${3}" - installation_id="${4}" - gh_apps_token="${5}" - test_github_second_token="${6}" - gitlab_token="${7}" - bitbucket_server_token="${8}" - bitbucket_server_api_url="${9}" - bitbucket_server_webhook_secret="${10}" + set +x + target="${1}" + bitbucket_cloud_token="${2}" + webhook_secret="${3}" + test_gitea_smeeurl="${4}" + installation_id="${5}" + gh_apps_token="${6}" + test_github_second_token="${7}" + gitlab_token="${8}" + bitbucket_server_token="${9}" + bitbucket_server_api_url="${10}" + bitbucket_server_webhook_secret="${11}" # Nothing specific to webhook here it just that repo is private in that org and that's what we want to test export TEST_GITHUB_PRIVATE_TASK_URL="https://github.com/openshift-pipelines/pipelines-as-code-e2e-tests-private/blob/main/remote_task.yaml" @@ -122,7 +138,13 @@ run_e2e_tests() { export TEST_BITBUCKET_SERVER_WEBHOOK_SECRET="${bitbucket_server_webhook_secret}" export TEST_BITBUCKET_SERVER_USER="pipelines" export TEST_BITBUCKET_SERVER_E2E_REPOSITORY="PAC/pac-e2e-tests" - make test-e2e + + mapfile -t tests < <(get_tests "${target}") + echo "About to run ${#tests[@]} tests: ${tests[*]}" + env GO_TEST_FLAGS="-run '$( + IFS='|' + echo "${tests[*]}" + )'" make test-e2e } collect_logs() { @@ -178,7 +200,7 @@ help() { create_second_github_app_controller_on_ghe Create the second controller on GHE - run_e2e_tests + run_e2e_tests Run the e2e tests collect_logs @@ -194,7 +216,7 @@ create_second_github_app_controller_on_ghe) create_second_github_app_controller_on_ghe "${2}" "${3}" "${4}" ;; run_e2e_tests) - run_e2e_tests "${2}" "${3}" "${4}" "${5}" "${6}" "${7}" "${8}" "${9}" "${10}" "${11}" + run_e2e_tests "${2}" "${3}" "${4}" "${5}" "${6}" "${7}" "${8}" "${9}" "${10}" "${11}" "${12}" ;; collect_logs) collect_logs "${2}" "${3}"