Skip to content

Commit 78ef1b2

Browse files
committed
test: adding PR check scripts, github action and login code, updating tests
1 parent 4609b37 commit 78ef1b2

File tree

16 files changed

+360
-451
lines changed

16 files changed

+360
-451
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build and Push Base Test Image
2+
3+
# trigger manually
4+
on: workflow_dispatch
5+
6+
jobs:
7+
base-image:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout 🛎️
11+
uses: actions/checkout@v4
12+
13+
- name: Build and Push Base Image
14+
env:
15+
USERNAME=${{ secrets.QUAY_BOT_USERNAME }}
16+
TOKEN=${{ secrets.QUAY_BOT_TOKEN }}
17+
run: |
18+
cd e2e-tests
19+
podman login -u="$USERNAME" -p="$TOKEN" quay.io
20+
podman build -t quay.io/konflux_ui_qe/konflux-ui-tests-base:latest -f BaseDockerfile
21+
podman push quay.io/konflux_ui_qe/konflux-ui-tests-base:latest

.github/workflows/post-merge.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ jobs:
4343
token: ${{ secrets.CODECOV_TOKEN }}
4444
flags: unittests
4545
fail_ci_if_error: true
46+
47+
# - name: Build E2E Test Image (if tests changed)

.github/workflows/pr-check.yaml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: PR Check Test
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize, reopened, labeled]
6+
7+
jobs:
8+
# check-org-membership:
9+
# runs-on: ubuntu-latest
10+
# outputs:
11+
# org-member: ${{ steps.org-check.outputs.org-member }}
12+
# steps:
13+
# - name: Check if PR author is a member of the organization
14+
# continue-on-error: true
15+
# id: org-check
16+
# run: |
17+
# ORG="${{ github.repository_owner }}"
18+
# AUTHOR="${{ github.event.pull_request.user.login }}"
19+
# if ! gh api /orgs/$ORG/members/$AUTHOR; then
20+
# echo '### ❌ PR author is not a member of GitHub organization' >> $GITHUB_STEP_SUMMARY
21+
# exit 1
22+
# fi
23+
# echo "org-member=true" >> $GITHUB_OUTPUT
24+
# env:
25+
# GITHUB_TOKEN: ${{ secrets.HAC_TEST_GH_TOKEN }}
26+
27+
e2e-test:
28+
# if: ${{ (needs.check-org-membership.outputs.org-member == 'true') || (github.event.pull_request.user.login == 'renovate[bot]') || contains(github.event.pull_request.labels.*.name, 'ok-to-test') }}
29+
# needs: check-org-membership
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Free Disk Space (Ubuntu)
33+
uses: jlumbroso/free-disk-space@main
34+
with:
35+
# this might remove tools that are actually needed,
36+
# if set to "true" but frees about 6 GB
37+
tool-cache: false
38+
docker-images: false
39+
40+
# konflux-ci is cloned to /home/runner/work/konflux-ui/konflux-ui
41+
# as it have to be at home folder to use helm/kind-action@v1 action
42+
- name: Checkout Repository
43+
uses: actions/checkout@v4
44+
with:
45+
repository: 'konflux-ci/konflux-ci'
46+
ref: 'main'
47+
48+
- name: Disable AppArmor
49+
# works around a change in ubuntu 24.04 that restricts Linux namespace access
50+
# for unprivileged users
51+
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
52+
53+
- name: Create k8s Kind Cluster
54+
uses: helm/kind-action@v1
55+
with:
56+
config: kind-config.yaml
57+
58+
- name: Show version information
59+
run: |
60+
kubectl version
61+
kind version
62+
63+
- name: List namespaces
64+
run: |
65+
kubectl get namespace
66+
67+
- name: Deploying Dependencies
68+
run: |
69+
./deploy-deps.sh
70+
71+
- name: List namespaces
72+
run: |
73+
kubectl get namespace
74+
75+
- name: Wait for the dependencies to be ready
76+
run: |
77+
./wait-for-all.sh
78+
79+
- name: WORKAROUND - Set up tkn cli for the following task
80+
uses: tektoncd/actions/setup-tektoncd-cli@main
81+
with:
82+
version: latest
83+
84+
- name: WORKAROUND - Remove clair-scan task from docker-pipeline
85+
run: |
86+
./test/e2e/customize-docker-pipeline.sh
87+
88+
- name: Deploying Konflux
89+
run: |
90+
./deploy-konflux.sh
91+
92+
- name: List namespaces
93+
run: |
94+
kubectl get namespace
95+
96+
- name: Deploy test resources
97+
run: |
98+
./deploy-test-resources.sh
99+
100+
- name: Prepare resources for E2E tests
101+
# Sets secrets, deploys image controller and setup smee.
102+
env:
103+
APP_ID: ${{ secrets.GH_APP_ID }}
104+
APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}
105+
APP_WEBHOOK_SECRET: ${{ secrets.GH_APP_WEBHOOK_SECRET }}
106+
QUAY_ORG: ${{ secrets.QUAY_TEST_ORG }}
107+
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN_TEST }}
108+
SMEE_CHANNEL: ${{ secrets.SMEE_URL }}
109+
run: |
110+
./test/e2e/prepare-e2e.sh
111+
112+
# konflux-ui repo is cloned to /home/runner/work/konflux-ui/konflux-ui/konflux-ui
113+
- name: Checkout Konflux-UI Repository
114+
uses: actions/checkout@v4
115+
with:
116+
ref: "${{ github.event.pull_request.head.sha }}"
117+
path: 'konflux-ui'
118+
119+
- name: Install Konflux-UI and run tests
120+
env:
121+
CYPRESS_GH_TOKEN: ${{ secrets.GH_TOKEN }}
122+
TARGET_BRANCH: ${{ github.base_ref }}
123+
PR_NUMBER: ${{ github.event.number }}
124+
HEAD_SHA: "${{ github.event.pull_request.head.sha }}"
125+
CYPRESS_USERNAME: "${{ secrets.CYPRESS_USERNAME }}"
126+
CYPRESS_PASSWORD: "${{ secrets.CYPRESS_PASSWORD }}"
127+
run: |
128+
./konflux-ui/pr_check.sh
129+
130+
- name: Generate error logs
131+
if: ${{ !cancelled() }}
132+
run: |
133+
.generate-err-logs.sh
134+
cp -r konflux-ui/artifacts logs
135+
136+
- name: Archive logs
137+
if: ${{ !cancelled() }}
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: logs
141+
path: logs

