Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
play

GitHub Action

KSP-AVC Version File Validator

v1.3.0

KSP-AVC Version File Validator

play

KSP-AVC Version File Validator

Validate the KSP-AVC .version file of your mod against the AVC schema

Installation

Copy and paste the following snippet into your .yml file.

              

- name: KSP-AVC Version File Validator

uses: DasSkelett/[email protected]

Learn more about this action in DasSkelett/AVC-VersionFileValidator

Choose a version

KSP-AVC Version File Validator

Unit Tests Full Integration Test

This repository hosts a Docker-based GitHub Action written in Python3.8 that you can use in a workflow in your KSP mod repo. It will validate all KSP-AVC version files in the repository against the official KSP-AVC schema.

This is intended for authors and maintainers of Kerbal Space Program mods.

No more missing commas that prevent your latest release from being indexed by the CKAN.

Usage

In a GitHub workflow (default)

Download the standard workflow file and save it under <YourMod>/.github/workflows/AVC-VersionFileValidator.yml. Then commit and push it to GitHub.

Alternatively, copy the following and put it in <YourMod>/.github/workflows/AVC-VersionFileValidator.yml.

name: Validate AVC .version files
on:
  push:
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  validate_version_files:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v2
        with:
          fetch-depth: 1
      - name: Validate files
        uses: DasSkelett/AVC-VersionFileValidator

Make sure workflows are activated in your repository settings: workflow settings The top radio button should be selected.

To exclude files, add a JSON array containing the paths to the files (relative from repo rooot) as exclude parameter after - name: Validate files:

        with:
          exclude: '["./invalid.version", "./test/corruptVersionFiles/**/*.version"]'

You can also use globbing statements, for the syntax see syntax, see the pathlib documentation.

For more workflow file examples, see the examples folder.

Outside of a GitHub action, like locally or in Travis

You need Python 3.8 installed! Setup:

git clone https://github.com/DasSkelett/AVC-VersionFileValidator.git
cd AVC-VersionFileValidator
python3.8 -m venv venv
source venv/bin/activate
pip install --upgrade -r requirements.txt

Now use the validator. Make sure you have the venv activated!

python main.py ../<YourMod>/GameData/<YourMod>/<YourMod>.version

Alternatively, if there are more version files to be checked, switch your working directory to the root of your repo and execute main.py from there. It will search for version files recursively.

cd ../<YourMod>
python ../AVC-VersionFileValidator/main.py

Furthermore, if you use an IDE that supports custom JSON schemas, I strongly recommend using this feature.

Development

Setup development environment

I recommend setting up a virtual environment, especially if you are using an IDE:

python3.8 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

The Action itself is a Docker image/container (requirement by GitHub). You can use the same Dockerfile for running it locally, but remember to set the right environment variables if needed .

The repository is set up in a way that supports running the app directly or in a Docker container. Same goes for the tests. You only have to pay attention what your current working directory is when you invoke Python!

Testing

This project uses unittest, which is part of the Python stdlib.

Run tests in Docker Container

If you want to run the unit tests using Docker:

docker build --target tests -t avc-versionfilevalidator . && docker run avc-versionfilevalidator

Without Docker Container

If you want to run the unit tests on your host, do the following (remember venv!):

python -m unittest tests

Note that the test framework assumes that your current working directory is this project's root.