Skip to content

Commit

Permalink
Merge pull request #5 from trocco-io/modernize-build-environment-and-…
Browse files Browse the repository at this point in the history
…support-embulk-v0.10-and-v0.11

Modernize build environment and support embulk v0.10/v0.11
  • Loading branch information
NamedPython authored Nov 6, 2024
2 parents 2cd2558 + 91389c0 commit e227f19
Show file tree
Hide file tree
Showing 14 changed files with 250 additions and 387 deletions.
50 changes: 32 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: main

on:
workflow_dispatch:
push:
branches:
- "master"
Expand All @@ -11,34 +10,49 @@ on:
branches:
- "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@v4
- name: Set up JDK 1.8
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 1.8
- name: lint
# Run ./gradlew spotlessApply when failing on this step.
distribution: 'temurin'
java-version: 8
- name: Lint
run: ./gradlew spotlessCheck
- run: ./gradlew test
- name: Show Current Version
run: ./gradlew printVersion
- name: Build Gem & Put it into './pkg/' 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@v4
- 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 }}"
109 changes: 35 additions & 74 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
plugins {
id "com.jfrog.bintray" version "1.1"
id "com.github.jruby-gradle.base" version "1.5.0"
id "java"
id "org.embulk.embulk-plugins" version "0.5.5"
id "com.palantir.git-version" version "0.12.3"
id "com.diffplug.spotless" version "6.13.0"
id "java"
id "checkstyle"
}
import com.github.jrubygradle.JRubyExec

repositories {
mavenCentral()
jcenter()
}

configurations {
provided
}

group = "io.trocco"
description = "An embulk input plugin to load records from Aws Cost Explorer."
version = {
def vd = versionDetails()
if (vd.commitDistance == 0 && vd.lastTag ==~ /^[0-9]+\.[0-9]+\.[0-9]?/) {
if (vd.commitDistance == 0 && vd.lastTag ==~ /^[0-9]+\.[0-9]+\.[0-9]+(\.[a-zA-Z0-9]+)?/) {
vd.lastTag
}
else {
Expand All @@ -30,81 +29,43 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile "org.embulk:embulk-core:0.9.23"
provided "org.embulk:embulk-core:0.9.23"
compile "com.amazonaws:aws-java-sdk-costexplorer:1.12.666"
testCompile "junit:junit:4.+"
}
def embulkVersion = "0.10.43"

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

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
}

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 "org.embulk:embulk-util-config:0.3.4"
compile "org.embulk:embulk-util-timestamp:0.2.2"
compile "com.amazonaws:aws-java-sdk-costexplorer:1.12.666"

task gemPush(type: JRubyExec, dependsOn: ["gem"]) {
jrubyArgs "-S"
script "gem"
scriptArgs "push", "pkg/${project.name}-${project.version}.gem"
testImplementation "junit:junit:4.+"
testImplementation "org.embulk:embulk-core:${embulkVersion}"
testImplementation "org.embulk:embulk-deps:${embulkVersion}"
testImplementation "org.embulk:embulk-junit4:${embulkVersion}"
testImplementation "org.mockito:mockito-core:3.12.4"
}

task "package"(dependsOn: ["gemspec", "classpath"]) {
doLast {
println "> Build succeeded."
println "> You can run embulk with '-L ${file(".").absolutePath}' argument."
}
embulkPlugin {
mainClass = "org.embulk.input.aws_cost_explorer.AwsCostExplorerInputPlugin"
category = "input"
type = "aws_cost_explorer"
}

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 = ["kekekenta"]
spec.summary = %[Aws Cost Explorer input plugin for Embulk]
spec.description = %[Loads records from Aws Cost Explorer.]
spec.email = ["bell.kenta@gmail.com"]
spec.licenses = ["MIT"]
spec.homepage = "https://github.com/trocco-io/embulk-input-aws_cost_explorer"
clean { delete "classpath" }

spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
spec.test_files = spec.files.grep(%r"^(test|spec)/")
spec.require_paths = ["lib"]
gem {
authors = ["kekekenta"]
summary = "Aws Cost Explorer input plugin for Embulk"
email = ["bell.kenta@gmail.com"]
licenses = ["MIT"]
homepage = "https://github.com/trocco-io/embulk-input-aws_cost_explorer"
}

#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
/$)
spotless {
java {
importOrder()
removeUnusedImports()
// TODO: If we apply it, there will be many changes, so we will make it a separate Pull Request.
// googleJavaFormat().aosp()
}
}
clean { delete "${project.name}.gemspec" }
128 changes: 0 additions & 128 deletions config/checkstyle/checkstyle.xml

This file was deleted.

Loading

0 comments on commit e227f19

Please sign in to comment.