Make git-based deps check out all submodules #185
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
# Trigger the workflow on push or pull request, but only for the master branch | |
on: | |
pull_request: | |
push: | |
branches: [main] | |
jobs: | |
# This workflow defines two different jobs that are very similar: | |
# nix-commit-from-ci and nix-commit-from-flake-lock. | |
# | |
# The difference is what version of stacklock2nix is used in the | |
# my-example-haskell-lib-easy/flake.lock and | |
# my-example-haskell-lib-advanced/flake.lock files. | |
# | |
# nix-commit-from-ci uses the stacklock2nix dependency from the code that is | |
# running through CI. This is what you'd expect to be tested. | |
# | |
# nix-commit-from-flake-lock uses the version of stacklock2nix that is locked | |
# in the respective flake.lock files. | |
# | |
# This is only necessary because Nix's relative-path support for flakes is broken: | |
# | |
# - https://github.com/NixOS/nix/issues/3978 | |
# - https://discourse.nixos.org/t/relative-path-support-for-nix-flakes/18795 | |
# | |
# Because Nix's relative-path support for flakes is broken, the | |
# my-example-haskell-lib-easy/flake.lock and | |
# my-example-haskell-lib-advanced/flake.lock files are locked to | |
# the upstream stacklock2nix repo on GitHub, instead of just the repository top-level | |
# flake.nix. | |
# | |
# It is necessary to test these two Haskell projects against the version of | |
# stacklock2nix that is locked in the two flake.lock files because end-users | |
# might try to directly use one of the Haskell projects without updating the | |
# stacklock2nix to the latest version. The expectation is that they will | |
# work as-is. | |
nix-commit-from-ci: | |
name: nix / ubuntu-latest / using stacklock2nix commit from CI | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: cachix/install-nix-action@v22 | |
- uses: DeterminateSystems/magic-nix-cache-action@v1 | |
- name: Check that easy project and advanced project are locked to same Nixpkgs | |
run: | | |
are_same=$(nix eval --impure --expr 'let easy-rev = (builtins.fromJSON (builtins.readFile ./my-example-haskell-lib-easy/flake.lock)).nodes.nixpkgs.locked.rev; advanced-rev = (builtins.fromJSON (builtins.readFile ./my-example-haskell-lib-advanced/flake.lock)).nodes.nixpkgs.locked.rev; in easy-rev == advanced-rev') | |
if [ "$are_same" != "true" ]; then | |
echo "ERROR: The ./my-example-haskell-lib-easy/flake.lock and ./my-example-haskell-lib-advanced/flake.lock files are locked to different versions of Nixpkgs" | |
exit 1 | |
fi | |
# The ./my-example-haskell-lib-easy/flake.nix is locked to the main | |
# branch of stacklock2nix, but we want to use the stacklock2nix that is | |
# currently being tested here in CI. | |
- name: "Easy Example: Update Flake stacklock2nix Input" | |
run: | | |
sed -i -e 's|^ inputs.stacklock2nix.url = .*$| inputs.stacklock2nix.url = "path:'"$(realpath ..)"'";|' ./flake.nix | |
cat ./flake.nix | |
nix flake lock --update-input stacklock2nix | |
cat ./flake.lock | |
working-directory: "./my-example-haskell-lib-easy/" | |
- name: "Advanced Example: Update Flake stacklock2nix Input" | |
run: | | |
sed -i -e 's|^ inputs.stacklock2nix.url = .*$| inputs.stacklock2nix.url = "path:'"$(realpath ..)"'";|' ./flake.nix | |
cat ./flake.nix | |
nix flake lock --update-input stacklock2nix | |
cat ./flake.lock | |
working-directory: "./my-example-haskell-lib-advanced/" | |
- name: "Easy Example: Build with Nix" | |
run: nix build -L | |
working-directory: "./my-example-haskell-lib-easy/" | |
- name: "Easy Example: Build with Cabal" | |
run: "nix develop -L --command cabal build all" | |
working-directory: "./my-example-haskell-lib-easy/" | |
- name: "Easy Example: Test with Cabal" | |
run: "nix develop -L --command cabal test all" | |
working-directory: "./my-example-haskell-lib-easy/" | |
- name: "Advanced Example: Build with Nix" | |
run: nix build -L | |
working-directory: "./my-example-haskell-lib-advanced/" | |
- name: "Advanced Example: Generate my-example-haskell-lib/my-example-haskell-lib.cabal" | |
run: "nix develop -L --command hpack my-example-haskell-lib" | |
working-directory: "./my-example-haskell-lib-advanced/" | |
- name: "Advanced Example: Build with Cabal" | |
run: "nix develop -L --command cabal build all" | |
working-directory: "./my-example-haskell-lib-advanced/" | |
- name: "Advanced Example: Test with Cabal" | |
run: "nix develop -L --command cabal test all" | |
working-directory: "./my-example-haskell-lib-advanced/" | |
- name: "Tests" | |
run: "nix-build" | |
working-directory: "./test/" | |
nix-commit-from-flake-lock: | |
name: nix / ubuntu-latest / using stacklock2nix commit from flake.lock | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: cachix/install-nix-action@v22 | |
- uses: DeterminateSystems/magic-nix-cache-action@v1 | |
- name: "Easy Example: Build with Nix" | |
run: nix build -L | |
working-directory: "./my-example-haskell-lib-easy/" | |
- name: "Easy Example: Build with Cabal" | |
run: "nix develop -L --command cabal build all" | |
working-directory: "./my-example-haskell-lib-easy/" | |
- name: "Easy Example: Test with Cabal" | |
run: "nix develop -L --command cabal test all" | |
working-directory: "./my-example-haskell-lib-easy/" | |
- name: "Advanced Example: Build with Nix" | |
run: nix build -L | |
working-directory: "./my-example-haskell-lib-advanced/" | |
- name: "Advanced Example: Generate my-example-haskell-lib/my-example-haskell-lib.cabal" | |
run: "nix develop -L --command hpack my-example-haskell-lib" | |
working-directory: "./my-example-haskell-lib-advanced/" | |
- name: "Advanced Example: Build with Cabal" | |
run: "nix develop -L --command cabal build all" | |
working-directory: "./my-example-haskell-lib-advanced/" | |
- name: "Advanced Example: Test with Cabal" | |
run: "nix develop -L --command cabal test all" | |
working-directory: "./my-example-haskell-lib-advanced/" |