Skip to content

Commit

Permalink
chore(CI): GitLab Actions refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
stritti committed May 21, 2024
1 parent 0dee800 commit d6b2098
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 151 deletions.
73 changes: 0 additions & 73 deletions ,github/workflows/check.yaml

This file was deleted.

34 changes: 0 additions & 34 deletions ,github/workflows/publish.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up JDK 18
uses: actions/setup-java@v2
with:
Expand All @@ -40,11 +40,11 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: Test report
path: build/reports/tests/test
path: build/reports/tests/test
- name: Publish with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: -Pversion=${{ github.event.release.tag_name || '1.0-SNAPSHOT' }} publish
env:
ACTION_DEPLOY_USER: ${{ secrets.ACTION_DEPLOY_USER }}
ACTION_DEPLOY_TOKEN: ${{ secrets.ACTION_DEPLOY_TOKEN }}
ACTION_DEPLOY_USER: ${{ secrets.ACTION_DEPLOY_USER }}
ACTION_DEPLOY_TOKEN: ${{ secrets.ACTION_DEPLOY_TOKEN }}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
id 'jacoco'
id 'idea'
id 'maven-publish'
id 'com.github.jk1.dependency-license-report' version '2.1'
id 'com.github.jk1.dependency-license-report' version '2.1'
}

/*
Expand Down Expand Up @@ -40,7 +40,7 @@ tasks.withType(JavaCompile).configureEach {
options.deprecation = true
options.compilerArgs += ['-Xlint:deprecation']
// options.compilerArgs += ['-Xlint:unchecked']
sourceCompatibility = 17
sourceCompatibility = 18
}

sourceSets {
Expand Down
54 changes: 26 additions & 28 deletions src/itest/java/com/sybit/airtable/TableConverterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,66 +23,64 @@
* @author fzr
*/
public class TableConverterTest extends WireMockBaseTest {
//TODO Test für nicht gülitiges bzw String

//TODO Test für nicht gülitiges bzw String

@Test
public void testConvertMovie() throws AirtableException, HttpResponseException {


Table<Movie> movieTable = base.table("Movies", Movie.class);
Movie movie = movieTable.find("recFj9J78MLtiFFMz");
assertNotNull(movie);

assertEquals(movie.getId(),"recFj9J78MLtiFFMz");
assertEquals(movie.getName(),"The Godfather");
assertEquals(movie.getPhotos().size(),2);
assertEquals(movie.getDirector().size(),1);
assertEquals(movie.getActors().size(),2);
assertEquals(movie.getGenre().size(),1);
//TODO Test für Datum

}

@Test
public void testConvertAttachement() throws AirtableException, HttpResponseException {


Table<Movie> movieTable = base.table("Movies", Movie.class);
Movie movie = movieTable.find("recFj9J78MLtiFFMz");
assertNotNull(movie);
assertEquals(movie.getPhotos().size(),2);

assertEquals(2, movie.getPhotos().size());

Attachment photo1 = movie.getPhotos().get(0);
assertNotNull(photo1);
Attachment photo2 = movie.getPhotos().get(0);
assertNotNull(photo2);

assertEquals(photo1.getId(),"attk3WY5B28GVcFGU");
assertEquals(photo1.getUrl(),"https://dl.airtable.com/9UhUUeAtSym1PzBdA0q0_AlPacinoandMarlonBrando.jpg");
assertEquals(photo1.getFilename(),"AlPacinoandMarlonBrando.jpg");
assertEquals(photo1.getSize(),35698,0);
assertEquals(photo1.getType(),"image/jpeg");
assertEquals(photo1.getThumbnails().size(),2);


assertEquals("attk3WY5B28GVcFGU",photo1.getId());
assertEquals("https://dl.airtable.com/9UhUUeAtSym1PzBdA0q0_AlPacinoandMarlonBrando.jpg",photo1.getUrl());
assertEquals("AlPacinoandMarlonBrando.jpg",photo1.getFilename());
assertEquals(35698, photo1.getSize(),0);
assertEquals("image/jpeg",photo1.getType());
assertEquals(2, photo1.getThumbnails().size());
}

@Test
public void testConvertThumbnails() throws AirtableException, HttpResponseException {

Table<Movie> movieTable = base.table("Movies", Movie.class);
Movie movie = movieTable.find("recFj9J78MLtiFFMz");
assertNotNull(movie);

assertEquals(movie.getPhotos().get(0).getThumbnails().size(),2);
assertEquals(movie.getPhotos().get(1).getThumbnails().size(),2);
Map<String, Thumbnail> thumbnails = movie.getPhotos().get(1).getThumbnails();
Thumbnail thumb = thumbnails.get("small");
assertEquals(thumb.getUrl(),"https://dl.airtable.com/rlQ8MyQ4RuqN7rT03ALq_small_The%20Godfather%20poster.jpg");
assertEquals(thumb.getHeight(),36.0, 0);
assertEquals(thumb.getWidth(),24.0, 0);

assertEquals("https://dl.airtable.com/rlQ8MyQ4RuqN7rT03ALq_small_The%20Godfather%20poster.jpg",thumb.getUrl());
assertEquals(36.0, thumb.getHeight(), 0);
assertEquals(24.0, thumb.getWidth(), 0);
}

}
20 changes: 16 additions & 4 deletions src/itest/java/com/sybit/airtable/movies/Actor.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import com.google.gson.annotations.SerializedName;
import com.sybit.airtable.vo.Attachment;

