Skip to content

Commit f59ee14

Browse files
committed
use nu shell (cross-platform compatible)
1 parent 7aff709 commit f59ee14

File tree

1 file changed

+60
-87
lines changed

1 file changed

+60
-87
lines changed

action.yml

Lines changed: 60 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ inputs:
219219
outputs:
220220
checks-failed:
221221
description: An integer that can be used as a boolean value to indicate if any checks failed by clang-tidy and clang-format.
222-
value: ${{ steps.cpp-linter-unix.outputs.checks-failed || steps.cpp-linter-windows.outputs.checks-failed }}
222+
value: ${{ steps.cpp-linter.outputs.checks-failed }}
223223
clang-tidy-checks-failed:
224224
description: An integer that can be used as a boolean value to indicate if any checks failed by clang-tidy only.
225-
value: ${{ steps.cpp-linter-unix.outputs.clang-tidy-checks-failed || steps.cpp-linter-windows.outputs.clang-tidy-checks-failed }}
225+
value: ${{ steps.cpp-linter.outputs.clang-tidy-checks-failed }}
226226
clang-format-checks-failed:
227227
description: An integer that can be used as a boolean value to indicate if any checks failed by clang-format only.
228-
value: ${{ steps.cpp-linter-unix.outputs.clang-format-checks-failed || steps.cpp-linter-windows.outputs.clang-format-checks-failed }}
228+
value: ${{ steps.cpp-linter.outputs.clang-format-checks-failed }}
229229
runs:
230230
using: "composite"
231231
steps:
@@ -237,9 +237,9 @@ runs:
237237
# First try installing from default Ubuntu repositories before trying LLVM script
238238
if ! sudo apt-get install -y clang-format-${{ inputs.version }} clang-tidy-${{ inputs.version }}; then
239239
# This LLVM script will add the relevant LLVM PPA: https://apt.llvm.org/
240-
wget https://apt.llvm.org/llvm.sh -O $GITHUB_ACTION_PATH/llvm_install.sh
241-
chmod +x $GITHUB_ACTION_PATH/llvm_install.sh
242-
if sudo $GITHUB_ACTION_PATH/llvm_install.sh ${{ inputs.version }}; then
240+
wget https://apt.llvm.org/llvm.sh -O ${GITHUB_ACTION_PATH%/}/llvm_install.sh
241+
chmod +x ${GITHUB_ACTION_PATH%/}/llvm_install.sh
242+
if sudo ${GITHUB_ACTION_PATH%/}/llvm_install.sh ${{ inputs.version }}; then
243243
sudo apt-get install -y clang-format-${{ inputs.version }} clang-tidy-${{ inputs.version }}
244244
fi
245245
fi
@@ -253,89 +253,62 @@ runs:
253253
ln -s "$(brew --prefix llvm@${{ inputs.version }})/bin/clang-format" "/usr/local/bin/clang-format-${{ inputs.version }}"
254254
ln -s "$(brew --prefix llvm@${{ inputs.version }})/bin/clang-tidy" "/usr/local/bin/clang-tidy-${{ inputs.version }}"
255255
256-
- name: Setup cpp-linter dependencies (Unix)
257-
if: runner.os == 'Linux' || runner.os == 'macOS'
258-
shell: bash
259-
env:
260-
UV_NO_MODIFY_PATH: 1
261-
UV_PROJECT_ENVIRONMENT: ${{ github.action_path }}
262-
UV_INSTALL_DIR: ${{ github.action_path }}/bin
263-
run: |
264-
curl -LsSf https://astral.sh/uv/install.sh | sh
265-
${{ env.UV_INSTALL_DIR }}/uv sync --config-file "${{ env.GITHUB_ACTION_PATH }}" --group action
266-
${{ env.UV_INSTALL_DIR }}/uv run clang-tools -i ${{ inputs.version }} -b
256+
- name: Setup nu shell
257+
uses: hustcer/setup-nu@v3
258+
with:
259+
version: '0.106.1'
267260

