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

Drone CI generator support + Drone CI docs improvement #2195

Merged
merged 7 commits into from Jan 1, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
- [eslint](https://eslint.org) from 8.30.0 to **8.31.0** on 2022-12-31
- [checkstyle](https://checkstyle.sourceforge.io) from 10.5.0 to **10.6.0** on 2023-01-01
<!-- linter-versions-end -->
- Drone CI enhancements
- Config generator tool now supports Drone CI
- Added information about how to change trigger rules for Drone CI workflow
- New MegaLinter plugin: [linkcheck](https://github.com/shiranr/linkcheck): Plugin to check and validate Markdown links.

## [v6.17.0] - 2022-12-27
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,32 @@ steps:

This uses the [Drone CI docker runner](https://docs.drone.io/pipeline/docker/overview/), so it's needed to install and configure it beforehand on your Drone CI server.

#### (Optional) Adjusting trigger rules

The Drone CI workflow should trigger automatically for every scenario (push, pull request, sync...) however, you can *optionally* change this behavior by changing the trigger. For example:

```yaml
kind: pipeline
type: docker
name: MegaLinter

workspace:
path: /tmp/lint

steps:

- name: megalinter
image: oxsecurity/megalinter:v6
environment:
DEFAULT_WORKSPACE: /tmp/lint

trigger:
event:
- push
```

The workflow above should only trigger on push, not on any other situation. For more information about how to configure Drone CI trigger rules, [click here](https://docs.drone.io/pipeline/triggers/).

### Docker container

You can also run megalinter with its Docker container, just execute this command:
Expand Down
16 changes: 15 additions & 1 deletion mega-linter-runner/generators/mega-linter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ When you don't know what option to select, please use default values`
default: "gitHubActions",
choices: [
{ name: "GitHub Actions", value: "gitHubActions" },
{ name: "Drone CI", value: "droneCI" },
{ name: "Jenkins", value: "jenkins" },
{ name: "GitLab CI", value: "gitLabCI" },
{ name: "Azure Pipelines", value: "azure" },
Expand Down Expand Up @@ -138,6 +139,7 @@ When you don't know what option to select, please use default values`
writing() {
// Generate workflow config
this._generateGitHubAction();
this._generateDroneCI();
this._generateJenkinsfile();
this._generateGitLabCi();
this._generateAzurePipelines();
Expand Down Expand Up @@ -231,7 +233,19 @@ When you don't know what option to select, please use default values`
}
);
}

_generateDroneCI() {
if (this.props.ci !== "droneCI") {
return;
}
this.fs.copyTpl(
this.templatePath(".drone.yml"),
this.destinationPath(".drone.yml"),
{
APPLY_FIXES: this.props.applyFixes === true ? "all" : "none",
DEFAULT_BRANCH: this.props.defaultBranch,
}
);
}
_generateJenkinsfile() {
if (this.props.ci !== "jenkins") {
return;
Expand Down
15 changes: 15 additions & 0 deletions mega-linter-runner/generators/mega-linter/templates/.drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
kind: pipeline
type: docker
name: MegaLinter


workspace:
path: /tmp/lint

steps:


- name: megalinter
image: oxsecurity/megalinter:v6
environment:
DEFAULT_WORKSPACE: /tmp/lint