Skip to content

Commit

Permalink
fix: Build packages by cycle / Push builds to Cachix (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
sestrella authored Mar 4, 2024
1 parent 9049e26 commit efba3eb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
28 changes: 19 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,22 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 20
strategy:
matrix:
# INFO: This is only a workaround to avoid timeout issues with the CI;
# whether it becomes a definitive solution or not will require a
# separate discussion with Oscar.
cycle:
- "all-1.7"
- "all-1.6"
- "all-1.5"
- "all-1.4"
- "all-1.3"
- "all-1.2"
- "all-1.1"
- "all-1.0"
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -25,19 +40,14 @@ jobs:
name: nixpkgs-terraform
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
skipPush: false
- name: Setup Dhall
uses: dhall-lang/setup-dhall@v4
with:
version: '1.42.0'
- name: Build packages
run: |
build_command="nix flake check --impure --max-jobs auto --cores 0 --keep-going"
if dhall resolve --file /home/runner/.config/cachix/cachix.dhall | grep -q authToken; then
if grep -q authToken ~/.config/cachix/cachix.dhall; then
echo "Cachix token is present"
cachix watch-exec nixpkgs-terraform -- $build_command
cachix watch-exec nixpkgs-terraform nix -- build .#\"${{ matrix.cycle }}\" --impure
else
echo "Cachix token is not present"
$build_command
nix build .#\"${{ matrix.cycle }}\" --impure
fi
env:
NIXPKGS_ALLOW_UNFREE: 1
Expand Down
24 changes: 23 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,29 @@
pkgs-unstable = inputs.nixpkgs-unstable.legacyPackages.${system};
};

packages = import ./lib/packages.nix { inherit pkgs pkgs-unstable; custom-lib = self.lib; };
packages =
let
versions = import ./lib/packages.nix { inherit pkgs pkgs-unstable; custom-lib = self.lib; };
linkPackagesByCycle = versionsPerCycle: builtins.mapAttrs
(cycle: cycleVersions: pkgs.symlinkJoin {
name = "terraform-all-${cycle}";
paths = builtins.map (version: versions.${version}) cycleVersions;
})
versionsPerCycle;
groupVersionsByCycle = versions: builtins.groupBy
(version:
let
splittedVersion = builtins.splitVersion version;
in
"all-" + (builtins.concatStringsSep "." [
(builtins.elemAt splittedVersion 0)
(builtins.elemAt splittedVersion 1)
])
)
(builtins.attrNames versions);
cycles = linkPackagesByCycle (groupVersionsByCycle versions);
in
versions // cycles;

overlayAttrs = {
terraform-versions = config.packages;
Expand Down

0 comments on commit efba3eb

Please sign in to comment.