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

test(cli): add composer install step #654

Merged
merged 1 commit into from
Jan 28, 2025
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
22 changes: 11 additions & 11 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
- Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
- The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand Down Expand Up @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand Down
13 changes: 12 additions & 1 deletion codegen/src/actions/packages.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::workflow::WorkflowJobsStep;
use crate::tools::{Tool, ToolPackagesBrew};
use crate::tools::{Tool, ToolPackagesBrew, ToolPackagesComposer};

fn generate_cargo(tool: &str) -> String {
format!("( which cargo && ( cargo binstall {tool} || cargo install {tool} ) )")
Expand Down Expand Up @@ -67,6 +67,13 @@ fn generate_nimble(tool: &str) -> String {
format!("( which nimble && nimble install {tool} )")
}

fn generate_composer(tool: &ToolPackagesComposer) -> String {
format!(
"( which composer && composer require {} )",
tool.package.as_ref().unwrap_or(&tool.binary)
)
}

pub fn generate_install_steps(tools: &Vec<Tool>) -> Vec<WorkflowJobsStep> {
let mut steps = Vec::new();

Expand Down Expand Up @@ -150,6 +157,10 @@ pub fn generate_install_steps(tools: &Vec<Tool>) -> Vec<WorkflowJobsStep> {
install_options.push(generate_nimble(nimble));
}

if let Some(composer) = &tool.packages.composer {
install_options.push(generate_composer(composer));
}

if let Some(julia) = &tool.packages.julia {
install_options.push(generate_julia(julia));
}
Expand Down
18 changes: 13 additions & 5 deletions codegen/src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ pub struct ToolPackagesBrew {
pub tap: Option<String>,
}

#[derive(Debug, serde::Deserialize, schemars::JsonSchema, Clone, Default)]
#[serde(deny_unknown_fields)]
pub struct ToolPackagesComposer {
pub binary: String,

pub package: Option<String>,
}

#[derive(Debug, serde::Deserialize, schemars::JsonSchema, Clone, Default)]
#[serde(deny_unknown_fields)]
pub struct ToolPackages {
Expand Down Expand Up @@ -70,6 +78,9 @@ pub struct ToolPackages {

pub opam: Option<String>,

/// Binary name if installed through composer
pub composer: Option<ToolPackagesComposer>,

pub pip: Option<String>,

pub stack: Option<String>,
Expand Down Expand Up @@ -99,9 +110,6 @@ pub struct Tool {
#[serde(default)]
pub packages: ToolPackages,

/// Binary name if installed through composer
pub php: Option<String>,

pub disable_ci_tests: Option<bool>,
}

Expand Down Expand Up @@ -197,8 +205,8 @@ impl Tool {
command_types.push(format!("CommandType::NodeModules(\"{}\")", self.binary));
};

if let Some(php) = &self.php {
command_types.push(format!("CommandType::PhpVendor(\"{php}\")"));
if let Some(php) = &self.packages.composer {
command_types.push(format!("CommandType::PhpVendor(\"{}\")", php.binary));
};

command_types.push(format!("CommandType::Direct(\"{}\")", self.binary));
Expand Down
7 changes: 6 additions & 1 deletion tools/easy-coding-standard/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@
"homepage": "https://github.com/easy-coding-standard/easy-coding-standard",
"languages": ["php"],
"name": "easy-coding-standard",
"php": "ecs"
"packages": {
"composer": {
"binary": "ecs",
"package": "symplify/easy-coding-standard"
}
}
}
3 changes: 1 addition & 2 deletions tools/hurlfmt/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@
"name": null,
"packages": {
"cargo": "hurlfmt"
},
"php": null
}
}
7 changes: 6 additions & 1 deletion tools/php-cs-fixer/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@
"description": "A tool to automatically fix PHP Coding Standards issues",
"homepage": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer",
"languages": ["php"],
"php": "php-cs-fixer"
"packages": {
"composer": {
"binary": "php-cs-fixer",
"package": "friendsofphp/php-cs-fixer"
}
}
}
7 changes: 6 additions & 1 deletion tools/phpcbf/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@
"description": "PHP Code Beautifier and Fixer fixes violations of a defined coding standard",
"homepage": "https://phpqa.io/projects/phpcbf.html",
"languages": ["php"],
"php": "phpcbf"
"packages": {
"composer": {
"binary": "phpcbf",
"package": "squizlabs/php_codesniffer"
}
}
}
7 changes: 6 additions & 1 deletion tools/phpinsights/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@
"description": "Instant PHP quality checks from your console",
"homepage": "https://github.com/nunomaduro/phpinsights",
"languages": ["php"],
"php": "phpinsights"
"packages": {
"composer": {
"binary": "phpinsights",
"package": "nunomaduro/phpinsights"
}
}
}
7 changes: 6 additions & 1 deletion tools/pint/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@
"description": "Laravel Pint is an opinionated PHP code style fixer for minimalists",
"homepage": "https://github.com/laravel/pint",
"languages": ["php"],
"php": "pint"
"packages": {
"composer": {
"binary": "pint",
"package": "laravel/pint"
}
}
}
9 changes: 8 additions & 1 deletion tools/pretty-php/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@
"description": "The opinionated PHP code formatter",
"homepage": "https://github.com/lkrms/pretty-php",
"languages": ["php"],
"php": "pretty-php"
"packages": {
"brew": {
"name": "lkrms/misc/pretty-php"
},
"composer": {
"binary": "pretty-php"
}
}
}
7 changes: 6 additions & 1 deletion tools/tlint/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@
"description": "Tighten linter for Laravel conventions",
"homepage": "https://github.com/tighten/tlint",
"languages": ["php"],
"php": "tlint"
"packages": {
"composer": {
"binary": "tlint",
"package": "tightenco/tlint"
}
}
}
28 changes: 24 additions & 4 deletions tools/tool.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@
},
"packages": {
"$ref": "#/definitions/ToolPackages"
},
"php": {
"description": "Binary name if installed through composer",
"type": ["string", "null"]
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -124,6 +120,17 @@
"cargo": {
"type": ["string", "null"]
},
"composer": {
"description": "Binary name if installed through composer",
"anyOf": [
{
"$ref": "#/definitions/ToolPackagesComposer"
},
{
"type": "null"
}
]
},
"coursier": {
"type": ["string", "null"]
},
Expand Down Expand Up @@ -173,6 +180,19 @@
}
},
"additionalProperties": false
},
"ToolPackagesComposer": {
"type": "object",
"required": ["binary"],
"properties": {
"binary": {
"type": "string"
},
"package": {
"type": ["string", "null"]
}
},
"additionalProperties": false
}
}
}
7 changes: 6 additions & 1 deletion tools/twig-cs-fixer/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@
"description": "A tool to automatically fix Twig Coding Standards issues",
"homepage": "https://github.com/VincentLanglet/Twig-CS-Fixer",
"languages": ["twig"],
"php": "twig-cs-fixer"
"packages": {
"composer": {
"binary": "twig-cs-fixer",
"package": "vincentlanglet/twig-cs-fixer"
}
}
}
Loading