lokkju / github-action-sbt

Github Actions support for building SBT projects
14 stars 11 forks source link

Plugin failure in sbt action #2

Open gzoller opened 4 years ago

gzoller commented 4 years ago

I’m getting failures using sbt-coverage. It’s like the plugins didn’t import when sbt fired. It all works great locally but always fails as a github Action.

My action yml is this:

name: Gregs Scala CI

on: ["push", "pull_request"]

jobs:
  build:
    name: ScalaJack CI
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
      with:
        fetch-depth: 1
    - name: Set up JDK 13
      uses: actions/setup-java@v1
      with:
        java-version: '13.0.1'
    - name: Run tests
      uses: lokkju/github-action-sbt@master
      with:
        commands: '+ test'
    - name: Generate coverage report
      uses: lokkju/github-action-sbt@master
      with:
        commands: 'clean coverage test coverageReport coverageAggregate'
    - name: Coveralls
      uses: coverallsapp/github-action@master
      with:
        github-token: ${{ secrets.COVERALLS_SCALAJACK }}

Here’s a clip of the error:

/github/workspace/build.sbt:3: error: not found: object scoverage import scoverage.ScoverageKeys._

This import is in my build.sbt. My plugins.sbt file lives in my root project directory and specifies the sbt-coverage plugin.

Can the sby action detect and handle sbt plugins?

gzoller commented 4 years ago

Additional data: I got this to work in one way by down-grading my sbt to an older version (was 1.3.4, now 1.2.7). That stopped the above error, but now I'm having trouble getting sbt to run multiple commands. I've tried:

commands: 'clean coverage test coverageAggregate'
and
commands: 'clean' 'coverage' 'test' 'coverageAggregate'

For now I'm doing a separate github-action-sbt task for each one of these. It seems to work, but its pretty slow because the action needs to set up sbt for each invocation of the task.

In both cases sbt fails in the action saying it expects a whitespace between clean and coverage. Am I doing this right?

lokkju commented 4 years ago

Interesting; I need to look at the setup-java actions, as I'm including java in my image - the java version mismatch could be causing the issue.

As for the quoting, there are interesting issues with passing quotes through bash shell. You might try "'clean' 'coverage' 'test' 'coverageAggregate'" or other variations. I've also considered having the commands stuffed into an env var, then building the command line from that to avoid quoting issues.