Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: split e2e test run #1870

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/kind-e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ on:
required: false
default: false
pull_request_target:
types: [ opened, synchronize, reopened ]
types: [opened, synchronize, reopened]
paths:
- "**.go"

jobs:
e2e-tests:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
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
Expand Down Expand Up @@ -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 }}" \
Expand All @@ -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 }}" \
Expand Down
48 changes: 35 additions & 13 deletions hack/gh-workflow-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -178,7 +200,7 @@ help() {
create_second_github_app_controller_on_ghe <test_github_second_smee_url> <test_github_second_private_key> <test_github_second_webhook_secret>
Create the second controller on GHE

run_e2e_tests <bitbucket_cloud_token> <webhook_secret> <test_gitea_smeeurl> <installation_id> <gh_apps_token> <test_github_second_token> <gitlab_token> <bitbucket_server_token> <bitbucket_server_api_url> <bitbucket_server_webhook_secret>
run_e2e_tests <target> <bitbucket_cloud_token> <webhook_secret> <test_gitea_smeeurl> <installation_id> <gh_apps_token> <test_github_second_token> <gitlab_token> <bitbucket_server_token> <bitbucket_server_api_url> <bitbucket_server_webhook_secret>
Run the e2e tests

collect_logs
Expand All @@ -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}"
Expand Down
Loading