DEV Community

loading...

Package Validator for V

delta456 profile image Swastik Baranwal ・2 min read

This workflow is a package validator for V Language. It uses V Actions for building and using V for Windows 10, Ubuntu 18.04 LTS and MacOS. This is a pretty simple workflow as V is really a new language and most things are handled by V itself!

It took a lot of time to create as I was backed by the limitations of V so I had to tell the creator about these issues which he fixed it in his free time but of course he couldn't solve all.

More things will be added soon. Any suggestions are welcome!

My Workflow

I am using this as my Actions for V as its made by the community.

GitHub logo nocturlab / setup-vlang-action

Github Action that allow you to compile v programs without the use of docker (because it's very slow)

Setup V environment Latest version Build Tests

GitHub Action that allows you to compile V programs without the use of Docker (because it's very slow).

Usage

You just have to setup your workflow like this:

# file: .github/workflows/vlang-build-pipeline.yml
name: vlang-build-pipeline

on:
  push:
    paths-ignore:
      - '**.md'

jobs:
  run:
    name: Run
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Set up V version latest
      uses: nocturlab/setup-vlang-action@v1
      with:
        v-version: latest
      id: v
    - name: Build repository app
      run: v .
    - name: Run V tests
      run: v test .

Inputs

  • v-version: V version. Can be either exact version number, latest (by default), or master (use the master branch instead of release).



Submission Category:

Maintainer Must-Haves

Yaml File or Link to Code

name: CI
on:
  push:
    branches: [master]
  pull_request:
    types: [opened, synchronize]
jobs:  
 test:
  name: Run tests on ${{ matrix.os }} ${{ matrix.v-version }}
  strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        v-version: [master, latest]
  runs-on: ${{ matrix.os }}
  steps:
      - uses: actions/checkout@v1
      - uses: nocturlab/setup-vlang-action@master
        with:
          v-version: master
      - name: Run vet
        run: v vet .
      - name: Run tests
        run: v test .
      - name: vfmt verify
        run: v fmt -verify -diff *.v

How it works

This workflow uses the master branch of V repo. It goes through all the .v files in the current directory which includes vet i.e. find unnecessary code which can be optimized, test which tests all files with __test as suffix and fmt which formats the code but here we are using using -verify flag to see it's the files are formatted or not.

Currently v fmt -verify -diff shows the diff of the original and formatted files as -verify doesn't assert true even though they are formatted, its due to line endings. (LF v/s CRLF)

Additional Resources / Info

Example of Repo using it:

GitHub logo v-community / repo_template

Template for V Repos

V Repo Template

Template for V Repos

CI GitHub Release

Purpose

This repo template tries to solve the complexity behind creating V repos as many people don't how to make one or people are lazy.

Overview

  • Makefile for formatting files, running examples and tests
  • GitHub Actions workflow for V
  • v.mod A file for initalising V projects
  • MIT License for Repo (though you can change the license)
  • A .gitignore made for V
  • ISSUE_TEMPLATE, CODE_OF_CONDUCT etc written
  • More things coming soon...

Installation

git clone https://github.com/v-community/repo_template

Acknowledgments

Thanks to moul/golang-template for his ISSUE_TEMPLATE and other things written by him and inspiration.

License

Licensed under MIT

Contributing

Contribution is welcome. Please read Code of Conduct.

Discussion (0)

pic
Editor guide