Skip to content

Conversation

@glbrntt
Copy link
Contributor

@glbrntt glbrntt commented Aug 12, 2022

Motivation:

We have a handful of scripts which are cargo-culted across the NIO
repos. This includes the soundness script for checking license headers
and unacceptable language. As regex was added to Swift 5.7 we can use it
to replace the bash in the existing script and provide a product which
can be used in the other NIO repos.

Modifications:

  • Add a 'nio-soundness' plugin which can check for unacceptable
    language and valid license headers.
  • The CLI is hand rolled to avoid bringing in a dependency on
    swift-argument-parser.
  • Update the soundness script to use the new tool.
  • Update the soundness script to use zsh instead of bash as the bash
    shipped on macOS is old and doesn't support globbing '**'.

Result:

Less bash, more Swift.

Motivation:

We have a handful of scripts which are cargo-culted across the NIO
repos. This includes the soundness script for checking license headers
and unacceptable language. As regex was added to Swift 5.7 we can use it
to replace the bash in the existing script and provide a product which
can be used in the other NIO repos.

Modifications:

- Add a 'nio-soundness' product which can check for unacceptable
  language and valid license headers.
- The CLI is hand rolled to avoid bringing in a dependency on
  swift-argument-parser.
- Update the soudness script to use the new tool.
- Update the soudness script to use zsh instead of bash as the bash
  shipped on macOS is old and doesn't support globbing '**'.

Result:

Less bash, more Swift.
@glbrntt
Copy link
Contributor Author

glbrntt commented Aug 12, 2022

We'll have to update our soundness job to use 5.7 once it's released if we want to use this.

It will also need zsh...

@glbrntt glbrntt changed the title Add a soudness product Add a soudness plugin Aug 15, 2022
@glbrntt glbrntt changed the title Add a soudness plugin Add a soundness plugin Aug 15, 2022
@ktoso
Copy link
Member

ktoso commented Aug 16, 2022

It will also need zsh...

I mean... I love zsh as any other person; but it's not a great idea to require it for scripts like this, why the requirement?

@ktoso
Copy link
Member

ktoso commented Aug 16, 2022

Very nice by the way, would love to share this implementation and not have to copy paste the plugin into all other repos...
Could we perhaps make this a thing in swift-server org?

done

rm "$tmp"
swift package plugin check-nio-soundness check-language \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI you don't need the "plugin", can be swift package check-nio-soundness

I'd love to make this a plugin we can share within our projects tbh, lots of projects, not just nio, use those scripts -- we could make it swift package soundness check-language etc

struct Soundness: CommandPlugin {
func performCommand(context: PackagePlugin.PluginContext, arguments: [String]) async throws {
// Check for help first.
if arguments.contains("--help") {
Copy link
Member

@tomerd tomerd Aug 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SwiftPM plugin APIs include a simple argument parser that can help make these tasks easier.

see https://github.com/apple/swift-package-manager/blob/main/Documentation/Plugins.md#implementing-the-command-plugin-script

cc @abertelrud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants