Skip to content

Commit

Permalink
test: add login, container files, and PR check automation
Browse files Browse the repository at this point in the history
  • Loading branch information
Katka92 committed Jan 8, 2025
1 parent 69a23b0 commit 32c6e47
Show file tree
Hide file tree
Showing 12 changed files with 281 additions and 442 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/base-test-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build and Push Base Test Image

# trigger manually
on: workflow_dispatch

jobs:
base-image:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Build and Push Base Image
env:
USERNAME=${{ secrets.QUAY_BOT_USERNAME }}
TOKEN=${{ secrets.QUAY_BOT_TOKEN }}
run: |
cd e2e-tests
podman login -u="$USERNAME" -p="$TOKEN" quay.io
podman build -t quay.io/konflux_ui_qe/konflux-ui-tests-base:latest -f BaseDockerfile
podman push quay.io/konflux_ui_qe/konflux-ui-tests-base:latest
154 changes: 154 additions & 0 deletions .github/workflows/pr-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: PR Check Test

on:
pull_request:
branches:
- main

jobs:
check-org-membership:
runs-on: ubuntu-latest
outputs:
org-member: ${{ steps.org-check.outputs.org-member }}
steps:
- name: Check if PR author is a member of the organization
continue-on-error: true
id: org-check
run: |
ORG="${{ github.repository_owner }}"
AUTHOR="${{ github.event.pull_request.user.login }}"
if ! gh api /orgs/$ORG/members/$AUTHOR; then
echo '### ❌ PR author is not a member of GitHub organization' >> $GITHUB_STEP_SUMMARY
exit 1
fi
echo "org-member=true" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.HAC_TEST_GH_TOKEN }}

e2e-test:
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') }}
needs: check-org-membership
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
docker-images: false
- name: Checkout Repository
uses: actions/checkout@v4
with:
repository: 'konflux-ci/konflux-ci'
ref: 'new-ui'

- name: Disable AppArmor
# works around a change in ubuntu 24.04 that restricts Linux namespace access
# for unprivileged users
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0

- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
with:
config: kind-config.yaml

- name: Show version information
run: |
kubectl version
kind version
- name: List namespaces
run: |
kubectl get namespace
- name: Deploying Dependencies
run: |
./deploy-deps.sh
- name: List namespaces
run: |
kubectl get namespace
- name: Wait for the dependencies to be ready
run: |
./wait-for-all.sh
- name: WORKAROUND - Set up tkn cli for the following task
uses: tektoncd/actions/setup-tektoncd-cli@main
with:
version: latest

- name: WORKAROUND - Remove clair-scan task from docker-pipeline
run: |
./test/e2e/customize-docker-pipeline.sh
- name: Deploying Konflux
run: |
./deploy-konflux.sh
- name: List namespaces
run: |
kubectl get namespace
- name: Deploy test resources
run: |
./deploy-test-resources.sh
- name: Prepare resources for E2E tests
# Sets secrets, deploys image controller and setup smee.
env:
APP_ID: ${{ secrets.GH_APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}
APP_WEBHOOK_SECRET: ${{ secrets.GH_APP_WEBHOOK_SECRET }}
QUAY_ORG: ${{ secrets.QUAY_TEST_ORG }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN_TEST }}
SMEE_CHANNEL: ${{ secrets.SMEE_URL }}
run: |
./test/e2e/prepare-e2e.sh
- name: Checkout Konflux-UI Repository
uses: actions/checkout@v4
with:
repository: 'konflux-ci/konflux-ui'

