Skip to content

Commit

Permalink
Merge pull request #26 from trocco-io/feature/embulk-v0.1x
Browse files Browse the repository at this point in the history
Implementation for embulk v0.1x
  • Loading branch information
NamedPython authored Dec 23, 2024
2 parents 586b8bd + 8c9a60f commit 598dbf8
Show file tree
Hide file tree
Showing 21 changed files with 695 additions and 354 deletions.
49 changes: 31 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,57 @@
name: main

on:
workflow_dispatch:
push:
branches:
- "master"
- 'master'
tags:
- "*"
- '*'
pull_request:
branches:
- "master"
- 'master'
types: [opened, synchronize]
pull_request_target:
branches:
- 'master'
types: [labeled]

jobs:
main:
test:
name: test
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
if: >
${{
github.event_name == 'pull_request' ||
(github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'safe to test')) ||
startsWith(github.ref, 'refs/tags/')
}}
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: lint
# Run ./gradlew spotlessApply when failing on this step.
run: ./gradlew spotlessCheck
- run: ./gradlew test
- name: Show Current Version
run: ./gradlew printVersion
- name: Build Gem & Put it into './build/gems/' Directory
run: ./gradlew gem
- name: Set up JRuby
- name: Test
run: ./gradlew test
build:
name: Build + Publish
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
needs: [ test ]
if: ${{ github.event_name == 'workflow_dispatch' || contains(github.ref, 'refs/tags/') }}
steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.7
uses: ruby/setup-ruby@v1
with:
ruby-version: jruby
ruby-version: 2.7
- name: push gem
uses: trocco-io/push-gem-to-gpr-action@v1
with:
language: java
gem-path: "./pkg/*.gem"
gem-path: "./build/gems/*.gem"
github-token: "${{ secrets.GITHUB_TOKEN }}"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ build/
/.metadata/
.classpath
.project
example.yml
example.yml
example/test.yml
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,15 @@ in:
```
$ ./gradlew gem # -t to watch change of files and rebuild continuously
```

## TEST

```
$ ./gradlew test
```

If you want to test using the actual API, create a file referring to example/test.yml.example and set the EMBULK_INPUT_FACEBOOK_ADS_INSIGTHS_TEST_CONFIG environment variable.

```
$ EMBULK_INPUT_FACEBOOK_ADS_INSIGTHS_TEST_CONFIG="example/test.yml" ./gradlew test # Create example/test.yml based on example/test.yml.example
```
119 changes: 48 additions & 71 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
plugins {
id "com.github.jruby-gradle.base" version "1.5.0"
id "org.embulk.embulk-plugins" version "0.5.5"
id "com.palantir.git-version" version "0.13.0"
id "com.diffplug.spotless" version "5.15.0"
id "com.adarshr.test-logger" version "3.0.0"
id "java"
id "checkstyle"
}
import com.github.jrubygradle.JRubyExec

repositories {
mavenCentral()
jcenter()
}

configurations {
provided
}

group = "io.trocco"
description = "Facebook Ads Insights input plugin for Embulk."

