Giter Club home page Giter Club logo

scalafmt-ci's Introduction

Scalafmt GitHub Action

Runs scalafmt --list on your repository automatically with every push.

Uses scalafmt-native under the hood to keep things small and booting super quick by avoiding the JVM. ๐ŸŽ

Usage

Simply add a step such as the following to your your workflow yml file:

- name: Check for scalafmt conformance
  uses: openlawteam/scalafmt-ci@v2

Example in the full context of a workflow file, with some optional arguments:

name: Check scalafmt on push
on: [push]

jobs:
  scalafmt-lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
        with:
          fetch-depth: 1
      - name: Checking your code to see if u r naughty or nice
        uses: openlawteam/scalafmt-ci@v2
        with:
          args: "--exclude=third_party --list"

Installing with GitHub Marketplace

https://github.com/marketplace/actions/scalafmt-action

(Legacy) HCL Syntax

If you are still using legacy HCL format (from the GitHub Actions Alpha test), you will need to pin to a previous version of this action.

action "lint" {
  uses="openlawteam/scalafmt-ci@v0"
  # optional additional args
  args="--exclude ./vendor"
}

scalafmt-ci's People

Contributors

jentsch avatar mroth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

scalafmt-ci's Issues

Getting error using code snippet from the guide

jobs:
  scalafmt-lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
        with:
          fetch-depth: 1
      - name: Checking your code to see if u r naughty or nice
        uses: openlawteam/scalafmt-ci@v2
        with:
          args: "--exclude=third_party --list"

I have this job step, copied from the documentation. When this runs in my actions pipeline, I see the following error:

Run openlawteam/scalafmt-ci@v2

/usr/bin/docker run --name ccae24c2b974dabafc4cc719a46fff3_ce0a58 --label 290506 --workdir /github/workspace --rm -e "INPUT_ARGS" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/user-auth/user-auth":"/github/workspace" 290506:3ccae24c2b974dabafc4cc719a46fff3  "--exclude=third_party --list"

Exception in thread "main" org.scalafmt.Error$NoMatchingFiles$: No files formatted/tested. Verify include/exclude filters and command line arguments.

Patches should be easier to apply -- patch(1p)

Currently files are generated of the form:

--- /github/workspace/something/foo.scala
+++ /github/workspace/something/foo.scala-formatted
@@ -1541,3 +1541,6 @@
       ),
-      thing(someLongItem, dateLikeItem = LocalDateTime.of(2020, JANUARY, 15,12,0)),
+      thing(
+        someLongItem,
+        dateLikeItem = LocalDateTime.of(2020, JANUARY, 15,12,0)),
+      ),
       thing(item, dateLikeItem = LocalDateTime.of(2020, JANUARY, 15, 12, 0))

It would be better if they were written like this:

--- /github/workspace/something.orig/foo.scala
+++ /github/workspace/something/foo.scala
@@ -1541,3 +1541,6 @@
       ),
-      thing(someLongItem, dateLikeItem = LocalDateTime.of(2020, JANUARY, 15,12,0)),
+      thing(
+        someLongItem,
+        dateLikeItem = LocalDateTime.of(2020, JANUARY, 15,12,0)),
+      ),
       thing(item, dateLikeItem = LocalDateTime.of(2020, JANUARY, 15, 12, 0))

See the following excerpts from patch (1P = Posix):

       If the type of difference is unified context, the patch utility
       shall recognize the following expressions:

       --- filename timestamp
             The patches arose from filename.

       +++ filename timestamp
             The patches should be applied to filename.

Alternatively, you could just ensure that an Index: line is included:

       The patch utility shall recognize the following expression in the
       header information:

       Index: pathname
             The file to be patched is named pathname.

For reference, here's the output from gofmt:

checking gofmt fail...
diff -u ./src/lib/cache/memory/memory.go.orig ./src/lib/cache/memory/memory.go
--- ./src/lib/cache/memory/memory.go.orig 2021-01-26 04:15:30.858660671 +0000
+++ ./src/lib/cache/memory/memory.go 2021-01-26 04:15:30.858660671 +0000
@@ -24,7 +24,7 @@
)

type entry struct {
- data []byte
+ data []byte
expiredAt int64
}

(The actual diff here is a different bug which I may try to file against golang/go at some point.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.