The example below shows how to set up a basic pipeline for Deno projects in GitHub Actions:

    All this pipeline does at the moment is set up GitHub Actions and Deno, and it is configured to trigger a workflow run on push and pull request events. Note that in the example the latest version of ubuntu image is used, but you could specify an exact version for added stability in a production pipeline, such as ubuntu-20.04.

    To expand the workflow you can add any of the deno CLI commands that you might need. The code below shows how to check the formatting, lint the code, run the tests and generate a test coverage report, all as part of a build job:

    1. jobs:
    2. build:
    3. runs-on: ubuntu-20.04
    4. steps:
    5. - name: Setup Actions
    6. uses: actions/checkout@v2
    7. - name: Setup Deno
    8. uses: denoland/setup-deno@v1.0.0
    9. with:
    10. deno-version: v1.x
    11. run: deno fmt --check
    12. - name: Analyze code
    13. run: deno lint
    14. - name: Run unit and integration tests
    15. run: deno test -A --coverage=cov --doc
    16. - name: Generate coverage report
    17. run: deno coverage --lcov cov > cov.lcov
    1. - name: Check formatting

    This simply checks if the project code is formatted according to Deno’s default formatting conventions.

    In this step the deno lint command checks for syntax and style errors. If necessary, you can pass a deno.json configuration file with custom linter rules.

    1. - name: Run unit and integration tests
    2. run: deno test -A --coverage=cov --doc

    Here, Deno runs some tests with a lot of options being passed along! This example runs with all permissions (-A) but in reality you may only need a subset of permissions to run your tests, such as --allow-read or --allow-env. Test coverage is generated with --coverage into an output directory and finally, --doc is provided to typecheck any code blocks in the project’s documentation.

    1. - name: Generate coverage report
    2. run: deno coverage --lcov cov > cov.lcov

    As a Deno module maintainer, you probably want to know that your code works on all of the major operating systems in use today: Linux, MacOS and Windows. A Cross-platform workflow can be achieved by running a matrix of parallel jobs in GitHub Actions, each one running your build on a different operating system:

    There can be parts of the pipeline that don’t make sense to run for every OS. For example, generating the same coverage report on Linux, MacOS and Windows is a bit redundant. You can use the conditional if keyword in these cases to reduce repetition:

    1. - name: Generate coverage report
    2. if: ${{ matrix.os == 'ubuntu-latest' }}
    3. run: deno coverage --lcov cov > cov.lcov
    1. - name: Upload coverage report
    2. if: ${{ matrix.os == 'ubuntu-latest' }}
    3. uses: coverallsapp/github-action@master
    4. with:
    5. github-token: ${{ secrets.GITHUB_TOKEN }}