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

Call the mega-linter-runner installer to generate the examples in the docs #3073

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ In your repository you should have a `.github/workflows` folder with **GitHub**
<details>
<summary>This file should have this code</summary>

<!-- The following code has been @generated by build.sh and the mega-linter-runner generator, please don't update it, but update the template, then build again -->
<!-- install-github-example-workflow-section-start -->
```yml
---
# MegaLinter GitHub Action configuration file
Expand Down Expand Up @@ -514,6 +516,7 @@ jobs:
commit_user_name: megalinter-bot
commit_user_email: [email protected]
```
<!-- install-github-example-workflow-section-end -->

</details>

Expand Down
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env bash
set -eu

npm install --prefix mega-linter-runner
npm run --prefix mega-linter-runner generator-samples

PYTHONPATH=.
export PYTHONPATH
if type python3 >/dev/null 2>/dev/null; then
Expand Down
19 changes: 0 additions & 19 deletions mega-linter-runner/__tests__/mega-linter.js

This file was deleted.

47 changes: 47 additions & 0 deletions mega-linter-runner/__tests__/mega-linter.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import helpers, { RunResult, result } from "yeoman-test";
import MyGenerator from "../generators/mega-linter/index.js";

import { dirname } from "path";
import { fileURLToPath } from "url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

import * as path from "path";

describe("generator test", () => {
describe("test", () => {
beforeEach(async () => {
const files = {
"mega-linter-runner/generators/mega-linter/templates/mega-linter.yml":
{},
};
await helpers
.run(MyGenerator, {
targetDir: RunResult,
resolved: path.join(__dirname, "..", "generators", "mega-linter"),
namespace: "mega-linter-runner:mega-linter",
})
.withAnswers({ flavor: "all", ox: false, ci: "gitHubActions" });
});

it("creates files", () => {
// before(() => helpers.prepareTemporaryDir());
result
.dumpFiles(".github/workflows/mega-linter.yml")
.fs.copy(
".github/workflows/mega-linter.yml",
path.join(
__dirname,
"..",
"generators",
"mega-linter",
"out",
".github/workflows/mega-linter.yml"
)
);
result.fs.commit();
result.dumpFilenames();
});
});
});
6 changes: 3 additions & 3 deletions mega-linter-runner/generators/mega-linter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ When you don't know what option to select, please use default values`
this.validateAllCodeBaseGha = "true";
} else {
this.validateAllCodeBaseGha = ">-\n"
this.validateAllCodeBaseGha += " ${{";
this.validateAllCodeBaseGha += " github.event_name == 'push' &&"
this.validateAllCodeBaseGha += " github.ref == 'refs/heads/main'"
this.validateAllCodeBaseGha += " ${{\n";
this.validateAllCodeBaseGha += " github.event_name == 'push' &&\n"
this.validateAllCodeBaseGha += " github.ref == 'refs/heads/main'\n"
this.validateAllCodeBaseGha += " }}";
}
this.disable = false;
Expand Down
6 changes: 4 additions & 2 deletions mega-linter-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"mega-linter-runner": "lib/index.js"
},
"scripts": {
"test": "mocha \"test/**/*.test.js\""
"test": "mocha \"test/**/*.test.js\"",
"generator-samples": "mocha \"__tests__/mega-linter.mjs\""
},
"keywords": [
"mega-linter",
Expand Down Expand Up @@ -95,7 +96,8 @@
"devDependencies": {
"assert": "^2.1.0",
"eslint": "^8.50.0",
"mocha": "^10.2.0"
"mocha": "^10.2.0",
"yeoman-test": "^8.2.0"
},
"resolutions": {
"semver": "7.5.2"
Expand Down
Loading