268-
- name: Setup cpp-linter dependencies (Windows)
269-
if: runner.os == 'Windows'
270-
shell: pwsh
261+
- name: Setup cpp-linter dependencies
262+
shell: nu {0}
271263
env:
272264
UV_NO_MODIFY_PATH: 1
273-
UV_INSTALL_DIR: ${{ github.action_path }}/bin
274-
UV_PROJECT_ENVIRONMENT: ${{ github.action_path }}
275-
run: |
276-
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/0.8.9/install.ps1 | iex"
277-
${{ env.UV_INSTALL_DIR }}/uv sync --config-file "${{ env.GITHUB_ACTION_PATH }}" --group action
278-
${{ env.UV_INSTALL_DIR }}/uv run clang-tools -i ${{ inputs.version }} -b
265+
run: |-
266+
let action_path = $env.GITHUB_ACTION_PATH | str trim --right --char '/'
267+
$env.UV_INSTALL_DIR = $action_path | path join 'bin'
268+
$env.UV_PROJECT_ENVIRONMENT = $action_path | path join '.venv'
279269
280-
- name: Run cpp-linter (Unix)
281-
if: runner.os == 'Linux' || runner.os == 'macOS'
282-
id: cpp-linter-unix
283-
shell: bash
284-
env:
285-
UV_PROJECT_ENVIRONMENT: ${{ github.action_path }}
286-
UV_INSTALL_DIR: ${{ github.action_path }}/bin
287-
run: >-
288-
${{ env.UV_INSTALL_DIR }}/uv run
289-
cpp-linter
290-
--style="${{ inputs.style }}"
291-
--extensions=${{ inputs.extensions }}
292-
--tidy-checks="${{ inputs.tidy-checks }}"
293-
--repo-root=${{ inputs.repo-root }}
294-
--version=${{ inputs.version }}
295-
--verbosity=${{ inputs.verbosity }}
296-
--lines-changed-only=${{ inputs.lines-changed-only }}
297-
--files-changed-only=${{ inputs.files-changed-only }}
298-
--thread-comments=${{ inputs.thread-comments }}
299-
--no-lgtm=${{ inputs.no-lgtm }}
300-
--step-summary=${{ inputs.step-summary }}
301-
--ignore="${{ inputs.ignore }}"
302-
--ignore-tidy="${{ inputs.ignore-tidy }}"
303-
--ignore-format="${{ inputs.ignore-format }}"
304-
--database=${{ inputs.database }}
305-
--file-annotations=${{ inputs.file-annotations }}
306-
--extra-arg="${{ inputs.extra-args }}"
307-
--tidy-review="${{ inputs.tidy-review }}"
308-
--format-review="${{ inputs.format-review }}"
309-
--passive-reviews="${{ inputs.passive-reviews }}"
310-
--jobs=${{ inputs.jobs }}
270+
if ((sys host | get 'name') == 'Windows') {
271+
^powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/0.8.9/install.ps1 | iex"
272+
} else {
273+
^curl -LsSf https://astral.sh/uv/install.sh | sh
274+
}
311275
312-
- name: Run cpp-linter (Windows)
313-
id: cpp-linter-windows
314-
shell: pwsh
315-
env:
316-
UV_PROJECT_ENVIRONMENT: ${{ github.action_path }}
317-
UV_INSTALL_DIR: ${{ github.action_path }}/bin
318-
run: >-
319-
${{ env.UV_INSTALL_DIR }}/uv run
320-
cpp-linter
321-
--style="${{ inputs.style }}"
322-
--extensions=${{ inputs.extensions }}
323-
--tidy-checks="${{ inputs.tidy-checks }}"
324-
--repo-root=${{ inputs.repo-root }}
325-
--version=${{ inputs.version }}
326-
--verbosity=${{ inputs.verbosity }}
327-
--lines-changed-only=${{ inputs.lines-changed-only }}
328-
--files-changed-only=${{ inputs.files-changed-only }}
329-
--thread-comments=${{ inputs.thread-comments }}
330-
--no-lgtm=${{ inputs.no-lgtm }}
331-
--step-summary=${{ inputs.step-summary }}
332-
--ignore="${{ inputs.ignore }}"
333-
--ignore-tidy="${{ inputs.ignore-tidy }}"
334-
--ignore-format="${{ inputs.ignore-format }}"
335-
--database=${{ inputs.database }}
336-
--file-annotations=${{ inputs.file-annotations }}
337-
--extra-arg="${{ inputs.extra-args }}"
338-
--tidy-review="${{ inputs.tidy-review }}"
339-
--format-review="${{ inputs.format-review }}"
340-
--passive-reviews="${{ inputs.passive-reviews }}"
341-
--jobs=${{ inputs.jobs }}
276+
^$'($env.UV_INSTALL_DIR)/uv' sync --directory $action_path --group action
277+
^$'($env.UV_INSTALL_DIR)/uv' run clang-tools -i ${{ inputs.version }} -b
278+
279+
- name: Run cpp-linter
280+
id: cpp-linter
281+
shell: nu {0}
282+
run: |-
283+
let action_path = (
284+
$env.GITHUB_ACTION_PATH
285+
| str trim --right --char '/'
286+
)
287+
$env.UV_INSTALL_DIR = $action_path | path join 'bin'
288+
$env.UV_PROJECT_ENVIRONMENT = $action_path | path join '.venv'
289+
290+
let args = [
291+
--style="${{ inputs.style }}"
292+
--extensions=${{ inputs.extensions }}
293+
--tidy-checks="${{ inputs.tidy-checks }}"
294+
--repo-root=${{ inputs.repo-root }}
295+
--version=${{ inputs.version }}
296+
--verbosity=${{ inputs.verbosity }}
297+
--lines-changed-only=${{ inputs.lines-changed-only }}
298+
--files-changed-only=${{ inputs.files-changed-only }}
299+
--thread-comments=${{ inputs.thread-comments }}
300+
--no-lgtm=${{ inputs.no-lgtm }}
301+
--step-summary=${{ inputs.step-summary }}
302+
--ignore="${{ inputs.ignore }}"
303+
--ignore-tidy="${{ inputs.ignore-tidy }}"
304+
--ignore-format="${{ inputs.ignore-format }}"
305+
--database=${{ inputs.database }}
306+
--file-annotations=${{ inputs.file-annotations }}
307+
--extra-arg="${{ inputs.extra-args }}"
308+
--tidy-review="${{ inputs.tidy-review }}"
309+
--format-review="${{ inputs.format-review }}"
310+
--passive-reviews="${{ inputs.passive-reviews }}"
311+
--jobs=${{ inputs.jobs }}
312+
]
313+
314+
$'($env.UV_INSTALL_DIR)/uv' run cpp-linter ...$args

0 commit comments

Comments
 (0)