1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

KotlinコンソールアプリでとりあえずCircleCIを回したい時にAndroid用のテンプレを流用する

Posted at

###この記事について
KotlinでCUIアプリを作成する際にCircleCI用のテンプレを探したのですが見つかりませんでした。なのでAndroid用のテンプレ(https://circleci.com/docs/ja/2.0/language-android/ )を調整してプルリクに対して自動テストを行うようにします。前提としてGradleで管理されていること、JUnit5をテストフレームワークとして使用します。ちなみにgradle.ktsはうまく行かず、調べてみるとうまく行っていない人が多く、辛いのでやめました。

###設定ファイル

build.gradle
plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.3.40'
}

group 'org.your-group-name'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"

    // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
    testCompile "org.junit.jupiter:junit-jupiter-api:5.5.1"
    testCompile "org.junit.jupiter:junit-jupiter-engine:5.5.1"
}

compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

test {
    useJUnitPlatform()
}
config.yml
version: 2
jobs:
  build:
    working_directory: ~/code
    docker:
      - image: circleci/android:api-28-alpha
    environment:
      JVM_OPTS: -Xmx3200m
    steps:
      - checkout
      - restore_cache:
          #key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
          key: jars-{{ checksum "build.gradle" }} #app/build.gradleがないので
      - run:
          name: Download Dependencies
          #command: ./gradlew androidDependencies
          command: ./gradlew dependencies #androidではないので
      - save_cache:
          paths:
            - ~/.gradle
          #key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
          key: jars-{{ checksum "build.gradle" }}
      - run:
          name: Run Tests
          command: ./gradlew test
      #今回はテスト結果を格納する
      - store_artifacts:
          path: build/reports/tests/test/ 
          destination: test_art
      - store_test_results:
          path: build/test-results/

###結果

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?