Skip to content

Commit ec7e2dc

Browse files
committed
test: refactor E2E matrix and rename SecondController to GHE
Refactor the end-to-end test suite to standardize naming and simplify the CI workflow. Rename "SecondController" references to "GHE" across test files, structs, and helper functions to clearly identify GitHub Enterprise scenarios. Update the GitHub Actions workflow to use descriptive matrix targets (`github_public`, `github_ghe`) and eliminate the separate flaky test job. Modify the CI script to support these new targets while retaining backward compatibility for the previous target names. Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
1 parent 01ef74e commit ec7e2dc

22 files changed

+229
-332
lines changed

.github/workflows/e2e.yaml

Lines changed: 3 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ jobs:
4343
matrix:
4444
provider:
4545
[
46-
github_1,
47-
github_2,
48-
github_second_controller,
46+
github_public,
47+
github_ghe,
4948
gitlab_bitbucket,
5049
gitea_1,
5150
gitea_2,
@@ -439,136 +438,10 @@ jobs:
439438
name: logs-e2e-tests-${{ matrix.provider }}
440439
path: /tmp/logs
441440

442-
e2e-flaky-tests:
443-
name: e2e flaky tests
444-
runs-on: ubuntu-latest
445-
needs: e2e-tests
446-
if: always() && !cancelled()
447-
concurrency:
448-
group: ${{ github.workflow }}-flaky-${{ github.event.pull_request.number || github.ref_name }}
449-
cancel-in-progress: true
450-
451-
env:
452-
CONTROLLER_DOMAIN_URL: controller.paac-127-0-0-1.nip.io
453-
KOCACHE: /tmp/ko-cache
454-
KO_DOCKER_REPO: localhost:5000
455-
KUBECONFIG: /home/runner/.kube/config.kind
456-
TEST_EL_URL: http://controller.paac-127-0-0-1.nip.io
457-
TEST_EL_WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
458-
TEST_GITHUB_API_URL: api.github.com
459-
TEST_GITHUB_PRIVATE_TASK_NAME: task-remote
460-
TEST_GITHUB_PRIVATE_TASK_URL: https://github.com/openshift-pipelines/pipelines-as-code-e2e-tests-private/blob/main/remote_task.yaml
461-
TEST_GITHUB_REPO_INSTALLATION_ID: ${{ vars.INSTALLATION_ID }}
462-
TEST_GITHUB_REPO_OWNER_GITHUBAPP: openshift-pipelines/pipelines-as-code-e2e-tests
463-
TEST_GITHUB_SECOND_API_URL: ghe.pipelinesascode.com
464-
TEST_GITHUB_SECOND_EL_URL: http://ghe.paac-127-0-0-1.nip.io
465-
TEST_GITHUB_SECOND_REPO_INSTALLATION_ID: 1
466-
TEST_GITHUB_SECOND_REPO_OWNER_GITHUBAPP: pipelines-as-code/e2e
467-
TEST_GITHUB_SECOND_TOKEN: ${{ secrets.TEST_GITHUB_SECOND_TOKEN }}
468-
TEST_GITHUB_TOKEN: ${{ secrets.GH_APPS_TOKEN }}
469-
steps:
470-
- uses: actions/checkout@v6
471-
with:
472-
ref: ${{ inputs.target_ref || github.event.pull_request.head.sha || github.sha }}
473-
474-
- uses: actions/setup-go@v6
475-
with:
476-
go-version-file: "go.mod"
477-
478-
- name: Cache ko layer cache
479-
uses: actions/cache@v5
480-
with:
481-
path: /tmp/ko-cache
482-
key: ${{ runner.os }}-ko-${{ hashFiles('go.sum') }}
483-
restore-keys: |
484-
${{ runner.os }}-ko-
485-
486-
- uses: ko-build/setup-ko@v0.9
487-
488-
- name: Build binaries in parallel with cluster installation
489-
run: |
490-
nohup make allbinaries > /tmp/binary-build.log 2>&1 &
491-
echo $! > /tmp/binary-build.pid
492-
493-
- name: Install gosmee
494-
uses: jaxxstorm/action-install-gh-release@v2.1.0
495-
with:
496-
repo: chmouel/gosmee
497-
498-
- name: Install Snazy
499-
uses: jaxxstorm/action-install-gh-release@v2.1.0
500-
with:
501-
repo: chmouel/snazy
502-
503-
- name: Run gosmee for main controller
504-
run: |
505-
nohup gosmee client --saveDir /tmp/gosmee-replay ${{ secrets.PYSMEE_URL }} "http://${CONTROLLER_DOMAIN_URL}" > /tmp/gosmee-main.log 2>&1 &
506-
507-
- name: Start installing cluster
508-
run: |
509-
export PAC_DIR=${PWD}
510-
bash -x ./hack/dev/kind/install.sh
511-
512-
- name: Create PAC github-app-secret
513-
env:
514-
PAC_GITHUB_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
515-
PAC_GITHUB_APPLICATION_ID: ${{ vars.APPLICATION_ID }}
516-
PAC_WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
517-
run: |
518-
./hack/gh-workflow-ci.sh create_pac_github_app_secret
519-
520-
- name: Create second Github APP Controller on GHE
521-
env:
522-
TEST_GITHUB_SECOND_SMEE_URL: ${{ secrets.TEST_GITHUB_SECOND_SMEE_URL }}
523-
TEST_GITHUB_SECOND_PRIVATE_KEY: ${{ secrets.TEST_GITHUB_SECOND_PRIVATE_KEY }}
524-
TEST_GITHUB_SECOND_WEBHOOK_SECRET: ${{ secrets.TEST_GITHUB_SECOND_WEBHOOK_SECRET }}
525-
TEST_GITHUB_SECOND_APPLICATION_ID: ${{ vars.TEST_GITHUB_SECOND_APPLICATION_ID }}
526-
run: |
527-
./hack/gh-workflow-ci.sh create_second_github_app_controller_on_ghe
528-
529-
- name: Enable debug logging for e2e
530-
run: |
531-
set -euo pipefail
532-
kubectl -n pipelines-as-code patch configmap pac-config-logging --type merge -p '{"data":{"loglevel.pipelinesascode":"debug","loglevel.pac-watcher":"debug","loglevel.pipelines-as-code-webhook":"debug"}}'
533-
kubectl -n pipelines-as-code rollout restart deployment/pipelines-as-code-controller deployment/pipelines-as-code-webhook deployment/pipelines-as-code-watcher
534-
for name in controller webhook watcher; do
535-
echo "=== Waiting for $name to be ready ==="
536-
kubectl -n pipelines-as-code rollout status deployment/pipelines-as-code-$name --timeout=120s
537-
done
538-
539-
- name: Run Flaky E2E Tests
540-
env:
541-
TEST_PROVIDER: flaky
542-
TEST_EL_WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
543-
TEST_GITHUB_REPO_INSTALLATION_ID: ${{ vars.INSTALLATION_ID }}
544-
TEST_GITHUB_TOKEN: ${{ secrets.GH_APPS_TOKEN }}
545-
TEST_GITHUB_SECOND_TOKEN: ${{ secrets.TEST_GITHUB_SECOND_TOKEN }}
546-
run: |
547-
./hack/gh-workflow-ci.sh run_e2e_tests
548-
549-
- name: Collect logs
550-
if: ${{ always() }}
551-
env:
552-
TEST_GITHUB_SECOND_SMEE_URL: ${{ secrets.TEST_GITHUB_SECOND_SMEE_URL }}
553-
run: |
554-
./hack/gh-workflow-ci.sh collect_logs
555-
556-
- name: Show controllers/watcher errors with Snazy
557-
if: ${{ always() }}
558-
run: |
559-
./hack/gh-workflow-ci.sh output_logs
560-
561-
- name: Upload artifacts
562-
if: ${{ always() }}
563-
uses: actions/upload-artifact@v6
564-
with:
565-
name: logs-e2e-tests-flaky
566-
path: /tmp/logs
567-
568441
notify-slack:
569442
name: Notify Slack on Failures
570443
runs-on: ubuntu-latest
571-
needs: [e2e-tests, e2e-flaky-tests]
444+
needs: [e2e-tests]
572445
if: ${{ always() && github.ref_name == 'main' && github.event_name == 'schedule' }}
573446
steps:
574447
- uses: actions/checkout@v6

hack/gh-workflow-ci.sh

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ get_tests() {
8686
fi
8787

8888
local -a github_tests=()
89-
if [[ "${target}" == *"github"* ]] && [[ "${target}" != "github_second_controller" ]]; then
90-
mapfile -t github_tests < <(echo "${all_tests}" | grep -iP '^TestGithub' 2>/dev/null | grep -ivP 'Concurrency|GithubSecond|Flaky' 2>/dev/null | sort 2>/dev/null)
89+
if [[ "${target}" == *"github"* ]] && [[ "${target}" != "github_ghe" ]] && [[ "${target}" != "github_second_controller" ]]; then
90+
mapfile -t github_tests < <(echo "${all_tests}" | grep -iP '^TestGithub' 2>/dev/null | grep -ivP 'Concurrency|GithubGHE' 2>/dev/null | sort 2>/dev/null)
9191
fi
9292

9393
# Calculate chunk sizes for splitting gitea tests into 3 parts
@@ -97,32 +97,49 @@ get_tests() {
9797
remainder=$((${#gitea_tests[@]} % 3))
9898
fi
9999

100-
# Calculate chunk sizes for splitting github tests into 2 parts
100+
# TODO: revert once the new workflow matrix lands on main.
101+
# Backward compat: github_1/github_2 chunking for pull_request_target
102+
# which runs the workflow YAML from main (old target names).
101103
local github_chunk_size github_remainder
102104
if [[ ${#github_tests[@]} -gt 0 ]]; then
103-
github_chunk_size=$((${#github_tests[@]} / 2))
104-
github_remainder=$((${#github_tests[@]} % 2))
105+
github_chunk_size=$(( ${#github_tests[@]} / 2 ))
106+
github_remainder=$(( ${#github_tests[@]} % 2 ))
105107
fi
106108

107109
case "${target}" in
108110
flaky)
109-
printf '%s\n' "${all_tests}" | grep -iP 'Flaky'
111+
# no-op: flaky tests have been absorbed into their natural categories.
112+
# Kept for backward compat since pull_request_target uses main's YAML
113+
# which still references 'flaky'.
110114
;;
115+
111116
concurrency)
112117
printf '%s\n' "${all_tests}" | grep -iP 'Concurrency|Others'
113118
;;
119+
github_public)
120+
if [[ ${#github_tests[@]} -gt 0 ]]; then
121+
printf '%s\n' "${github_tests[@]}"
122+
fi
123+
;;
124+
# TODO: revert - remove github_1, github_2, github_second_controller aliases
125+
# once the new workflow matrix lands on main. These exist because
126+
# pull_request_target runs the workflow YAML from main which still sends old
127+
# target names.
114128
github_1)
115129
if [[ ${#github_tests[@]} -gt 0 ]]; then
116-
printf '%s\n' "${github_tests[@]:0:${github_chunk_size}}"
130+
printf '%s\n' "${github_tests[@]:0:$((github_chunk_size + github_remainder))}"
117131
fi
118132
;;
119133
github_2)
120134
if [[ ${#github_tests[@]} -gt 0 ]]; then
121-
printf '%s\n' "${github_tests[@]:${github_chunk_size}:$((github_chunk_size + github_remainder))}"
135+
printf '%s\n' "${github_tests[@]:$((github_chunk_size + github_remainder))}"
122136
fi
123137
;;
124138
github_second_controller)
125-
printf '%s\n' "${all_tests}" | grep -iP 'GithubSecond' | grep -ivP 'Concurrency|Flaky'
139+
printf '%s\n' "${all_tests}" | grep -iP 'GithubGHE' | grep -ivP 'Concurrency'
140+
;;
141+
github_ghe)
142+
printf '%s\n' "${all_tests}" | grep -iP 'GithubGHE' | grep -ivP 'Concurrency'
126143
;;
127144
gitlab_bitbucket)
128145
printf '%s\n' "${all_tests}" | grep -iP 'Gitlab|Bitbucket' | grep -ivP 'Concurrency'
@@ -145,7 +162,8 @@ get_tests() {
145162
;;
146163
*)
147164
echo "Invalid target: ${target}"
148-
echo "supported targets: github_1, github_2, github_second_controller, gitlab_bitbucket, gitea_1, gitea_2, gitea_3, concurrency, flaky"
165+
echo "supported targets: github_public, github_ghe, gitlab_bitbucket, gitea_1, gitea_2, gitea_3, concurrency, flaky"
166+
echo "backward compat aliases: github_1, github_2, github_second_controller"
149167
;;
150168
esac
151169
}
@@ -158,6 +176,11 @@ run_e2e_tests() {
158176
mapfile -t tests < <(get_tests "${target}")
159177
echo "About to run ${#tests[@]} tests: ${tests[*]}"
160178

179+
if [[ ${#tests[@]} -eq 0 || (-z "${tests[0]}" && ${#tests[@]} -eq 1) ]]; then
180+
echo "No tests to run for target '${target}', exiting successfully."
181+
return 0
182+
fi
183+
161184
mkdir -p /tmp/logs
162185

163186
# shellcheck disable=SC2001
@@ -285,7 +308,7 @@ output_logs)
285308
;;
286309
print_tests)
287310
set +x
288-
for target in github_1 github_2 github_second_controller gitlab_bitbucket gitea_1 gitea_2 gitea_3 concurrency flaky; do
311+
for target in github_public github_ghe gitlab_bitbucket gitea_1 gitea_2 gitea_3 concurrency flaky; do
289312
mapfile -t tests < <(get_tests "${target}")
290313
echo "Tests for target: ${target} Total: ${#tests[@]}"
291314
printf '%s\n' "${tests[@]}"

test/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ Tests run on:
130130

131131
The tests are separated into provider categories (matrix strategy):
132132

133-
- `github` - GitHub tests (excluding second controller and concurrency)
134-
- `github_second_controller` - GitHub second controller tests
133+
- `github_public` - Public GitHub tests (excluding GHE and concurrency)
134+
- `github_ghe` - GitHub Enterprise (GHE) tests
135135
- `gitlab_bitbucket` - GitLab and Bitbucket tests
136-
- `gitea_others` - Gitea and other non-provider specific functionality
136+
- `gitea_1`, `gitea_2`, `gitea_3` - Gitea tests (split into 3 chunks)
137137
- `concurrency` - Concurrency-specific tests
138138

139139
This split helps reduce the load on external APIs during testing and provides more focused test results.

test/gitea_gitops_commands_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ func TestGiteaOnCommentAnnotation(t *testing.T) {
127127
assert.NilError(t, err)
128128
}
129129

130-
// TestGiteaTestPipelineRunExplicitelyWithTestComment will test a pipelinerun
130+
// TestGiteaTestPipelineRunExplicitlyWithTestComment will test a pipelinerun
131131
// even if it hasn't matched when we are doing a /test comment.
132-
func TestGiteaTestPipelineRunExplicitelyWithTestComment(t *testing.T) {
132+
func TestGiteaTestPipelineRunExplicitlyWithTestComment(t *testing.T) {
133133
var err error
134134
ctx := context.Background()
135135
topts := &tgitea.TestOpts{

test/github_config_maxkeepruns_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ import (
1717
"knative.dev/pkg/apis"
1818
)
1919

20-
func TestGithubSecondMaxKeepRuns(t *testing.T) {
20+
func TestGithubGHEMaxKeepRuns(t *testing.T) {
2121
ctx := context.Background()
2222
g := &tgithub.PRTest{
23-
Label: "Github MaxKeepRun config",
24-
YamlFiles: []string{"testdata/pipelinerun-max-keep-run-1.yaml"},
25-
SecondController: true,
23+
Label: "Github MaxKeepRun config",
24+
YamlFiles: []string{"testdata/pipelinerun-max-keep-run-1.yaml"},
25+
GHE: true,
2626
}
2727
g.RunPullRequest(ctx, t)
2828
defer g.TearDown(ctx, t)

0 commit comments

Comments
 (0)