Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: golangci/golangci-lint-action
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.6.0
Choose a base ref
...
head repository: golangci/golangci-lint-action
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.7.0
Choose a head ref

Commits on Jun 12, 2023

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    DrFaust92 Ilia Lazebnik
    Copy the full SHA
    907f20a View commit details
  2. Copy the full SHA
    313d11e View commit details
  3. Copy the full SHA
    1577f9c View commit details
  4. Copy the full SHA
    8078b42 View commit details
  5. Copy the full SHA
    aca98fe View commit details
  6. Copy the full SHA
    444727d View commit details
  7. docs: fix default value

    ldez committed Jun 12, 2023
    Copy the full SHA
    cde40a3 View commit details
  8. docs: improve changelog

    ldez committed Jun 12, 2023
    Copy the full SHA
    455ad55 View commit details

Commits on Jun 13, 2023

  1. chore: flag dist as generated

    ldez committed Jun 13, 2023
    Copy the full SHA
    b814b86 View commit details

Commits on Jun 19, 2023

  1. Copy the full SHA
    71a9ad5 View commit details
  2. Copy the full SHA
    2a20098 View commit details
  3. Copy the full SHA
    05fe2da View commit details
  4. Copy the full SHA
    0182747 View commit details

Commits on Jun 24, 2023

  1. Copy the full SHA
    715abd3 View commit details

Commits on Jun 26, 2023

  1. Copy the full SHA
    28fa338 View commit details
  2. Copy the full SHA
    d29c0cc View commit details

Commits on Jul 3, 2023

  1. Copy the full SHA
    4d9aae6 View commit details
  2. Copy the full SHA
    5326fa0 View commit details
  3. Copy the full SHA
    98d3249 View commit details
  4. Copy the full SHA
    f1690ab View commit details
  5. Copy the full SHA
    4f5a3af View commit details

Commits on Jul 9, 2023

  1. Copy the full SHA
    42ba3c2 View commit details

Commits on Jul 10, 2023

  1. Copy the full SHA
    360e5b7 View commit details
  2. Copy the full SHA
    84836b1 View commit details
  3. Copy the full SHA
    a422a81 View commit details