- name: Install konflux-ui
run: |
cd konflux-ui
yarn install
yarn start
- name: Run E2E tests
env:
GH_ORG: ${{ secrets.GH_ORG }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
QUAY_DOCKERCONFIGJSON: ${{ secrets.QUAY_DOCKERCONFIGJSON }}
run: |
TEST_IMAGE="quay.io/konflux_ui_qe/konflux-ui-tests:latest"
#Rebuild test image if Dockerfile from e2e-tests was changed
if ! git diff --exit-code --quiet origin/$ghprbTargetBranch HEAD -- e2e-tests/Dockerfile; then
echo "Dockerfile changes detected, rebuilding test image"
TEST_IMAGE="konflux-ui-tests:pr-${ghprbPullId}"
cd e2e-tests
podman build -t "$TEST_IMAGE" . -f Dockerfile
cd ..
fi
cd konflux-ui/e2e-tests
echo "running tests using image ${TEST_IMAGE}"
# - name: Generate error logs
# if: ${{ !cancelled() }}
# run: |
# ./generate-err-logs.sh

# - name: Archive logs
# if: ${{ !cancelled() }}
# uses: actions/upload-artifact@v4
# with:
# name: logs
# path: logs
8 changes: 8 additions & 0 deletions e2e-tests/BaseContainerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ARG DEFAULT_CHROME_VERSION='131.0.6778.139-1'

FROM cypress/factory:5.1.1

RUN apt update && \
apt install curl jq python3 python3-venv python3-pip xauth skopeo -y

RUN apt install python3-requests python3-click -y
4 changes: 2 additions & 2 deletions e2e-tests/Dockerfile → e2e-tests/Containerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM quay.io/hacdev/hac-tests:base
FROM quay.io/konflux_ui_qe/konflux-ui-tests-base:latest

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

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

Expand Down
8 changes: 4 additions & 4 deletions e2e-tests/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@ export default defineConfig({
});

const defaultValues: { [key: string]: string | boolean } = {
KONFLUX_BASE_URL: 'https://prod.foo.redhat.com:1337/preview/application-pipeline',
USERNAME: '',
PASSWORD: '',
KONFLUX_BASE_URL: 'https://localhost:9443',
USERNAME: '[email protected]',
PASSWORD: 'password',
GH_USERNAME: 'hac-test',
GH_PASSWORD: '',
GH_TOKEN: '',
GH_SETUP_KEY: '',
KUBECONFIG: '~/.kube/appstudio-config',
CLEAN_NAMESPACE: 'false',
PR_CHECK: false,
PR_CHECK: '',
PERIODIC_RUN: false,
resolution: 'high',
REMOVE_APP_ON_FAIL: false,
Expand Down
5 changes: 4 additions & 1 deletion e2e-tests/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ else
fi

npx cypress run $args
echo "Test run finished, dealing with artifacts..."

if [ -d "/e2e/cypress" ]; then
echo "Cypress folder found, copying artifacts"
cp -a /e2e/cypress/* /tmp/artifacts
chmod -R a+rwx /tmp/artifacts
chmod -R a+rwx /e2e/cypress
else
echo "Copying artifacts"
cp -a /tmp/e2e/cypress/* /tmp/artifacts
fi
fi
2 changes: 1 addition & 1 deletion e2e-tests/support/commands/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ before(() => {
);

if (Cypress.env('PR_CHECK') || Cypress.env('PERIODIC_RUN')) {
Login.prCheckLogin();
Login.localKonfluxLogin();
} else {
Login.login();
}
Expand Down
20 changes: 10 additions & 10 deletions e2e-tests/support/pageObjects/global-po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ export const alertTitle = '.pf-v5-c-alert__title';

export const consentButton = '[id="truste-consent-button"]';

export const loginPO = {
usernameForm: '.pf-c-login__main',
username: '#rh-username-verification-form',
nextButton: '#login-show-step2',
passwordForm: '#login-show-step2',
password: '#rh-password-verification-form',
loginButton: '#rh-password-verification-submit-button',
export const stageLoginPO = {
username: '#username',
password: '#password',
loginButton: '#submit',
dex: `button[type="submit"]`,
loginWithSso: `a[title="Log in with redhat-sso"]`,
};

export const kcLoginPO = {
username: '#username',
export const localKonfluxLoginPO = {
username: '#login',
password: '#password',
loginButton: '#kc-login',
loginButton: '#submit-login',
dex: `button[type="submit"]`,
};

export const waits = {
Expand Down
6 changes: 1 addition & 5 deletions e2e-tests/tests/basic-happy-path.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,16 @@ import { UIhelper } from '../utils/UIhelper';

describe('Basic Happy Path', () => {
const applicationName = Common.generateAppName();
// const applicationName = "test-app-173261349";
const applicationDetailPage = new ApplicationDetailPage();
const integrationTestsTab = new IntegrationTestsTabPage();
const componentPage = new ComponentPage();

const sourceOwner = 'hac-test';
const sourceRepo = 'devfile-sample-code-with-quarkus';
const repoName = Common.generateAppName(sourceRepo);
// const repoName = "java-quarkus-173261349"
const repoOwner = 'redhat-hac-qe';
const publicRepo = `https://github.com/${repoOwner}/${repoName}`;
// const publicRepo = 'https://github.com/redhat-hac-qe/devfile-sample-code-with-quarkus-173218691'
const componentName: string = Common.generateAppName('java-quarkus');
// const componentName = "java-quarkus-173261349"
const piplinerunlogsTasks = ['init', 'clone-repository', 'build-container', 'show-sbom'];
const quarkusDeplomentBody = 'Congratulations, you have created a new Quarkus cloud application';
// this is default option and should be the fastest one
Expand Down Expand Up @@ -194,7 +190,7 @@ describe('Basic Happy Path', () => {
ComponentsTabPage.openComponent(componentName);
});

it('Verify deployed image exists', () => {
it.skip('Verify deployed image exists', () => {
ComponentDetailsPage.checkBuildImage();
});
});
Expand Down
3 changes: 2 additions & 1 deletion e2e-tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"cypress",
"node",
"cypress-axe"
]
],
"baseUrl": "https://localhost:8080"
},
"include": [
"./**/*.ts"
Expand Down
22 changes: 12 additions & 10 deletions e2e-tests/utils/Login.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NavItem, pageTitles } from '../support/constants/PageTitle';
import { loginPO, kcLoginPO } from '../support/pageObjects/global-po';
import { localKonfluxLoginPO, stageLoginPO } from '../support/pageObjects/global-po';
import { GetStartedPage } from '../support/pages/GetStartedPage';
import { Common } from './Common';

Expand All @@ -9,22 +9,24 @@ export class Login {
password: string = Cypress.env('PASSWORD'),
) {
cy.visit(Cypress.env('KONFLUX_BASE_URL'));
// cy.get(loginPO.usernameForm);
// cy.get(loginPO.username).find('[type="text"]').type(username);
// cy.get(loginPO.nextButton).click();
// cy.get(loginPO.password).find('[type="password"]').type(password, { log: false });
// cy.get(loginPO.loginButton).click();
cy.get(stageLoginPO.dex).should('be.visible').click();
// disabling as we don't have testing account on stage, manual log in is needed
// cy.get(stageLoginPO.loginWithSso).click();
// cy.get(stageLoginPO.username).type(username);
// cy.get(stageLoginPO.password).type(password, { log: false });
// cy.get(stageLoginPO.loginButton).click();
this.waitForApps();
}

static prCheckLogin(
static localKonfluxLogin(
username: string = Cypress.env('USERNAME'),
password: string = Cypress.env('PASSWORD'),
) {
cy.visit(Cypress.env('KONFLUX_BASE_URL'));
// cy.get(kcLoginPO.username).type(username);
// cy.get(kcLoginPO.password).type(password, { log: false });
// cy.get(kcLoginPO.loginButton).click();
cy.get(localKonfluxLoginPO.dex).should('be.visible').click();
cy.get(localKonfluxLoginPO.username).type(username);
cy.get(localKonfluxLoginPO.password).type(password, { log: false });
cy.get(localKonfluxLoginPO.loginButton).click();
this.waitForApps();
}

Expand Down
Loading

0 comments on commit 32c6e47

Please sign in to comment.