connect_to_local_konflux.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Change configs to connect the UI with locally running Konflux
2+
# Mainly for the PR check but can be used locally too
3+
echo "Patching .env and webpack.dev.config.js"
4+
cat > .env << EOL
5+
AUTH_URL=https://127.0.0.1:9443/
6+
REGISTRATION_URL=https://127.0.0.1:9443/
7+
PROXY_URL=https://127.0.0.1:9443/
8+
PROXY_WEBSOCKET_URL=wss://127.0.0.1:9443
9+
EOL
10+
11+
# regex cheatsheet
12+
# [^ ].* - take everything before the text but leave spaces
13+
# 0, - replace just the first occurence
14+
#
15+
sed -i "s%[^ ].*\/oauth2\/.*%context: (path) => path.includes('/oauth2/') || path.includes('/idp/'),%g" webpack.dev.config.js
16+
sed -i '0,/autoRewrite: false,/s//autoRewrite: true,/' webpack.dev.config.js
17+
sed -i "s/[^ ].*stone-stg-rh01.*/'localhost:9443',/" webpack.dev.config.js
18+
sed -i "s/[^ ].*stone-stg-rh01.*/'localhost:9443',/" webpack.dev.config.js
19+
sed -i "s/[^ ].*DEV_SERVER_PORT}\/oauth2\`,/\`localhost:\${DEV_SERVER_PORT}\`,/" webpack.dev.config.js
20+
21+
echo "Patching done, UI is connected to locally running Konflux."

e2e-tests/BaseContainerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ARG DEFAULT_CHROME_VERSION='131.0.6778.139-1'
2+
3+
FROM cypress/factory:5.1.1
4+
5+
RUN apt update && \
6+
apt install curl jq python3 python3-venv python3-pip xauth skopeo -y
7+
8+
RUN apt install python3-requests python3-click -y