version = {
def vd = versionDetails()
if (vd.commitDistance == 0 && vd.lastTag ==~ /^v[0-9]+\.[0-9]+\.[0-9]+(\.[a-zA-Z0-9]+)?/) {
Expand All @@ -27,84 +31,48 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile "org.embulk:embulk-core:0.9.17"
provided "org.embulk:embulk-core:0.9.17"
compile group: "com.facebook.business.sdk", name: "facebook-java-business-sdk", version: "19.0.3"
// compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
testCompile "junit:junit:4.+"
}
def embulkVersion = "0.10.42"
compileOnly("org.embulk:embulk-api:${embulkVersion}")
compileOnly("org.embulk:embulk-spi:${embulkVersion}")

task classpath(type: Copy, dependsOn: ["jar"]) {
doFirst { file("classpath").deleteDir() }
from (configurations.runtime - configurations.provided + files(jar.archivePath))
into "classpath"
}
clean { delete "classpath" }

checkstyle {
configFile = file("${project.rootDir}/config/checkstyle/checkstyle.xml")
toolVersion = '6.14.1'
}
checkstyleMain {
configFile = file("${project.rootDir}/config/checkstyle/default.xml")
ignoreFailures = true
}
checkstyleTest {
configFile = file("${project.rootDir}/config/checkstyle/default.xml")
ignoreFailures = true
}
task checkstyle(type: Checkstyle) {
classpath = sourceSets.main.output + sourceSets.test.output
source = sourceSets.main.allJava + sourceSets.test.allJava
}
compile "org.embulk:embulk-util-config:0.3.4"
compile "org.embulk:embulk-util-timestamp:0.3.0"
compile "org.embulk:embulk-util-json:0.3.0"

task gem(type: JRubyExec, dependsOn: ["gemspec", "classpath"]) {
jrubyArgs "-S"
script "gem"
scriptArgs "build", "${project.name}.gemspec"
doLast { ant.move(file: "${project.name}-${project.version}.gem", todir: "pkg") }
compile group: "com.facebook.business.sdk", name: "facebook-java-business-sdk", version: "19.0.3"
// compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
testImplementation "junit:junit:4.+"
testImplementation "org.mockito:mockito-core:3.11.2"
testImplementation "org.embulk:embulk-api:${embulkVersion}"
testImplementation "org.embulk:embulk-spi:${embulkVersion}"
testImplementation "org.embulk:embulk-core:${embulkVersion}"
testImplementation "org.embulk:embulk-deps:${embulkVersion}"
testImplementation "org.embulk:embulk-junit4:${embulkVersion}"
testImplementation "org.embulk:embulk-output-file:${embulkVersion}"
testImplementation "org.embulk:embulk-formatter-csv:${embulkVersion}"
}

task gemPush(type: JRubyExec, dependsOn: ["gem"]) {
jrubyArgs "-S"
script "gem"
scriptArgs "push", "pkg/${project.name}-${project.version}.gem"
embulkPlugin {
mainClass = "org.embulk.input.facebook_ads_insights.FacebookAdsInsightsInputPlugin"
category = "input"
type = "facebook_ads_insights"
}

task "package"(dependsOn: ["gemspec", "classpath"]) {
doLast {
println "> Build succeeded."
println "> You can run embulk with '-L ${file(".").absolutePath}' argument."
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
options.encoding = "UTF-8"
}

task gemspec {
ext.gemspecFile = file("${project.name}.gemspec")
inputs.file "build.gradle"
outputs.file gemspecFile
doLast { gemspecFile.write($/
Gem::Specification.new do |spec|
spec.name = "${project.name}"
spec.version = "${project.version}"
spec.authors = ["naotaka nakane"]
spec.summary = %[Facebook Ads Insights input plugin for Embulk]
spec.description = %[Loads records from Facebook Ads Insights.]
spec.email = ["n.nakane0219@gmail.com"]
spec.licenses = ["MIT"]
spec.homepage = "https://github.com/trocco-io/embulk-input-facebook_ads_insights"

spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
spec.test_files = spec.files.grep(%r"^(test|spec)/")
spec.require_paths = ["lib"]
clean { delete "classpath" }

#spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION']
spec.add_development_dependency 'bundler', ['~> 1.0']
spec.add_development_dependency 'rake', ['~> 12.0']
end
/$)
}
gem {
from("LICENSE.txt")
authors = ["naotaka nakane"]
email = ["n.nakane0219@gmail.com"]
summary = "Facebook Ads Insights input plugin for Embulk."
homepage = "https://github.com/trocco-io/embulk-input-facebook_ads_insights"
licenses = [ "MIT" ]
}
clean { delete "${project.name}.gemspec" }

sourceSets.all {
configurations.getByName(runtimeClasspathConfigurationName) {
Expand All @@ -117,3 +85,12 @@ sourceSets.all {
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
}
}

spotless {
java {
importOrder()
removeUnusedImports()
// googleJavaFormat()
toggleOffOn()
}
}
128 changes: 0 additions & 128 deletions config/checkstyle/checkstyle.xml

This file was deleted.

Loading

0 comments on commit 598dbf8

Please sign in to comment.