【问题标题】:Why doesn't github actions CI compile with same jdk?为什么 github 操作 CI 不使用相同的 jdk 编译?
【发布时间】:2021-03-12 15:02:06
【问题描述】:

我有在 JDK 13.0.1 上成功本地构建的 Scala 代码。

s.getValue().stripTrailing()  // s.getValue() returns String

当此代码由 github 操作构建时,我收到此错误:

Error:  -- [E008] Not Found Error: /github/workspace/core/src/main/scala/co.blocke.scalajack/yaml/YamlParser.scala:45:96 
Error:  45 |          case "|" | ">"                           => s.getValue().stripTrailing()
Error:     |                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
Error:     |                           value stripTrailing is not a member of String

我的动作文件是:

name: Package Build
# This workflow is triggered on pushes to the repository.
on: 
  push:
    branches-ignore:
      - "feature/*"  # don't run build/test against a feature branch -- no SLA there
      - "master"

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repo
        uses: actions/checkout@v2
      - name: Set up JDK 13
        uses: actions/setup-java@v1
        with:
          java-version: '13.0.1'
      - name: Test
        id: sbt
        uses: lokkju/github-action-sbt@master
        with:
          commands: test

stripTrailing() 是 Oracle 和 OpenJDK 13.x 库中的 String 方法。

【问题讨论】:

    标签: java github-actions


    【解决方案1】:

    github-action-sbt 操作在内部使用 Docker 容器 (source)。您的步骤Set up JDK 13 仅适用于直接在运行器上运行的东西,但不会影响容器。

    解决方案

    {JAVA_VERSION}-{SBT_VERSION}-{SCALA_VERSION} 格式指定标签。请参阅下面的可用版本。

          - name: Test
            id: sbt
            uses: lokkju/github-action-sbt@14-1.3.0-2.10.7
            with:
              commands: test
    

    标签控制初始化图像的 Java、SBT 和 Scala 的版本。 SBT 和 Scala 将自动下载项目设置中指定的其他版本,但如果它们与初始化版本不匹配,则可能需要大量额外的构建时间。

    标签格式为{JAVA_VERSION}-{SBT_VERSION}-{SCALA_VERSION}目前支持的标签有:

    JAVA_VERSIONS=("8" "11" "14")
    SBT_VERSIONS=("0.13.17" "1.1.6" "1.2.8" "1.3.0")
    SCALA_VERSIONS=("2.13.0" "2.12.10" "2.11.12" "2.10.7")
    

    source at time of creation of this post

    source @master

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-25
      • 2020-09-09
      • 2016-05-14
      • 1970-01-01
      • 2021-11-13
      • 2023-02-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多