Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kgoldpasv committed Apr 6, 2024
0 parents commit 127613d
Show file tree
Hide file tree
Showing 92 changed files with 9,404 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/wait-for-jenkins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -e

times=15
while ! curl -sSL 'http://localhost:8080/login?from=%2F' 2>&1 \
| grep '<html' >/dev/null; do
echo 'Waiting for the Jenkins'
sleep 10
times=$(($times - 1))

if [ $times -le 0 ]; then
echo 'Time out'
exit 1
fi
done

echo 'The Jenkins is up'
16 changes: 16 additions & 0 deletions .github/workflows/cancel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Cancel

on:
pull_request:
branches: [main]

jobs:
cancel:
name: 'Cancel previous runs'
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: styfle/[email protected]
with:
workflow_id: ci.yml
access_token: ${{ secrets.GITHUB_TOKEN }}
52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI

on:
pull_request:
branches: [main]

jobs:
run-test:
name: 'Run tests'
runs-on: ubuntu-latest

steps:
- name: Git clone
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install JDK
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
cache: 'maven'

- name: Get list of changed files
run: echo "LIST_OF_CHANGED_FILES=$(git diff --name-only origin/$GITHUB_HEAD_REF $(git merge-base origin/$GITHUB_HEAD_REF origin/main) | tr '\n' ';')" >> $GITHUB_ENV

- name: Prepare Jenkins data
run: |
cat ${{ github.workspace }}/jenkins_data/jenkins_backup0* > ${{ github.workspace }}/jenkins_backup.tar
md5sum ${{ github.workspace }}/jenkins_backup.tar
- name: Extract Jenkins data and set permission
run: |
tar -xvf ./jenkins_backup.tar
chmod -R 777 ./jenkins_backup/var/jenkins_home
- name: Docker login
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin

- name: Docker start
run: docker run --rm --detach -p 8080:8080 -v ${{ github.workspace }}/jenkins_backup/var/jenkins_home:/var/jenkins_home jenkins/jenkins:2.440.2-lts-jdk17

- name: Wait for the Jenkins
run: ./.github/wait-for-jenkins.sh

- name: Maven test
run: mvn test
env:
CHROME_OPTIONS: --remote-allow-origins=*;--disable-gpu;--no-sandbox;--disable-dev-shm-usage;--headless=new;--window-size=1920,1080
APP_OPTIONS: host=localhost;port=8080;admin.username=${{ secrets.ADMIN_USERNAME }};admin.password=${{ secrets.ADMIN_PASSWORD }}
CI_RUN: true
43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/*
#.idea/modules.xml
#.idea/jarRepositories.xml
#.idea/compiler.xml
#.idea/libraries/

*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store

### project ###
local.properties
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 RedRover.school

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# JenkinsQA_2024_spring
Binary file added jenkins_data/jenkins_backup00
Binary file not shown.
Binary file added jenkins_data/jenkins_backup01
Binary file not shown.
Binary file added jenkins_data/jenkins_backup02
Binary file not shown.
31 changes: 31 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>school.redrover</groupId>
<artifactId>JenkinsQA_2024_spring</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.8.0</version>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.18.1</version>
</dependency>
</dependencies>
</project>
18 changes: 18 additions & 0 deletions src/test/java/school/redrover/SmokeTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package school.redrover;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.testng.Assert;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;
import school.redrover.runner.BaseTest;

public class SmokeTest extends BaseTest {

@Test
public void testWelcome() {
WebElement welcomeText = getDriver().findElement(By.cssSelector(".empty-state-block > h1"));

Assert.assertEquals(welcomeText.getText(), "Welcome to Jenkins!");
}
}
69 changes: 69 additions & 0 deletions src/test/java/school/redrover/old/AqaGroupBaseTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package school.redrover.old;

import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Ignore;
import school.redrover.runner.BaseTest;

import java.time.Duration;

@Ignore
public abstract class AqaGroupBaseTest extends BaseTest {

private WebDriverWait wait5;
private WebDriverWait wait15;
private WebDriverWait wait25;
private WebDriverWait wait60;

@BeforeMethod
protected void beforeMethod() {
getDriver().manage().window().setSize(new Dimension(1920, 1080));
}

protected WebElement scrollIntoView(WebElement element) {
((JavascriptExecutor) getDriver()).executeScript("arguments[0].scrollIntoView(true);", element);
return element;
}

protected WebDriverWait getWait(int seconds) {
return new WebDriverWait(getDriver(), Duration.ofSeconds(seconds));
}

protected WebDriverWait getWait5() {
if (wait5 == null) {
wait5 = new WebDriverWait(getDriver(), Duration.ofSeconds(5));
}
return wait5;
}

protected WebDriverWait getWait15() {
if (wait15 == null) {
wait15 = new WebDriverWait(getDriver(), Duration.ofSeconds(15));
}
return wait15;
}

protected WebDriverWait getWait25() {
if (wait25 == null) {
wait25 = new WebDriverWait(getDriver(), Duration.ofSeconds(25));
}
return wait25;
}

protected WebDriverWait getWait60() {
if (wait60 == null) {
wait60 = new WebDriverWait(getDriver(), Duration.ofSeconds(60));
}
return wait60;
}

@AfterMethod
protected void afterMethod() {
wait5 = null;
wait15 = null;
wait25 = null;
wait60 = null;
}
}
Loading

0 comments on commit 127613d

Please sign in to comment.