Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argo #7

Open
wants to merge 27 commits into
base: circle_ci
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
# Be sure to update the Docker image tag below to openjdk version of your application.
# A list of available CircleCI Docker Convenience Images are available here: https://circleci.com/developer/images/image/cimg/openjdk
docker:
- image: cimg/openjdk:8.0
- image: cimg/openjdk:11.0
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
Expand Down
21 changes: 21 additions & 0 deletions .workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
- name: git-fetch
templateRef:
name: git-toolkit
template: git-fetch
clusterScope: true
arguments:
parameters:
- name: branch
value: "{{ workflow.parameters.branch }}"
- name: repo_name
value: "{{ workflow.parameters.repo_name }}"
- name: unit-tests-run
template: unit-tests
arguments:
parameters:
- name: branch
value: "{{ workflow.parameters.branch }}"
- name: repo_name
value: "{{ workflow.parameters.repo_name }}"
dependencies:
- git-fetch
Empty file added .workflows/parameters.yaml
Empty file.
31 changes: 31 additions & 0 deletions .workflows/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
- name: unit-tests
metadata:
retryStrategy:
limit: 1
retryPolicy: OnError
inputs:
parameters:
- name: repo_name
- name: branch
artifacts:
- name: git
path: /{{inputs.parameters.repo_name}}/{{inputs.parameters.branch}}
gcs:
key: "{{inputs.parameters.repo_name}}/{{inputs.parameters.branch}}/git"
script:
image: gradle:8.0.2-jdk11
env:
- name: REPO
value: "{{inputs.parameters.repo_name}}"
- name: BRANCH
value: "{{inputs.parameters.branch}}"
- name: ROOKOUT_TOKEN
valueFrom:
secretKeyRef:
name: demo-ci-rookout-token
key: demo-ci-rookout-token
workingDir: /{{inputs.parameters.repo_name}}/{{inputs.parameters.branch}}/junit5-migration-gradle
command: [ sh ]
source: |
export JAVA_TOOL_OPTIONS=-javaagent:"/{{inputs.parameters.repo_name}}/{{inputs.parameters.branch}}/junit5-migration-gradle/rook-all.jar" ROOKOUT_CONTROLLER_PORT=443 ROOKOUT_LABELS=env:argo
gradle test -i
2 changes: 2 additions & 0 deletions junit5-migration-gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ repositories {
}

dependencies {
implementation "org.json:json:20230227"

testImplementation(platform("org.junit:junit-bom:5.9.2"))

testImplementation("org.junit.jupiter:junit-jupiter") {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.example.librarybrowser;

import org.json.*;

import java.util.Calendar;
import java.util.Date;

public class Book {

public Book (String rawJson) {
try {
// Parse JSON
this.rawJson = rawJson;
this.json = new JSONObject(rawJson);

// Parse title
this.title = json.get("title").toString();

// Prase date
this.createdString = json.get("created").toString();
this.created = new Date(createdString);
this.yearCreated = created.getYear();

} catch (Throwable t) {
// Some items in the library our corrupted, keep what we have
}
}

public String getTitle() {
return this.title;
}

public int getYearCreated() {
return this.yearCreated;
}

String rawJson = "";
JSONObject json = null;
String title = "no title";
String createdString = "no created string";
Date created = new Date();
int yearCreated = created.getYear();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.example.librarybrowser;

import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

import com.example.librarybrowser.Book;

public class LibraryBrowser {

public LibraryBrowser () {

}

public Book getBookByIsbn(String isbn) throws Exception {
// Build book URL
String url = host + booksPrefix + isbn + jsonSuffix;

// Make an HTTP request
var request = HttpRequest.newBuilder(URI.create(url))
.header("accept", "application/json")
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());

// Return Book from response body
return new Book(response.body());
}

HttpClient client = HttpClient.newHttpClient();

final String extraHeaders = "";
final String host = "https://openlibrary.org/";
final String booksPrefix = "works/";
final String jsonSuffix = ".json";
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.example.librarybrowser;

import org.junit.Test;

import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Date;

import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.*;

public class LibraryBrowserTest {

@Test
public void getBookTest() throws Exception {

// Get Deathly Hallows book
String deathlyHallowsIsbn = "OL82586W";
var lib = new LibraryBrowser();
var book = lib.getBookByIsbn(deathlyHallowsIsbn);

// Test book attributes
assertEquals("Title", "Harry Potter and the Deathly Hallows", book.getTitle());
assertEquals("Year created", book.getYearCreated(), 2009);
}

}

This file was deleted.