Skip to content

Commit 4d2dd33

Browse files
committed
refactor: Revert startpaac
* can't get it to work reliably so revert to the previous * Updated the E2E GitHub Actions workflow: * Added `pull_request` trigger alongside `pull_request_target`. * Added `target_ref` input for manual runs. Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
1 parent 067e35a commit 4d2dd33

File tree

3 files changed

+97
-92
lines changed

3 files changed

+97
-92
lines changed

.github/workflows/e2e.yaml

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ on:
1010
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
1111
required: false
1212
default: false
13-
pull_request:
13+
target_ref:
14+
type: string
15+
description: "Target ref to run the tests against"
16+
required: false
17+
pull_request_target:
1418
types:
1519
- labeled
1620
- opened
@@ -22,7 +26,7 @@ jobs:
2226
# Only run if it's a scheduled run, manual dispatch, or has e2e label
2327
if: >
2428
github.event_name == 'schedule' ||
25-
(github.event_name == 'workflow_dispatch') ||
29+
github.event_name == 'workflow_dispatch' ||
2630
(github.event_name == 'pull_request_target' && (github.event.label.name == 'e2e' || contains(github.event.pull_request.labels.*.name, 'e2e')))
2731
2832
concurrency:
@@ -37,15 +41,14 @@ jobs:
3741

3842
env:
3943
KO_DOCKER_REPO: localhost:5000
40-
CONTROLLER_DOMAIN_URL: paac.127.0.0.1.nip.io
44+
CONTROLLER_DOMAIN_URL: controller.paac-127-0-0-1.nip.io
4145
TEST_GITHUB_REPO_OWNER_GITHUBAPP: openshift-pipelines/pipelines-as-code-e2e-tests
4246
KUBECONFIG: /home/runner/.kube/config.kind
4347
TEST_BITBUCKET_CLOUD_API_URL: https://api.bitbucket.org/2.0
4448
TEST_BITBUCKET_CLOUD_E2E_REPOSITORY: cboudjna/pac-e2e-tests
4549
TEST_BITBUCKET_CLOUD_USER: cboudjna
46-
TEST_EL_URL: https://paac.127.0.0.1.nip.io
47-
TEST_GITEA_API_URL: https://gitea.127.0.0.1.nip.io
48-
TEST_GITEA_INTERNAL_URL: http://forgejo-http.forgejo.svc.cluster.local:3000
50+
TEST_EL_URL: http://controller.paac-127-0-0-1.nip.io
51+
TEST_GITEA_API_URL: http://localhost:3000
4952
TEST_GITEA_USERNAME: pac
5053
TEST_GITEA_PASSWORD: pac
5154
TEST_GITEA_REPO_OWNER: pac/pac
@@ -54,16 +57,17 @@ jobs:
5457
TEST_GITHUB_PRIVATE_TASK_URL: https://github.com/openshift-pipelines/pipelines-as-code-e2e-tests-private/blob/main/remote_task.yaml
5558
TEST_GITHUB_PRIVATE_TASK_NAME: task-remote
5659
TEST_GITHUB_SECOND_API_URL: ghe.pipelinesascode.com
57-
TEST_GITHUB_SECOND_EL_URL: https://ghe.127.0.0.1.nip.io
60+
TEST_GITHUB_SECOND_EL_URL: http://ghe.paac-127-0-0-1.nip.io
5861
TEST_GITHUB_SECOND_REPO_OWNER_GITHUBAPP: pipelines-as-code/e2e
62+
TEST_GITHUB_SECOND_REPO_INSTALLATION_ID: 1
5963
TEST_GITLAB_API_URL: https://gitlab.com
6064
TEST_GITLAB_PROJECT_ID: ${{ vars.TEST_GITLAB_PROJECT_ID }}
6165
TEST_BITBUCKET_SERVER_USER: pipelines
6266
TEST_BITBUCKET_SERVER_E2E_REPOSITORY: PAC/pac-e2e-tests
6367
steps:
6468
- uses: actions/checkout@v4
6569
with:
66-
ref: ${{ github.event.pull_request.head.sha || github.sha }}
70+
ref: ${{ inputs.target_ref || github.event.pull_request.head.sha || github.sha }}
6771

6872
- uses: actions/setup-go@v5
6973
with:
@@ -76,55 +80,38 @@ jobs:
7680
with:
7781
repo: chmouel/gosmee
7882

