Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that go.mod exists in reading the version #173

Merged
merged 1 commit into from Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/test.yml
Expand Up @@ -14,24 +14,29 @@ jobs:
- run: |
npm install
npm run all

test: # make sure the action works on a clean machine without building
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
version:
- ""
- "latest"
- "v1.37"
- "v1.37.1"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: ./
with:
version: latest
version: ${{ matrix.version }}
args: --issues-exit-code=0 ./sample/...
only-new-issues: true

# Test with full version vX.Y.Z
test-full-version:
test-go-mod-version:
strategy:
matrix:
os:
Expand All @@ -43,6 +48,5 @@ jobs:
- uses: actions/checkout@v2
- uses: ./
with:
version: v1.28.3
args: --issues-exit-code=0 ./sample/...
only-new-issues: true
working-directory: sample-go-mod
args: --issues-exit-code=0 ./...
15 changes: 12 additions & 3 deletions dist/post_run/index.js
Expand Up @@ -2233,11 +2233,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.findLintVersion = exports.stringifyVersion = void 0;
const core = __importStar(__webpack_require__(470));
const httpm = __importStar(__webpack_require__(539));
const fs = __importStar(__webpack_require__(747));
const path_1 = __importDefault(__webpack_require__(622));
const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/;
const modVersionRe = /github.com\/golangci\/golangci-lint\s(v.+)/;
const parseVersion = (s) => {
Expand Down Expand Up @@ -2282,12 +2286,17 @@ const isLessVersion = (a, b) => {
};
const getRequestedLintVersion = () => {
let requestedLintVersion = core.getInput(`version`);
if (requestedLintVersion == "") {
const content = fs.readFileSync("go.mod", "utf-8");
const workingDirectory = core.getInput(`working-directory`);
let goMod = "go.mod";
if (workingDirectory) {
goMod = path_1.default.join(workingDirectory, goMod);
}
if (requestedLintVersion == "" && fs.existsSync(goMod)) {
const content = fs.readFileSync(goMod, "utf-8");
const match = content.match(modVersionRe);
if (match) {
requestedLintVersion = match[1];
core.info(`Found golangci-lint version '${requestedLintVersion}' in go.mod`);
core.info(`Found golangci-lint version '${requestedLintVersion}' in '${goMod}' file`);
}
}
const parsedRequestedLintVersion = parseVersion(requestedLintVersion);
Expand Down
15 changes: 12 additions & 3 deletions dist/run/index.js
Expand Up @@ -2233,11 +2233,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.findLintVersion = exports.stringifyVersion = void 0;
const core = __importStar(__webpack_require__(470));
const httpm = __importStar(__webpack_require__(539));
const fs = __importStar(__webpack_require__(747));
const path_1 = __importDefault(__webpack_require__(622));
const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/;
const modVersionRe = /github.com\/golangci\/golangci-lint\s(v.+)/;
const parseVersion = (s) => {
Expand Down Expand Up @@ -2282,12 +2286,17 @@ const isLessVersion = (a, b) => {
};
const getRequestedLintVersion = () => {
let requestedLintVersion = core.getInput(`version`);
if (requestedLintVersion == "") {
const content = fs.readFileSync("go.mod", "utf-8");
const workingDirectory = core.getInput(`working-directory`);
let goMod = "go.mod";
if (workingDirectory) {
goMod = path_1.default.join(workingDirectory, goMod);
}
if (requestedLintVersion == "" && fs.existsSync(goMod)) {
const content = fs.readFileSync(goMod, "utf-8");
const match = content.match(modVersionRe);
if (match) {
requestedLintVersion = match[1];
core.info(`Found golangci-lint version '${requestedLintVersion}' in go.mod`);
core.info(`Found golangci-lint version '${requestedLintVersion}' in '${goMod}' file`);
}
}
const parsedRequestedLintVersion = parseVersion(requestedLintVersion);
Expand Down
5 changes: 5 additions & 0 deletions sample-go-mod/go.mod
@@ -0,0 +1,5 @@
module sample

go 1.15

require github.com/golangci/golangci-lint v1.37.1