import java.util.Date;
import java.util.List;

public class Actor {
Expand All @@ -22,8 +24,11 @@ public class Actor {
private String biography;
@SerializedName("Filmography")
private String[] filmography;



@SerializedName("createdTime")
private Date createdTime;



public String getId() {
return id;
Expand Down Expand Up @@ -64,6 +69,13 @@ public String getBiography() {
public void setBiography(String Biography) {
this.biography = Biography;
}



public Date getCreatedTime() {
return createdTime;
}

public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
}

31 changes: 31 additions & 0 deletions src/itest/java/com/sybit/airtable/movies/Movie.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ public class Movie {
@SerializedName("Genre")
private List<String> genre;
private Date createdTime;
@SerializedName("seen?")
private String seen;
@SerializedName("personal Notes")
private String personalNotes;

@SerializedName("personal Rating")
private String personalRating;

public String getId() {
return id;
Expand Down Expand Up @@ -94,4 +101,28 @@ public Date getCreatedTime() {
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}

public String getSeen() {
return seen;
}

public void setSeen(String seen) {
this.seen = seen;
}

public String getPersonalRating() {
return personalRating;
}

public void setPersonalRating(String personalRating) {
this.personalRating = personalRating;
}

public String getPersonalNotes() {
return personalNotes;
}

public void setPersonalNotes(String personalNotes) {
this.personalNotes = personalNotes;
}
}
29 changes: 27 additions & 2 deletions src/main/java/com/sybit/airtable/Airtable.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.converters.DateConverter;
import org.apache.commons.beanutils.converters.DateTimeConverter;
import org.apache.http.HttpHost;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -51,7 +52,13 @@ public class Airtable {

private static final Logger LOG = LoggerFactory.getLogger(Airtable.class);

/**
* API-Key for Airtable.
* @deprecated since 0.3, use {@link #AIRTABLE_TOKEN} instead.
*/
@Deprecated(forRemoval = true, since = "0.3")
private static final String AIRTABLE_API_KEY = "AIRTABLE_API_KEY";
private static final String AIRTABLE_TOKEN = "AIRTABLE_TOKEN";
private static final String AIRTABLE_BASE = "AIRTABLE_BASE";

private Configuration config;
Expand Down Expand Up @@ -86,15 +93,33 @@ public Airtable configure() throws AirtableException {
@SuppressWarnings("UnusedReturnValue")
public Airtable configure(ObjectMapper objectMapper) throws AirtableException {

LOG.info("System-Property: Using Java property '-D" + AIRTABLE_API_KEY + "' to get apikey.");
String airtableApi = System.getProperty(AIRTABLE_API_KEY);
if (airtableApi != null) {
LOG.warn("System-Property: Using apikey '{} is deprecated, use '-D {}' instead .", AIRTABLE_API_KEY, AIRTABLE_TOKEN);
} else {
airtableApi = System.getProperty(AIRTABLE_TOKEN);
}

if (airtableApi == null) {
LOG.info("Environment-Variable: Using OS environment '" + AIRTABLE_API_KEY + "' to get apikey.");
airtableApi = System.getenv(AIRTABLE_API_KEY);
if (airtableApi != null) {
LOG.warn("Environment-Variable: Using apikey '{}' is deprecated, use '{}' instead .", AIRTABLE_API_KEY, AIRTABLE_TOKEN);
} else {
airtableApi = System.getenv(AIRTABLE_TOKEN);
}
}
if (airtableApi == null) {
airtableApi = getCredentialProperty(AIRTABLE_API_KEY);
if (airtableApi != null) {
LOG.warn("Credential file: Using '{}' is deprecated, use '{}' instead.", AIRTABLE_API_KEY, AIRTABLE_TOKEN);
} else {
airtableApi = getCredentialProperty(AIRTABLE_TOKEN);
}
}

if(airtableApi == null) {
throw new AirtableException("Missing Airtable API-Token: '" + AIRTABLE_TOKEN + "' not found.");
}

return this.configure(airtableApi, objectMapper);
Expand Down Expand Up @@ -159,7 +184,7 @@ public Airtable configure(Configuration config, ObjectMapper objectMapper) throw

this.config = config;
Unirest.config().reset();

if (config.getTimeout() != null) {
LOG.info("Set connection timeout to: " + config.getTimeout() + "ms.");
Unirest.config().connectTimeout(config.getTimeout().intValue());
Expand Down
Loading

0 comments on commit d6b2098

Please sign in to comment.