79-
- name: Run gosmee main controller
80-
run: |
81-
nohup gosmee client --saveDir /tmp/gosmee-replay ${{ secrets.TEST_GITEA_SMEEURL }} "${TEST_EL_URL}" &
82-
83-
- name: Run gosmee second controller
84-
if: matrix.provider == 'providers'
83+
- name: Run gosmee
8584
run: |
86-
nohup gosmee client --saveDir /tmp/gosmee-replay ${{ secrets.TEST_GITHUB_SECOND_SMEE_URL }} "${TEST_GITHUB_SECOND_EL_URL}" &
85+
nohup gosmee client --saveDir /tmp/gosmee-replay ${{ secrets.PYSMEE_URL }} "http://${CONTROLLER_DOMAIN_URL}" &
8786
8887
- name: Setup tmate session
8988
uses: mxschmitt/action-tmate@v3
9089
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
91-
env:
92-
PAC_GITHUB_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
93-
PAC_GITHUB_APPLICATION_ID: ${{ vars.APPLICATION_ID }}
94-
PAC_WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
95-
PAC_SMEE_URL: ${{ secrets.PYSMEE_URL }}
96-
TEST_GITHUB_SECOND_SMEE_URL: ${{ secrets.TEST_GITHUB_SECOND_SMEE_URL }}
97-
TEST_GITHUB_SECOND_PRIVATE_KEY: ${{ secrets.TEST_GITHUB_SECOND_PRIVATE_KEY }}
98-
TEST_GITHUB_SECOND_WEBHOOK_SECRET: ${{ secrets.TEST_GITHUB_SECOND_WEBHOOK_SECRET }}
99-
TEST_GITHUB_SECOND_APPLICATION_ID: ${{ vars.TEST_GITHUB_SECOND_APPLICATION_ID }}
100-
TEST_PROVIDER: ${{ matrix.provider }}
101-
TEST_BITBUCKET_CLOUD_TOKEN: ${{ secrets.BITBUCKET_CLOUD_TOKEN }}
102-
TEST_EL_WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
103-
TEST_GITEA_SMEEURL: ${{ secrets.TEST_GITEA_SMEEURL }}
104-
TEST_GITHUB_REPO_INSTALLATION_ID: ${{ vars.INSTALLATION_ID }}
105-
TEST_GITHUB_TOKEN: ${{ secrets.GH_APPS_TOKEN }}
106-
TEST_GITHUB_SECOND_TOKEN: ${{ secrets.TEST_GITHUB_SECOND_TOKEN }}
107-
TEST_GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
108-
TEST_BITBUCKET_SERVER_TOKEN: ${{ secrets.BITBUCKET_SERVER_TOKEN }}
109-
TEST_BITBUCKET_SERVER_API_URL: ${{ secrets.BITBUCKET_SERVER_API_URL }}
110-
TEST_BITBUCKET_SERVER_WEBHOOK_SECRET: ${{ secrets.BITBUCKET_SERVER_WEBHOOK_SECRET }}
11190
with:
11291
detached: true
11392
limit-access-to-actor: true
11493

11594
- name: Start installing cluster
95+
run: |
96+
export PAC_DIR=${PWD}
97+
export TEST_GITEA_SMEEURL="${{ secrets.TEST_GITEA_SMEEURL }}"
98+
bash -x ./hack/dev/kind/install.sh
99+
100+
- name: Create PAC github-app-secret
116101
env:
117-
TEST_PROVIDER: ${{ matrix.provider }}
118102
PAC_GITHUB_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
119103
PAC_GITHUB_APPLICATION_ID: ${{ vars.APPLICATION_ID }}
120104
PAC_WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
121-
PAC_SMEE_URL: ${{ secrets.PYSMEE_URL }}
105+
run: |
106+
./hack/gh-workflow-ci.sh create_pac_github_app_secret
107+
108+
- name: Create second Github APP Controller on GHE
109+
env:
122110
TEST_GITHUB_SECOND_SMEE_URL: ${{ secrets.TEST_GITHUB_SECOND_SMEE_URL }}
123111
TEST_GITHUB_SECOND_PRIVATE_KEY: ${{ secrets.TEST_GITHUB_SECOND_PRIVATE_KEY }}
124112
TEST_GITHUB_SECOND_WEBHOOK_SECRET: ${{ secrets.TEST_GITHUB_SECOND_WEBHOOK_SECRET }}
125-
TEST_GITHUB_SECOND_APPLICATION_ID: ${{ vars.TEST_GITHUB_SECOND_APPLICATION_ID }}
126113
run: |
127-
./hack/gh-workflow-ci.sh startpaac
114+
./hack/gh-workflow-ci.sh create_second_github_app_controller_on_ghe
128115
129116
- name: Run E2E Tests
130117
if: ${{ github.event_name != 'schedule' || github.event.label.name == 'e2e' || contains(github.event.pull_request.labels.*.name, 'e2e') }}

