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.
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: AVC .version file validation
on:
push:
branches:
- master
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@master
Make sure workflows are activated in your repository settings: The top radio button should be selected.
Workflow files support passing parameters to the executed Actions using the with
property,
The following options are available for the KSP-AVC Version File Validator:
To exclude files, add a JSON array containing the paths to the files (relative from repo root) as exclude
parameter after - name: Validate files
:
with:
exclude: '["./GameData/BundledMod/BundledMod.version", "./GameData/OtherBundledMod/**/*.version"]'
You can use globbing statements, for the syntax see the pathlib documentation.
If you only want to test a specific set of files, you can use the only
parameter. Can't be used together with exclude
!
with:
only: '["./GameData/YourMod/YourMod.version"]'
You need Python 3.8 or above installed! Setup:
git clone https://github.com/DasSkelett/AVC-VersionFileValidator.git
cd AVC-VersionFileValidator
python3.10 -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.
I recommend setting up a virtual environment, especially if you are using an IDE:
python3.10 -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!
This project uses unittest
, which is part of the Python stdlib.
If you want to run the unit tests using Docker:
docker build --target tests -t avc-versionfilevalidator . && docker run avc-versionfilevalidator
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.