项目作者: jchristgit

项目描述 :
simple, lightweight CI service for use with gitea
高级语言: Python
项目地址: git://github.com/jchristgit/fling.git
创建时间: 2019-09-08T13:45:28Z
项目社区:https://github.com/jchristgit/fling

开源协议:

下载


fling

A wrapper around systemd-nspawn and debootstrap for running isolated tests.
Can be run for local builds, and also ships a web server for usage with gitea.

A sample configuration file for testing bolt

  1. [fling]
  2. commands =
  3. service postgresql start
  4. su postgres -s /bin/sh -c 'psql -c "CREATE USER bolt PASSWORD '"'"'bolt'"'"' SUPERUSER" -d postgres'
  5. su postgres -s /bin/sh -c 'psql -c "CREATE DATABASE bolt_test OWNER bolt" -d postgres'
  6. export MIX_ENV=test
  7. export PGSQL_TEST_URL=postgres://bolt:bolt@/bolt_test
  8. mix local.hex --force
  9. mix local.rebar --force
  10. mix deps.get
  11. mix deps.compile
  12. mix compile
  13. packages = ca-certificates,elixir,erlang,git,postgresql-11

The packages specified in packages will be cached across invocations.
commands are simply run via shell.

Local usage

Head to your project directory and execute python3 -m fling build as root.

Usage with Gitea

  • Create a token in Gitea’s “Application” settings
    (user/settings/applications)
  • Start fling with the generated --gitea-token, ensure it is reachable to
    Gitea
  • Configure a webhook in your repository to point to
    http://<FLING_ADDR>/hook/gitea
  • Configure fling in your repository. See the configuration example above.

Configure root to have SSH keys to clone repositories you want to use it on.

Then, see python3 -m fling server --help for usage. Do not bind fling on a public IP
address.

Once the server is running, add a webhook on your repositories to test, pointing
to the address of the fling server, path /hook/gitea.

Execution

When fling receives a build via its webhook route /hook/gitea, it performs
the following:

  • prepare a workspace (checkout the commit to build locally)
  • load build configuration (from the default branch or the commit to build, see
    --trust)
  • prepares Debian Stable in a chroot if the current one is outdated [1], this is
    called the template machine
  • runs build commands in an ephemeral snapshot of the template machine

The commit status is updated on Gitea along the way.

[1] these are determined outdated in two cases: if the directory does not exist
at all, it is always considered outdated and recreated. Otherwise, fling
compares a hashsum of the configuration the image was built with with the
configuration that is desired, and if they mismatch, recreates the image

Dependencies

  • Python 3
  • debootstrap
  • systemd-nspawn
  • git
  • root access

Setup