Vikunja uses Mage to script common development tasks and even releasing. Mage is a pure go solution which allows for greater flexibility and things like better parallelization.
This document explains what tasks are available and what they do.
Installation #
To use mage, you'll need to install the mage cli. To install it, run the following command:
go install github.com/magefile/mageCategories #
There are multiple categories of subcommands in the magefile:
build: Contains commands to build a single binarycheck: Contains commands to statically check the source coderelease: Contains commands to release Vikunja with everything that's requiredtest: Contains commands to run all kinds of testsdev: Contains commands to run development tasksmisc: Commands which do not belong in either of the other categories
CI #
These tasks are automatically run in our CI every time someone pushes to main or you update a pull request:
mage lintmage build:build
Build #
Build Vikunja #
mage buildBuilds a vikunja-binary in the root directory of the repo for the platform it is run on.
clean #
mage build:cleanCleans all build and executable files
Check #
All check sub-commands exit with a status code of 1 if the check fails.
Various code-checks are available:
mage check:all: Runs golangci and swagger documentation checkmage lint: Checks if the code follows the rules as defined in the.golangci.ymlconfig file.mage lint:fix: Fixes all code style issues which are easily fixable.
Release #
Build Releases #
mage releaseBuilds binaries for all platforms and zips them with a copy of the templates/ folder. All built zip files are stored into dist/zips/. Binaries are stored in dist/binaries/, binaries bundled with templates are stored in dist/releases/.
All cross-platform binaries built using this series of commands are built with the help of xgo. The mage command will automatically install the binary to be able to use it.
mage release:release is a shortcut to execute mage release:dirs release:windows release:linux release:darwin release:copy release:check release:os-package release:zip.
mage release:dirscreates all directories neededmage release:windows/release:linux/release:darwinexecute xgo to build for their respective platformsmage release:copybundles binaries with a copy of theLICENSEand sample config files to then be zippedmage release:checkcreates sha256 checksums for each binary which will be included in the zip filemage release:os-packagebundles a binary with thesha256checksum file, a sampleconfig.ymland a copy of the license in a folder for each architecturemage release:compresscompresses all build binaries withupxto save spacemage release:zippackages a zip file for the files created byrelease:os-package
Build os packages #
mage release:packagesWill build .deb, .rpm and .apk packages to dist/os-packages.
Make a debian repo #
mage release:repreproTakes an already built debian package and creates a debian repo structure around it.
Used to be run inside a docker container in the CI process when releasing.
Test #
unit #
mage test:unitRuns all tests except integration tests.
coverage #
mage test:coverageRuns all tests except integration tests and generates a coverage.html file to inspect the code coverage.
integration #
mage test:integrationRuns all integration tests.
Dev #
Create a new migration #
mage dev:create-migrationCreates a new migration with the current date. Will ask for the name of the struct you want to create a migration for.
See also migration docs.
Generate documentation #
Swagger docs #
mage generate:swagger-docsGenerates swagger definitions from the comment annotations in the code.
config.yml sample file #
mage generate:config-yamlThis generates a config.yml.sample file from the content in config-raw.json file. This happens automatically when building packages and only really needs to happen at that time.
Misc #
Format the code #
mage fmtFormats all source code using go fmt.