Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 77 additions & 12 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,80 @@ on: [push]

jobs:
eslint:
name: runner / eslint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "20"
- run: npm i --force
- name: 'Run reviewdog'
uses: reviewdog/action-eslint@v1
with:
reporter: github-check
name: runner / eslint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2

- uses: actions/setup-node@v2
with:
node-version: 19

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0.0'
bundler-cache: true

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'

- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-

- name: Building gitdiff
run: |
mvn install -f gitdiff

- name: Running gitdiff
run: java -jar gitdiff/target/gitdiff-0.1.jar > gitdiff/gitdiff.yaml

- name: Install npm dependencies
run: npm i --force # OR: yarn

- name: Running eslint
run: npx eslint $(git diff --name-only HEAD^ | grep -E '\.(ts|tsx)$' | xargs) --format json > eslinted.json || true

- name: Running filter
run: ruby gitdiff/filter_diff.rb gitdiff/gitdiff.yaml eslinted.json > filtered.json

- uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest

- name: Running reviewdog
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cat filtered.json | reviewdog -f=rdjsonl -reporter=github-check
# github-pr-review

# - name: Annotate
# uses: actions/annotations

# # - name: Adding annotations

# - name: Install dependencies
# run: npm i --force # OR: yarn

# - name: Install other deps
# run: npm install --force --save-dev eslint-plugin-n@latest

# - name: Run eslint on changed files
# uses: tj-actions/eslint-changed-files@v20
# with:
# config_path: ".eslintrc.yml"
# fail_on_error: false
# file_extensions: |
# **/*.ts
# **/*.tsx
15 changes: 15 additions & 0 deletions gitdiff/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Thumbs.db
.DS_Store
.gradle
build/
target/
out/
.micronaut/
.idea
*.iml
*.ipr
*.iws
.project
.settings
.classpath
.factorypath
34 changes: 34 additions & 0 deletions gitdiff/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
image: eclipse-temurin:17
variables:
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
build:
stage: build
script: ./mvnw $MAVEN_CLI_OPTS compile
cache:
key: "$CI_COMMIT_REF_NAME"
policy: push
paths:
- target
- .mvn
test:
stage: test
script: ./mvnw $MAVEN_CLI_OPTS verify
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull
paths:
- target
- .mvn
package:
stage: deploy
script: ./mvnw $MAVEN_CLI_OPTS package
artifacts:
paths:
- target/gitdiff-*.jar
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull
paths:
- target
- .mvn
Binary file added gitdiff/.mvn/wrapper/maven-wrapper.jar
Binary file not shown.
18 changes: 18 additions & 0 deletions gitdiff/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
3 changes: 3 additions & 0 deletions gitdiff/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
}
24 changes: 24 additions & 0 deletions gitdiff/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Micronaut 4.0.2 Documentation

- [User Guide](https://docs.micronaut.io/4.0.2/guide/index.html)
- [API Reference](https://docs.micronaut.io/4.0.2/api/index.html)
- [Configuration Reference](https://docs.micronaut.io/4.0.2/guide/configurationreference.html)
- [Micronaut Guides](https://guides.micronaut.io/index.html)
---

- [Micronaut Maven Plugin documentation](https://micronaut-projects.github.io/micronaut-maven-plugin/latest/)
## Feature gitlab-workflow-ci documentation

- [https://docs.gitlab.com/ee/ci/](https://docs.gitlab.com/ee/ci/)


## Feature serialization-jackson documentation

- [Micronaut Serialization Jackson Core documentation](https://micronaut-projects.github.io/micronaut-serialization/latest/guide/)


## Feature maven-enforcer-plugin documentation

- [https://maven.apache.org/enforcer/maven-enforcer-plugin/](https://maven.apache.org/enforcer/maven-enforcer-plugin/)


50 changes: 50 additions & 0 deletions gitdiff/filter_diff.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
require 'json'
require 'yaml'


changed_regions = YAML.load(File.read ARGV.first)
.map do |key, value|
next File.expand_path(key), value.map do _1['start'].._1['finish'] end
end.to_h


warnings = JSON.load(File.read ARGV.last)



def map_for_reviewdog(file, warn)
{
location: {
path: file,
range: {
start: {
line: warn['line'],
column: warn['column']
}
}
},
code: {
value: warn['ruleId']
},
message: warn['message']
}
end

warnings.each do |warning|

path = warning['filePath']

changed = changed_regions[path]

next unless changed

warning['messages'].each do |messages|

line = messages['line']
range = changed.find do _1 === line end
next unless range

puts JSON.dump(map_for_reviewdog path, messages)
end
end

6 changes: 6 additions & 0 deletions gitdiff/micronaut-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
applicationType: cli
defaultPackage: com.fulcanelly.gitdiff
testFramework: junit
sourceLanguage: java
buildTool: maven
features: [app-name, gitlab-workflow-ci, http-client-test, java, junit, logback, maven, maven-enforcer-plugin, picocli, picocli-java-application, picocli-junit, properties, readme, serialization-jackson, shade]
Loading