stoplightio / spectral-action

GitHub Action wrapper for Spectral - a JSON/YAML/OpenAPI/AsyncAPI/etc linter with custom rule support.
https://stoplight.io/open-source/spectral
Apache License 2.0
89 stars 47 forks source link

Host spectral in a pre-built container image #452

Open mzabaluev opened 3 years ago

mzabaluev commented 3 years ago

User story.

As a workflow user, I should not wait while spectral is being rebuilt into a Docker container for every run, so that I can enjoy super-fast job completion times.

Is your feature request related to a problem?

The action rebuilds and sets up Spectral in its entirety into a Docker image, with no caching seemingly occurring between job runs. This costs about 1.5 minutes for every job, not to mention taxing the public infrastructure of npm, Docker Hub, and possibly other web resources.

Describe the solution you'd like

Don't know the details of how actions can deploy containers, but I would imagine building a Docker image once per spectral update (or any change in the Dockerfile), pushing it to a registry (the one provided by GitHub, to keep things close?) and then pulling it in the action would speed up the jobs.

jiridj commented 2 years ago

Why use a container at all? Wouldn't using plain NodeJS instead of Docker make it even faster as no container needs to be pulled?

rapita commented 2 years ago

I had the same problem.

Building docker image by stoplightio/spectral-action on every workflow trigger - is a very sub-optimal solution. 100 runs - 100 minutes only for building docker image OMG...

Solved by:

      - name: Run Spectral Lint
        uses: addnab/docker-run-action@v3
        with:
          image: stoplight/spectral:latest
          options: -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }}
          run: spectral lint --ruleset ./docs/spectral/bundled.spectral.yml ./docs/specification/*.yaml

Results: Build addnab/docker-run-action@v3 - 8s Run Spectral Lint - 6s