Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: init #1251

Merged
merged 2 commits into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"jobs":{"black":{"runs-on":"ubuntu-latest","steps":[{"name":"Checkout","uses":"actions/checkout@v2"},{"name":"Nix","uses":"cachix/install-nix-action@v7"},{"name":"Black","run":"nix-shell --run \"black . --check --diff\""}]},"build":{"runs-on":"ubuntu-latest","steps":[{"name":"Checkout","uses":"actions/checkout@v2"},{"name":"Nix","uses":"cachix/install-nix-action@v7"},{"name":"Build","run":"nix-build --quiet release.nix -A build.x86_64-linux -I nixpkgs=channel:19.09"}]},"ciCheck":{"runs-on":"ubuntu-latest","steps":[{"name":"Checkout","uses":"actions/checkout@v2"},{"name":"Nix","uses":"cachix/install-nix-action@v7"},{"name":"Check CI","run":"cp ./.github/workflows/ci.yml /tmp/ci.reference.yml\nnix-build ci.nix --no-out-link | bash\ndiff ./.github/workflows/ci.yml /tmp/ci.reference.yml || exit 1\n"}]},"coverage":{"runs-on":"ubuntu-latest","steps":[{"name":"Checkout","uses":"actions/checkout@v2"},{"name":"Nix","uses":"cachix/install-nix-action@v7"},{"name":"Coverage","run":"nix-shell --exclude tarball --run \"./coverage-tests.py -a '!libvirtd,!gce,!ec2,!azure' -v\""}]},"mypy":{"runs-on":"ubuntu-latest","steps":[{"name":"Checkout","uses":"actions/checkout@v2"},{"name":"Nix","uses":"cachix/install-nix-action@v7"},{"name":"MyPy","run":"nix-shell --run \"mypy nixops\""}]},"parsing":{"runs-on":"ubuntu-latest","steps":[{"name":"Checkout","uses":"actions/checkout@v2"},{"name":"Nix","uses":"cachix/install-nix-action@v7"},{"name":"Parsing","run":"find . -name \"*.nix\" -exec nix-instantiate --parse --quiet {} >/dev/null +"}]}},"name":"CI","on":{"push":{"branches":["*"]}}}
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

58 changes: 58 additions & 0 deletions ci.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{ lib ? import <nixpkgs/lib>
, pkgs ? import <nixpkgs> {}
}:
with builtins; with lib;
let
ciPath = "./.github/workflows/ci.yml";
checkout = {
name = "Checkout";
uses = "actions/checkout@v2";
};
nix = {
name = "Nix";
uses = "cachix/install-nix-action@v7";
};
mkJob = extraSteps: {
runs-on = "ubuntu-latest";
steps = [ checkout nix ] ++ extraSteps;
};
ci = {
on.push.branches = [ "*" ];
name = "CI";
jobs = {
parsing = mkJob [{
name = "Parsing";
run = "find . -name \"*.nix\" -exec nix-instantiate --parse --quiet {} >/dev/null +";
}];
mypy = mkJob [{
name = "MyPy";
run = "nix-shell --run \"mypy nixops\"";
}];
black = mkJob [{
name = "Black";
run = "nix-shell --run \"black . --check --diff\"";
}];
coverage = mkJob [{
name = "Coverage";
run = "nix-shell --exclude tarball --run \"./coverage-tests.py -a '!libvirtd,!gce,!ec2,!azure' -v\"";
}];
build = mkJob [{
name = "Build";
run = "nix-build --quiet release.nix -A build.x86_64-linux -I nixpkgs=channel:19.09";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since release.nix already has a default nixpkgs, isn't adding -I nixpkgs=... asking for trouble?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was copied over from .travis.yml

}];
ciCheck = mkJob [{
name = "Check CI";
run = ''
cp ${ciPath} /tmp/ci.reference.yml
nix-build ci.nix --no-out-link | bash
diff ${ciPath} /tmp/ci.reference.yml || exit 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generated yml/json file is one long line. Perhaps prettifying it with jq makes it more readable and results in easier to read diffs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferring to @grahamc, I'd be fine with that

'';
}];
};
};
generated = pkgs.writeText "ci.yml" (builtins.toJSON ci);
in
pkgs.writeShellScript "gen_ci" ''
mkdir -p "$(dirname ${ciPath})"
cat ${generated} > ${ciPath}
''