From ca9431bfb395b5ce019409c118b4ba76e480e244 Mon Sep 17 00:00:00 2001 From: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com> Date: Fri, 3 May 2024 16:06:58 -0400 Subject: [PATCH] Add support for linting on macOS and enable GH workflow for macOS. (#383) --- .github/workflows/clp-lint.yaml | 9 ++++++++- Taskfile.yml | 9 +++++---- docs/src/dev-guide/contributing-linting.md | 20 ++++++++++++++++++-- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/clp-lint.yaml b/.github/workflows/clp-lint.yaml index ab0f4774b..514c2ec37 100644 --- a/.github/workflows/clp-lint.yaml +++ b/.github/workflows/clp-lint.yaml @@ -9,7 +9,10 @@ concurrency: jobs: lint-check: - runs-on: "ubuntu-latest" + strategy: + matrix: + os: ["macos-latest", "ubuntu-latest"] + runs-on: "${{matrix.os}}" steps: - uses: "actions/checkout@v3" with: @@ -23,6 +26,10 @@ jobs: shell: "bash" run: "npm install -g @go-task/cli" + - if: "matrix.os == 'macos-latest'" + name: "Install coreutils (for md5sum)" + run: "brew install coreutils" + - name: "Run lint task" shell: "bash" run: "task lint:check" diff --git a/Taskfile.yml b/Taskfile.yml index c63966d84..b0135038c 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -306,9 +306,8 @@ tasks: curl --header "Cache-Control: no-cache, no-store" --silent "{{.NODEJS_VERSION_BASE_URL}}" | grep --only-matching - --perl-regexp --max-count 1 - "node-v\\d+\\.\\d+\\.\\d+-linux-{{.NODEJS_ARCH}}" + "node-v[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+-{{OS}}-{{.NODEJS_ARCH}}" | head --lines 1 cmds: - task: "download-and-extract-tar" @@ -565,8 +564,10 @@ tasks: vars: ["FILE_PATH", "SED_EXP"] cmds: - |- - # NOTE: We can't use `sed -i` since `-i` has different syntax on Linux and macOS + # NOTE: + # 1. We can't use `sed -i` since `-i` has different syntax on Linux and macOS + # 2. We can't use `--regexp` instead of `-E` since `--regexp` is not supported on macOS src="{{.FILE_PATH}}" dst="{{.FILE_PATH}}.tmp" - sed --regexp-extended '{{.SED_EXP}}' "${src}" > "${dst}" + sed -E '{{.SED_EXP}}' "${src}" > "${dst}" mv "${dst}" "${src}" diff --git a/docs/src/dev-guide/contributing-linting.md b/docs/src/dev-guide/contributing-linting.md index 2b9c46aa9..599935157 100644 --- a/docs/src/dev-guide/contributing-linting.md +++ b/docs/src/dev-guide/contributing-linting.md @@ -1,8 +1,23 @@ # Linting Before submitting a PR, ensure you've run our linting tools and either fixed any violations or -suppressed the warning. To run our linting workflows locally, you'll need [Task]. Alternatively, -you can run the [clp-lint] workflow in your fork. +suppressed the warning. If you can't run the linting workflows locally, you can enable and run the +[clp-lint] workflow in your fork. + +## Requirements + +We currently support running our linting tools on Linux and macOS. If you're developing on another +OS, you can submit a [feature request][feature-req], or use our [clp-lint] workflow in your fork. + +To run the linting tools, besides commonly installed tools like `tar`, you'll need: + +* `curl` +* `md5sum` +* Python 3.8 or newer +* python3-venv +* [Task] + +## Running the linters To perform the linting checks: @@ -17,4 +32,5 @@ task lint:fix ``` [clp-lint]: https://github.com/y-scope/clp/blob/main/.github/workflows/clp-lint.yaml +[feature-req]: https://github.com/y-scope/clp/issues/new?assignees=&labels=enhancement&projects=&template=feature-request.yml [Task]: https://taskfile.dev/