hack/gh-workflow-ci.sh

Lines changed: 70 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,70 @@
33
# Helper script for GitHub Actions CI, used from e2e tests.
44
set -exufo pipefail
55

6+
create_pac_github_app_secret() {
7+
# Read from environment variables instead of arguments
8+
local app_private_key="${PAC_GITHUB_PRIVATE_KEY}"
9+
local application_id="${PAC_GITHUB_APPLICATION_ID}"
10+
local webhook_secret="${PAC_WEBHOOK_SECRET}"
11+
12+
kubectl delete secret -n pipelines-as-code pipelines-as-code-secret || true
13+
kubectl -n pipelines-as-code create secret generic pipelines-as-code-secret \
14+
--from-literal github-private-key="${app_private_key}" \
15+
--from-literal github-application-id="${application_id}" \
16+
--from-literal webhook.secret="${webhook_secret}"
17+
kubectl patch configmap -n pipelines-as-code -p "{\"data\":{\"bitbucket-cloud-check-source-ip\": \"false\"}}" \
18+
--type merge pipelines-as-code
19+
20+
# restart controller
21+
kubectl -n pipelines-as-code delete pod -l app.kubernetes.io/name=controller
22+
23+
echo -n "Waiting for controller to restart"
24+
i=0
25+
while true; do
26+
[[ ${i} == 120 ]] && exit 1
27+
ep=$(kubectl get ep -n pipelines-as-code pipelines-as-code-controller -o jsonpath='{.subsets[*].addresses[*].ip}')
28+
[[ -n ${ep} ]] && break
29+
sleep 2
30+
echo -n "."
31+
i=$((i + 1))
32+
done
33+
echo
34+
}
35+
36+
create_second_github_app_controller_on_ghe() {
37+
# Read from environment variables instead of arguments
38+
local test_github_second_smee_url="${TEST_GITHUB_SECOND_SMEE_URL}"
39+
local test_github_second_private_key="${TEST_GITHUB_SECOND_PRIVATE_KEY}"
40+
local test_github_second_webhook_secret="${TEST_GITHUB_SECOND_WEBHOOK_SECRET}"
41+
42+
if [[ -n "$(type -p apt)" ]]; then
43+
sudo apt update &&
44+
sudo apt install -y python3-yaml
45+
elif [[ -n "$(type -p dnf)" ]]; then
46+
dnf install -y python3-pyyaml
47+
else
48+
# TODO(chmouel): setup a virtualenvironment instead
49+
python3 -m pip install --break-system-packages PyYAML
50+
fi
51+
52+
./hack/second-controller.py \
53+
--controller-image="ko" \
54+
--smee-url="${test_github_second_smee_url}" \
55+
--ingress-domain="paac-127-0-0-1.nip.io" \
56+
--namespace="pipelines-as-code" \
57+
ghe | tee /tmp/generated.yaml
58+
59+
ko apply -f /tmp/generated.yaml
60+
kubectl delete secret -n pipelines-as-code ghe-secret || true
61+
kubectl -n pipelines-as-code create secret generic ghe-secret \
62+
--from-literal github-private-key="${test_github_second_private_key}" \
63+
--from-literal github-application-id="2" \
64+
--from-literal webhook.secret="${test_github_second_webhook_secret}"
65+
sed "s/name: pipelines-as-code/name: ghe-configmap/" <config/302-pac-configmap.yaml | kubectl apply -n pipelines-as-code -f-
66+
kubectl patch configmap -n pipelines-as-code ghe-configmap -p '{"data":{"application-name": "Pipelines as Code GHE"}}'
67+
kubectl -n pipelines-as-code delete pod -l app.kubernetes.io/name=ghe-controller
68+
}
69+
670
get_tests() {
771
target=$1
872
mapfile -t testfiles < <(find test/ -maxdepth 1 -name '*.go')
@@ -27,50 +91,6 @@ run_e2e_tests() {
2791
make test-e2e GO_TEST_FLAGS="-run \"$(echo "${tests[*]}" | sed 's/ /|/g')\""
2892
}
2993

30-
startpaac() {
31-
echo "**********************************************************************"
32-
echo " Installing startpaac"
33-
echo "**********************************************************************"
34-
[[ -d ~/startpaac ]] ||
35-
git clone --depth=1 https://github.com/chmouel/startpaac ~/startpaac
36-
37-
mkdir -p ~/second ~/pass $HOME/.config/startpaac
38-
39-
cat <<EOF >$HOME/.config/startpaac/config
40-
PAC_DIR=$HOME/work/pipelines-as-code/pipelines-as-code/
41-
PAC_SECRET_FOLDER=$HOME/pass
42-
PAC_SECOND_SECRET_FOLDER=${HOME}/second
43-
TARGET_HOST=local
44-
EOF
45-
46-
echo "${PAC_GITHUB_PRIVATE_KEY}" >~/pass/github-private-key
47-
echo "${PAC_GITHUB_APPLICATION_ID}" >~/pass/github-application-id
48-
echo "${PAC_WEBHOOK_SECRET}" >~/pass/webhook.secret
49-
echo "${PAC_SMEE_URL}" >~/pass/smee
50-
51-
echo "${TEST_GITHUB_SECOND_PRIVATE_KEY}" >~/second/github-private-key
52-
echo "${TEST_GITHUB_SECOND_APPLICATION_ID}" >~/second/github-application-id
53-
echo "${TEST_GITHUB_SECOND_WEBHOOK_SECRET}" >~/second/webhook.secret
54-
echo "${TEST_GITHUB_SECOND_SMEE_URL}" >~/second/smee
55-
56-
go install github.com/jsha/minica@latest
57-
58-
(
59-
cd ${HOME}/startpaac
60-
if [[ ${TEST_PROVIDER} == "providers" ]]; then
61-
./startpaac --all-github-second-no-forgejo
62-
else
63-
./startpaac --all
64-
fi
65-
)
66-
67-
echo "**********************************************************************"
68-
echo "Copying minica CA certs to /usr/local/share/ca-certificates/minica.crt"
69-
echo "**********************************************************************"
70-
sudo cp -v /tmp/certs/minica.pem /usr/local/share/ca-certificates/minica.crt
71-
sudo update-ca-certificates
72-
}
73-
7494
collect_logs() {
7595
# Read from environment variables
7696
local test_gitea_smee_url="${TEST_GITEA_SMEEURL}"
@@ -137,23 +157,22 @@ help() {
137157
collect_logs
138158
Collect logs from the cluster
139159
Required env vars: TEST_GITEA_SMEEURL, TEST_GITHUB_SECOND_SMEE_URL
140-
141-
startpaac
142-
Install startpaac and setup the config
143-
Required env vars: PAC_GITHUB_PRIVATE_KEY, PAC_GITHUB_APPLICATION_ID, PAC_WEBHOOK_SECRET, PAC_SMEE_URL
144160
EOF
145161
}
146162

147163
case ${1-""} in
164+
create_pac_github_app_secret)
165+
create_pac_github_app_secret
166+
;;
167+
create_second_github_app_controller_on_ghe)
168+
create_second_github_app_controller_on_ghe
169+
;;
148170
run_e2e_tests)
149171
run_e2e_tests
150172
;;
151173
collect_logs)
152174
collect_logs
153175
;;
154-
startpaac)
155-
startpaac
156-
;;
157176
help)
158177
help
159178
exit 0

test/pkg/gitea/test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ func TestPR(t *testing.T, topts *TestOpts) (context.Context, func()) {
128128
hookURL := os.Getenv("TEST_GITEA_SMEEURL")
129129
topts.InternalGiteaURL = os.Getenv("TEST_GITEA_INTERNAL_URL")
130130
if topts.InternalGiteaURL == "" {
131-
// default to internal forgejo as deployed by the helm
132-
topts.InternalGiteaURL = "http://forgejo-http.forgejo.svc.cluster.local:3000"
131+
topts.InternalGiteaURL = "http://gitea.gitea:3000"
133132
}
134133
if topts.ExtraArgs == nil {
135134
topts.ExtraArgs = map[string]string{}

0 commit comments

Comments
 (0)