e2e-tests/Dockerfile renamed to e2e-tests/Containerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM quay.io/hacdev/hac-tests:base
1+
FROM quay.io/konflux_ui_qe/konflux-ui-tests-base:latest
22

33
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && \
44
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
55

6-
RUN wget "https://github.com/sigstore/cosign/releases/download/v2.0.0/cosign-linux-amd64" && \
6+
RUN wget "https://github.com/sigstore/cosign/releases/download/v2.4.0/cosign-linux-amd64" && \
77
mv cosign-linux-amd64 /usr/local/bin/cosign && \
88
chmod +x /usr/local/bin/cosign
99

@@ -23,4 +23,4 @@ WORKDIR /tmp/
2323
COPY --chown=node:root --chmod=775 entrypoint.sh /tmp/
2424

2525
ENTRYPOINT ["/tmp/entrypoint.sh"]
26-
CMD [""]
26+
CMD [""]

e2e-tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,4 @@ Job history is available [here](https://prow.ci.openshift.org/job-history/gs/ori
146146
## Reporting issues
147147
If you find a problem with the tests, feel free to open an issue at the [Konflux-UI Jira project](https://issues.redhat.com/projects/KFLUXUI). You can set the label as `qe` to indicate it is a quality problem.
148148

149-
<!-- If you discover a production bug thanks to a test failure, please label any issue created for that bug as `ci-fail`. That way we can see all this automation has actually generated some value. -->
149+
<!-- If you discover a production bug thanks to a test failure, please label any issue created for that bug as `ci-fail`. That way we can see all this automation has actually generated some value. -->

e2e-tests/cypress.config.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,16 @@ export default defineConfig({
133133
});
134134

135135
const defaultValues: { [key: string]: string | boolean } = {
136-
KONFLUX_BASE_URL: 'https://prod.foo.redhat.com:1337/preview/application-pipeline',
137-
USERNAME: '',
138-
PASSWORD: '',
136+
KONFLUX_BASE_URL: 'https://localhost:9443',
137+
USERNAME: '[email protected]',
138+
PASSWORD: 'password',
139139
GH_USERNAME: 'hac-test',
140140
GH_PASSWORD: '',
141141
GH_TOKEN: '',
142142
GH_SETUP_KEY: '',
143143
KUBECONFIG: '~/.kube/appstudio-config',
144144
CLEAN_NAMESPACE: 'false',
145-
PR_CHECK: false,
145+
PR_CHECK: '',
146146
PERIODIC_RUN: false,
147147
resolution: 'high',
148148
REMOVE_APP_ON_FAIL: false,
@@ -161,8 +161,11 @@ export default defineConfig({
161161
}
162162

163163
config.env.HAC_WORKSPACE = config.env.USERNAME.toLowerCase();
164-
config.env.HAC_NAMESPACE = `${config.env.HAC_WORKSPACE}-tenant`;
165-
164+
if (config.env.PR_CHECK === true) {
165+
config.env.HAC_NAMESPACE = `user-ns1`;
166+
} else {
167+
config.env.HAC_NAMESPACE = `${config.env.HAC_WORKSPACE}-tenant`;
168+
}
166169
if (
167170
config.env.PR_CHECK === true &&
168171
config.reporterOptions.reportportalAgentJsCypressReporterOptions

e2e-tests/entrypoint.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ else
1515
fi
1616

1717
npx cypress run $args
18+
echo "Test run finished, dealing with artifacts..."
1819

1920
if [ -d "/e2e/cypress" ]; then
21+
echo "Cypress folder found, copying artifacts"
2022
cp -a /e2e/cypress/* /tmp/artifacts
2123
chmod -R a+rwx /tmp/artifacts
2224
chmod -R a+rwx /e2e/cypress
2325
else
26+
echo "Copying artifacts"
2427
cp -a /tmp/e2e/cypress/* /tmp/artifacts
25-
fi
28+
fi

e2e-tests/support/commands/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ before(() => {
1717
);
1818

1919
if (Cypress.env('PR_CHECK') || Cypress.env('PERIODIC_RUN')) {
20-
Login.prCheckLogin();
20+
Login.localKonfluxLogin();
2121
} else {
2222
Login.login();
2323
}

0 commit comments

Comments
 (0)