diff --git a/.github/workflows/Container.yml b/.github/workflows/Container.yml deleted file mode 100644 index e80bf1f..0000000 --- a/.github/workflows/Container.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Container - -on: - push: - pull_request: - workflow_dispatch: - schedule: - - cron: '0 0 * * 3' - -jobs: - - container: - runs-on: ubuntu-latest - env: - IMAGE: ghcr.io/chipsalliance/verible-linter-action - steps: - - - uses: actions/checkout@v2 - - - name: Build container image - run: docker build -t $IMAGE . - - - name: Login to GitHub Container Registry (GHCR) - if: github.event_name != 'pull_request' && github.repository == 'chipsalliance/verible-linter-action' - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: gha - password: ${{ github.token }} - - - name: Push container image to GitHub Container Registry (GHCR) - if: github.event_name != 'pull_request' && github.repository == 'chipsalliance/verible-linter-action' - run: docker push $IMAGE diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 06668cf..0000000 --- a/Dockerfile +++ /dev/null @@ -1,43 +0,0 @@ -FROM ubuntu:20.04 - -RUN apt-get update -qq \ - && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \ - ca-certificates \ - curl \ - git \ - golang-go \ - jq \ - python3 \ - python3-click \ - python3-unidiff \ - wget \ - && apt-get autoclean && apt-get clean && apt-get -y autoremove \ - && update-ca-certificates \ - && rm -rf /var/lib/apt/lists/* - -RUN mkdir verible \ - && curl -fsSL https://api.github.com/repos/chipsalliance/verible/releases/latest | jq '.assets[] | select(.browser_download_url | test("(?=.*Ubuntu-20.04)(?=.*x86_64)")).browser_download_url' | xargs wget -qO- | tar -zxvf - -C verible --strip-components=1 \ - && for i in ./verible/bin/*; do cp $i /bin/$(basename $i); done - -ENV GOBIN=/opt/go/bin - -# FIXME This layer might be avoid by using BuildKit and --mount=type=bind -COPY reviewdog.patch /tmp/reviewdog/reviewdog.patch - -# Install reviewdog -RUN git clone https://github.com/reviewdog/reviewdog \ - && cd reviewdog \ - && git checkout 72c205e138df049330f2a668c33782cda55d61f6 \ - && git apply /tmp/reviewdog/reviewdog.patch \ - && mkdir -p $GOBIN \ - && go install ./cmd/reviewdog \ - && cd .. \ - && rm -rf reviewdog \ - && $GOBIN/reviewdog --version - -COPY entrypoint.sh /opt/antmicro/entrypoint.sh -COPY action.py /opt/antmicro/action.py -COPY rdf_gen.py /opt/antmicro/rdf_gen.py -WORKDIR /opt/antmicro - -ENTRYPOINT ["/opt/antmicro/entrypoint.sh"] diff --git a/README.md b/README.md index c100947..bc7be3a 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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 }} ``` diff --git a/action.yml b/action.yml index c1f99aa..94d05ac 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/entrypoint.sh b/entrypoint.sh index af2438c..685041f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 '*' @@ -35,7 +37,7 @@ 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" \ @@ -43,26 +45,26 @@ if [ "$INPUT_SUGGEST_FIXES" = "true" ]; then --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" \