Skip to content

Commit

Permalink
Merge pull request #26 from antmicro/rkol/verible-version-variable
Browse files Browse the repository at this point in the history
Convert action from Docker to composite
  • Loading branch information
tgorochowik authored Mar 22, 2023
2 parents e765819 + 76aa931 commit 68df99c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 85 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/Container.yml

This file was deleted.

43 changes: 0 additions & 43 deletions Dockerfile

This file was deleted.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ If you don't wish to use the automatic PR review,
you can omit the ``github_token`` input.
If you'd like to use a reporter of reviewdog other than ``github-pr-review``,
you can pass its name in the input ``reviewdog_reporter``.
If you want to declare Verible version to be used,
you can pass its release tag in the input ``verible_version``.

Here's a basic example to lint all ``*.v`` and ``*.sv`` files:
```yaml
Expand All @@ -34,7 +36,7 @@ jobs:
```
You can provide optional arguments to specify paths, exclude paths,
a config file and extra arguments for ``verible-verilog-lint``.
a config file, Verible version and extra arguments for ``verible-verilog-lint``.
```yaml
- uses: chipsalliance/verible-linter-action@main
Expand All @@ -46,6 +48,7 @@ a config file and extra arguments for ``verible-verilog-lint``.
exclude_paths: |
./rtl/some_file
extra_args: "--check_syntax=true"
verible_version: "v0.0-3100-gd75b1c47"
github_token: ${{ secrets.GITHUB_TOKEN }}
```
Expand Down
48 changes: 46 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,52 @@ inputs:
fail_on_error:
description: 'Fail the action when rule violations are found'
default: 'false'
verible_version:
description: 'Use selected Verible version (defaults to latest release)'
default: 'latest'


runs:
using: 'docker'
image: 'docker://ghcr.io/chipsalliance/verible-linter-action'
using: 'composite'
steps:
- name: Install dependencies
shell: bash
run: |
sudo apt-get update -qq
sudo apt-get -y install --no-install-recommends ca-certificates curl git golang-go jq python3 python3-click python3-unidiff wget
sudo update-ca-certificates
- name: Download Verible
shell: bash
run: |
mkdir verible
if [ "${{ inputs.verible_version }}" = "latest" ]; then
VERIBLE_TARBALL=$(curl -fsSL https://api.github.com/repos/chipsalliance/verible/releases/latest | jq -r '.assets[] | select(.browser_download_url | test("(?=.*Ubuntu-20.04)(?=.*x86_64)")).browser_download_url')
else
VERIBLE_TARBALL="https://github.com/chipsalliance/verible/releases/download/${{ inputs.verible_version }}/verible-${{ inputs.verible_version }}-Ubuntu-20.04-focal-x86_64.tar.gz"
fi
echo "Downloading $VERIBLE_TARBALL"
wget -qO- $VERIBLE_TARBALL | tar -zxvf - -C verible --strip-components=1
for i in ./verible/bin/*; do sudo cp $i /usr/local/bin/$(basename $i); done
- name: Build reviewdog
shell: bash
run: |
git clone https://github.com/reviewdog/reviewdog
cd reviewdog
git checkout 72c205e138df049330f2a668c33782cda55d61f6
git apply ${{ github.action_path }}/reviewdog.patch
go build ./cmd/reviewdog
cd ..
./reviewdog/reviewdog --version
- name: Run linter
shell: bash
env:
INPUT_CONFIG_FILE: ${{ inputs.config_file }}
INPUT_EXCLUDE_PATHS: ${{ inputs.exclude_paths }}
INPUT_EXTRA_ARGS: ${{ inputs.extra_args }}
INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }}
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
INPUT_LOG_FILE: ${{ inputs.log_file }}
INPUT_PATHS: ${{ inputs.paths }}
INPUT_REVIEWDOG_REPORTER: ${{ inputs.reviewdog_reporter }}
INPUT_SUGGEST_FIXES: ${{ inputs.suggest_fixes }}
run: ${{ github.action_path }}/entrypoint.sh
14 changes: 8 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

set -e

ACTION_PATH=`dirname "$0"`

event_file=event.json
diff_cmd="git diff FECH_HEAD"
diff_cmd="git diff FETCH_HEAD"

# XXX: workaround for "fatal: detected dubious ownership in repository" when running in a container
git config --global --add safe.directory '*'
Expand Down Expand Up @@ -35,34 +37,34 @@ rdf_log=$(mktemp)
if [ "$INPUT_SUGGEST_FIXES" = "true" ]; then
echo "suggesting fixes"
patch=$(mktemp)
/opt/antmicro/action.py \
$ACTION_PATH/action.py \
--conf-file "$INPUT_CONFIG_FILE" \
--extra-opts "$INPUT_EXTRA_ARGS" \
--exclude-paths "$INPUT_EXCLUDE_PATHS" \
--log-file "$INPUT_LOG_FILE" \
--patch "$patch" \
"$INPUT_PATHS"

/opt/antmicro/rdf_gen.py \
$ACTION_PATH/rdf_gen.py \
--efm-file "$INPUT_LOG_FILE" \
--diff-file "$patch" > "$rdf_log"
rm "$patch"
else
echo "not suggesting fixes"
/opt/antmicro/action.py \
$ACTION_PATH/action.py \
--conf-file "$INPUT_CONFIG_FILE" \
--extra-opts "$INPUT_EXTRA_ARGS" \
--exclude-paths "$INPUT_EXCLUDE_PATHS" \
--log-file "$INPUT_LOG_FILE" \
"$INPUT_PATHS"

/opt/antmicro/rdf_gen.py \
$ACTION_PATH/rdf_gen.py \
--efm-file "$INPUT_LOG_FILE" > "$rdf_log"
fi

echo "Running reviewdog"

"$GOBIN"/reviewdog -f=rdjson \
./reviewdog/reviewdog -f=rdjson \
-reporter="$INPUT_REVIEWDOG_REPORTER" \
-fail-on-error="$INPUT_FAIL_ON_ERROR" \
-name="verible-verilog-lint" \
Expand Down

0 comments on commit 68df99c

Please sign in to comment.