Commits on Jul 11, 2023

  1. build(deps): bump semver from 6.3.0 to 6.3.1 (#796)

    Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
    dependabot[bot] and ldez authored Jul 11, 2023
    Copy the full SHA
    8457318 View commit details
  2. chore: flag dist as generated

    ldez committed Jul 11, 2023
    Copy the full SHA
    83e5cce View commit details
  3. build(deps-dev): bump prettier from 2.8.8 to 3.0.0 (#794)

    Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
    dependabot[bot] and ldez authored Jul 11, 2023
    Copy the full SHA
    a1145a6 View commit details

Commits on Jul 17, 2023

  1. Copy the full SHA
    c0edea7 View commit details
  2. Copy the full SHA
    ba65924 View commit details
  3. Copy the full SHA
    a657dba View commit details

Commits on Jul 24, 2023

  1. build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.61.0 to…

    … 6.0.0 (#800)
    
    Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
    dependabot[bot] and ldez authored Jul 24, 2023
    Copy the full SHA
    b393647 View commit details
  2. Copy the full SHA
    f050028 View commit details
  3. Copy the full SHA
    51e800d View commit details
  4. Copy the full SHA
    88ae11c View commit details

Commits on Jul 31, 2023

  1. Copy the full SHA
    015f418 View commit details
  2. Copy the full SHA
    797977b View commit details
  3. Copy the full SHA
    77db3f9 View commit details
  4. Copy the full SHA
    2c52863 View commit details
  5. Copy the full SHA
    2ab8c44 View commit details

Commits on Aug 7, 2023

  1. Copy the full SHA
    66268c5 View commit details
  2. Copy the full SHA
    c0cd965 View commit details
  3. Copy the full SHA
    b6bdfb3 View commit details
  4. Copy the full SHA
    44d9998 View commit details
  5. Copy the full SHA
    a252750 View commit details

Commits on Aug 14, 2023

  1. Copy the full SHA
    ab66454 View commit details
  2. Copy the full SHA
    cac24f5 View commit details
  3. Copy the full SHA
    945dc98 View commit details
  4. Copy the full SHA
    18dad33 View commit details
  5. build(deps): bump @actions/cache from 3.2.1 to 3.2.2 (#825)

    Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
    dependabot[bot] and ldez authored Aug 14, 2023
    Copy the full SHA
    5e67631 View commit details
Showing with 2,985 additions and 1,530 deletions.
  1. +1 −0 .gitattributes
  2. +15 −0 .github/release.yml
  3. +13 −9 README.md
  4. +8 −5 action.yml
  5. +635 −433 dist/post_run/index.js
  6. +635 −433 dist/run/index.js
  7. +1,608 −633 package-lock.json
  8. +11 −11 package.json
  9. +2 −5 src/run.ts
  10. +56 −0 src/utils/diffUtils.ts
  11. +1 −1 tsconfig.json
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/** linguist-generated=true
15 changes: 15 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
changelog:
categories:
- title: Changes
labels:
- '*'
exclude:
labels:
- documentation
- dependencies
- title: Documentation
labels:
- documentation
- title: Dependencies
labels:
- dependencies
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -46,32 +46,34 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.53

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
#
# Note: by default the `.golangci.yml` file should be at the root of the repository.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the all caching functionality will be complete disabled,
# Optional: if set to true, then all caching functionality will be completely disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true
# Optional:The mode to install golangci-lint. It can be 'binary' or 'goinstall'.

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
```

@@ -113,7 +115,9 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.53

# Optional: working directory, useful for monorepos
13 changes: 8 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
@@ -3,7 +3,10 @@ description: "Official golangci-lint action with line-attached annotations for f
author: "golangci"
inputs:
version:
description: "version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version"
description: |
The version of golangci-lint to use.
When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
required: false
args:
description: "golangci-lint command line arguments"
@@ -18,21 +21,21 @@ inputs:
required: false
only-new-issues:
description: "if set to true and the action runs on a pull request - the action outputs only newly found issues"
default: false
default: 'false'
required: false
skip-cache:
description: |
if set to true then the all caching functionality will be complete disabled,
takes precedence over all other caching options.
default: false
default: 'false'
required: false
skip-pkg-cache:
description: "if set to true then the action doesn't cache or restore ~/go/pkg."
default: false
default: 'false'
required: false
skip-build-cache:
description: "if set to true then the action doesn't cache or restore ~/.cache/go-build."
default: false
default: 'false'
required: false
install-mode:
description: "The mode to install golangci-lint. It can be 'binary' or 'goinstall'."
1,068 changes: 635 additions & 433 deletions dist/post_run/index.js

Large diffs are not rendered by default.

1,068 changes: 635 additions & 433 deletions dist/run/index.js

Large diffs are not rendered by default.

2,241 changes: 1,608 additions & 633 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -24,27 +24,27 @@
"author": "golangci",
"license": "MIT",
"dependencies": {
"@actions/cache": "^3.2.1",
"@actions/cache": "^3.2.2",
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/github": "^5.1.1",
"@actions/http-client": "^2.1.0",
"@actions/http-client": "^2.1.1",
"@actions/tool-cache": "^2.0.1",
"@types/node": "^20.2.5",
"@types/node": "^20.5.0",
"@types/semver": "^7.5.0",
"@types/tmp": "^0.2.3",
"tmp": "^0.2.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"@vercel/ncc": "^0.36.1",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint": "^8.47.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"prettier": "^2.8.8",
"typescript": "^5.1.3"
"prettier": "^3.0.1",
"typescript": "^5.1.6"
}
}
7 changes: 2 additions & 5 deletions src/run.ts
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ import { promisify } from "util"

import { restoreCache, saveCache } from "./cache"
import { installLint, InstallMode } from "./install"
import { alterDiffPatch } from "./utils/diffUtils"
import { findLintVersion } from "./version"

const execShellCommand = promisify(exec)
@@ -68,7 +69,7 @@ async function fetchPatch(): Promise<string> {
const tempDir = await createTempDir()
const patchPath = path.join(tempDir, "pull.patch")
core.info(`Writing patch to ${patchPath}`)
await writeFile(patchPath, patch)
await writeFile(patchPath, alterDiffPatch(patch))
return patchPath
} catch (err) {
console.warn(`failed to save pull request patch:`, err)
@@ -157,10 +158,6 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
const workingDirectory = core.getInput(`working-directory`)
const cmdArgs: ExecOptions = {}
if (workingDirectory) {
if (patchPath) {
// TODO: make them compatible
throw new Error(`options working-directory and only-new-issues aren't compatible`)
}
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
throw new Error(`working-directory (${workingDirectory}) was not a path`)
}
56 changes: 56 additions & 0 deletions src/utils/diffUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as core from "@actions/core"
import * as path from "path"

// If needed alter diff file to be compatible with working directory
export function alterDiffPatch(patch: string): string {
const workingDirectory = core.getInput(`working-directory`)

if (workingDirectory) {
return alterPatchWithWorkingDirectory(patch, workingDirectory)
}

return patch
}

function alterPatchWithWorkingDirectory(patch: string, workingDirectory: string): string {
const workspace = process.env["GITHUB_WORKSPACE"] || ""

const wd = path.relative(workspace, workingDirectory)

// ignore diff sections not related to the working directory
let ignore = false

const lines = patch.split("\n")
const filteredLines = []

// starts with "--- a/xxx/" or "+++ a/xxx/" or "--- b/xxx/" or "+++ b/xxx/"
const cleanDiff = new RegExp(`^((?:\\+{3}|-{3}) [ab]\\/)${escapeRegExp(wd)}\\/(.*)`, "gm")

// contains " a/xxx/" or " b/xxx/"
const firstLine = new RegExp(`( [ab]\\/)${escapeRegExp(wd)}\\/(.*)`, "gm")

for (const line of lines) {
if (line.startsWith("diff --git")) {
ignore = !line.includes(` a/${wd}/`)
if (ignore) {
continue
}

filteredLines.push(line.replaceAll(firstLine, "$1$2"))
} else {
if (ignore) {
continue
}

filteredLines.push(line.replaceAll(cleanDiff, "$1$2"))
}
}

// Join the modified lines back into a diff string
return filteredLines.join("\n")
}

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
function escapeRegExp(exp: string): string {
return exp.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") // $& means the whole matched string
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"target": "ES2021", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */