Skip to content

Commit

Permalink
Feature/general update (#86)
Browse files Browse the repository at this point in the history
* Added handling of 429 error code("Rate limit exceeded")

* bump versions of used libs

(cherry picked from commit 0984aed)

* upgrade to gradle wrapper to v5.5.1

* use openjdk 11 on travis build

* update codacy-coverage-reporter to v. 6.0.0

* update gradle task for codacy

* fix: dependencies updated

* chore: changes for new version

* chore(CI): GitLab Actions added

* chore(CI): GitLab Actions refactored

* chore(CI): GitLab Actions refactored

* chore(CI): GitLab Actions versions updated

* chore(CI): GitLab Action gradle run updated

* chore(CI): GitLab Action gradle run updated

* chore(CI): GitLab Action gradle run updated

* chore(CI): GitLab Action gradle run updated

* chore(CI): GitLab Action gradle run updated

* chore(CI): GitLab Action gradle run updated

* chore(CI): split actions

* chore(CI): split actions

* chore(docs): missing comments added

* fix(CI): invocation fix

* fix(api): refactored

* fix(itest): pass vars

* fix(itest): pass vars

* chore(ci): scan added

* chore(ci): publish only releases

* chore(ci): publish only releases

* fix(codacy): issues solved

* fix(codacy): issues solved

* chore: updated for personal access token

* fix: updated for personal access token

---------

Co-authored-by: Alexander Deyneka <[email protected]>
  • Loading branch information
stritti and Alexander Deyneka authored May 21, 2024
1 parent 01b5d80 commit 3a3e934
Show file tree
Hide file tree
Showing 37 changed files with 945 additions and 703 deletions.
54 changes: 32 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,48 @@ on:
pull_request:
branches: [master]

permissions:
checks: write
pull-requests: write

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 18
uses: actions/setup-java@v2
- uses: actions/checkout@v4
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '18'
distribution: 'temurin'
cache: gradle
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: -Pversion=${{ github.event.release.tag_name || '1.0-SNAPSHOT' }} build
- name: Run Tests
uses: gradle/gradle-build-action@v2
with:
arguments: test integrationTest
- name: Build
run: ./gradlew -Pversion=${{ github.event.release.tag_name || '1.0-SNAPSHOT' }} build -x check
- name: Unit Tests
run: ./gradlew -Pversion=${{ github.event.release.tag_name || '1.0-SNAPSHOT' }} test
- name: Integration Tests
run: ./gradlew -Pversion=${{ github.event.release.tag_name || '1.0-SNAPSHOT' }} integrationTest
env:
AIRTABLE_TOKEN: ${{ vars.AIRTABLE_TOKEN }}
AIRTABLE_BASE: ${{ vars.AIRTABLE_BASE }}
- name: Archive test report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Test report
path: build/reports/tests/test
- name: Publish with Gradle
uses: gradle/gradle-build-action@v2
path: build/reports/tests
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
arguments: -Pversion=${{ github.event.release.tag_name || '1.0-SNAPSHOT' }} publish
files: |
build/test-results/**/*.xml
- name: Publish with Gradle
run: ./gradlew -Pversion=${{ github.event.release.tag_name || '1.0-SNAPSHOT' }} publish
if: github.event_name == 'release'
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: 0 additions & 4 deletions .nb-gradle-properties

This file was deleted.

Binary file not shown.
29 changes: 0 additions & 29 deletions .nb-gradle/profiles/private/aux-config

This file was deleted.

16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ access to Airtable:
Airtable airtable = new Airtable().configure();
```

### API-Key
### Personal Access Token

The API key could be passed to the app in different ways:
The personal access token could be passed to the app in different ways:

* Defining Java property `AIRTABLE_API_KEY` (e.g. `-DAIRTABLE_API_KEY=foo`).
* Defining OS environment variable `AIRTABLE_API_KEY` (e.g. `export AIRTABLE_API_KEY=foo`).
* Defining property file `credentials.properties` in root classpath containing key/value `AIRTABLE_API_KEY=foo`.
* On the other hand the API-key could also be added by using the method `Airtable.configure(String apiKey)`.
* Defining Java property `AIRTABLE_TOKEN` (e.g. `-DAIRTABLE_TOKEN=foo`).
* Defining OS environment variable `AIRTABLE_TOKEN` (e.g. `export AIRTABLE_TOKEN=foo`).
* Defining property file `credentials.properties` in root classpath containing key/value `AIRTABLE_TOKEN=foo`.
* On the other hand the token could also be added by using the method `Airtable.configure(String token)`.

#### How to get API-Key
#### How to get Personal Access Token

See: <https://support.airtable.com/hc/en-us/articles/219046777-How-do-I-get-my-API-key>-
See: <https://support.airtable.com//docs/creating-personal-access-tokens>-

### Proxy Support

Expand Down
136 changes: 64 additions & 72 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
* Permission is hereby granted, free of charge, to any person obtaining a copy
*/


plugins {
id "maven-publish"
id "jacoco"
id 'java-library'
id 'jacoco'
id 'idea'
id 'maven-publish'
id 'com.github.jk1.dependency-license-report' version '2.1'
}

apply plugin: 'java'

/*
* Gets the version name from the latest Git tag
*/
def getVersionName = { ->
try {
def stdout = new ByteArrayOutputStream()
Expand All @@ -28,101 +30,91 @@ def getVersionName = { ->
}
} as Object

group = 'com.sybit.airtable'
//version = getVersionName()
description = """API to access Airtable"""

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
group = 'com.sybit'
version = getVersionName()
description = "Java API for Airtable"

tasks.named("processTestResources") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.deprecation = true
options.compilerArgs += ['-Xlint:deprecation']
// options.compilerArgs += ['-Xlint:unchecked']
sourceCompatibility = 18
}

sourceSets {
integrationTest {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
// You can add other directories to the classpath like this:
//runtimeClasspath += files('src/itest/resources/com/buransky')
// Use "java" if you don't use Scala as a programming language
java.srcDir file('src/itest/java')

java {
srcDir file('src/itest/java')
}
resources {
srcDir file('src/itest/resources')
}
}
// This is just to trick IntelliJ IDEA to add integration test
// resources to classpath when running integration tests from
// the IDE. It's is not a good solution but I don't know about
// a better one.
test {
resources.srcDir file('src/itest/resources')
}

idea {
module {
testSources.from(sourceSets.integrationTest.java.srcDirs)
}
}

repositories {
mavenCentral()
maven { url "https://jitpack.io" }
maven { url "https://dl.bintray.com/typesafe/maven-releases" }
}

configurations {
codacy
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
integrationTestImplementation.extendsFrom implementation, testImplementation
integrationTestRuntimeOnly.extendsFrom runtimeOnly, testRuntimeOnly
}

dependencies {
implementation group: 'com.konghq', name: 'unirest-java', version: '3.14.5'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.14'
implementation group: 'org.json', name: 'json', version: '20230227'
implementation group: 'com.google.code.gson', name: 'gson', version:'2.9.1'
implementation group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.4'
implementation group: 'commons-io', name: 'commons-io', version: '2.11.0'
implementation group: 'org.slf4j', name: 'slf4j-api', version:'2.0.7'

testImplementation group: 'junit', name: 'junit', version:'4.13.2'
testImplementation group: 'com.github.tomakehurst', name: 'wiremock', version:'2.23.2'
testImplementation group: 'org.slf4j', name: 'slf4j-jdk14', version:'2.0.6'

codacy 'com.github.codacy:codacy-coverage-reporter:-SNAPSHOT'
implementation 'com.konghq:unirest-java:3.14.5'
implementation 'org.apache.httpcomponents.client5:httpclient5:5.3.1'
implementation 'org.json:json:20240303'
implementation 'com.google.code.gson:gson:2.9.1'
implementation 'commons-beanutils:commons-beanutils:1.9.4'
implementation 'commons-io:commons-io:2.16.1'
implementation 'org.slf4j:slf4j-api:2.0.7'

testImplementation 'junit:junit:4.13.2'
testImplementation 'com.github.tomakehurst:wiremock:3.0.1'
testImplementation 'org.slf4j:slf4j-jdk14:2.0.6'

testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.8.2'
}


test {
useJUnit()
java {
withSourcesJar()
withJavadocJar()
}

// custom tasks for creating source jar
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
// custom tasks for creating javadoc jar
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
tasks.named('test') {
useJUnitPlatform()
finalizedBy jacocoTestReport
}

// add javadoc/source jar tasks as artifacts
artifacts {
archives sourcesJar, javadocJar
tasks.named('jacocoTestReport') {
reports {
xml.required = true
}
}

//task to send coverage data to Codacy
task sendCoverageToCodacy(type: JavaExec, dependsOn: jacocoTestReport) {
mainClass = "com.codacy.CodacyCoverageReporter"
classpath = configurations.codacy
args = [
"report",
"-l",
"Java",
"-r",
"${buildDir}/reports/jacoco/test/jacocoTestReport.xml"
]
}
tasks.register('integrationTest', Test) {
description = 'Runs integration tests.'
group = 'verification'

testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath

shouldRunAfter test
useJUnitPlatform()

task integrationTest(type: Test) {
// This is not needed, but I like to see which tests have run
testLogging {
events "passed", "skipped", "failed"
}
Expand Down Expand Up @@ -196,4 +188,4 @@ publishing {
}
}

integrationTest.mustRunAfter test
check.dependsOn integrationTest
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Thu Apr 13 17:03:46 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 3a3e934

Please sign in to comment.