From dedd9a6b6d6c6b19a00022318cb6dde0fc82e1bb Mon Sep 17 00:00:00 2001 From: Ievgen Pyrogov Date: Tue, 14 Jul 2026 17:25:32 +0200 Subject: [PATCH] Speed up Nix-based CI --- .github/workflows/ci.yml | 34 ++++++++++++++++++++++------------ .github/workflows/release.yml | 8 +++++--- flake.nix | 11 +++++++++++ 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c08395..d6e3930 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,10 @@ on: permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: test: name: Test @@ -25,47 +29,53 @@ jobs: with: path: deps key: ${{ runner.os }}-mix-deps-${{ hashFiles('mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix-deps- - name: Restore build cache uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5 with: path: _build - key: ${{ runner.os }}-mix-build-${{ hashFiles('flake.lock', 'mix.lock') }} + key: ${{ runner.os }}-mix-build-${{ hashFiles('flake.nix', 'flake.lock') }}-${{ hashFiles('mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix-build-${{ hashFiles('flake.nix', 'flake.lock') }}- - name: Restore PLT cache uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5 with: path: priv/plts - key: ${{ runner.os }}-plt-${{ hashFiles('flake.lock', 'mix.lock') }} + key: ${{ runner.os }}-plt-${{ hashFiles('flake.nix', 'flake.lock') }}-${{ hashFiles('mix.lock') }} + restore-keys: | + ${{ runner.os }}-plt-${{ hashFiles('flake.nix', 'flake.lock') }}- - name: Install dependencies - run: nix develop --command mix deps.get --check-locked + run: nix develop .#ci --command mix deps.get --check-locked - name: Compile - run: nix develop --command mix compile --warnings-as-errors + run: nix develop .#ci --command mix compile --warnings-as-errors - name: Check formatting - run: nix develop --command mix format --check-formatted + run: nix develop .#ci --command mix format --check-formatted - name: Check unused dependencies - run: nix develop --command mix deps.unlock --check-unused + run: nix develop .#ci --command mix deps.unlock --check-unused - name: Check dependency cycles - run: nix develop --command mix xref graph --format cycles --fail-above 0 + run: nix develop .#ci --command mix xref graph --format cycles --fail-above 0 - name: Run unit tests without soffice - run: nix develop --command mix test --exclude integration + run: nix develop .#ci --command mix test --exclude integration env: URP_INTEGRATION: "0" - name: Build documentation - run: nix develop --command mix docs --warnings-as-errors + run: nix develop .#ci --command mix docs --warnings-as-errors - name: Audit Hex dependencies - run: nix develop --command mix hex.audit + run: nix develop .#ci --command mix hex.audit - name: Run dialyzer - run: nix develop --command mix dialyzer + run: nix develop .#ci --command mix dialyzer - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4 @@ -88,6 +98,6 @@ jobs: timeout 30 bash -c 'until nc -z localhost 2002; do sleep 1; done' - name: Run integration tests - run: nix develop --command mix test --include integration --include lo26 + run: nix develop .#ci --command mix test --include integration --include lo26 env: URP_INTEGRATION: "1" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b59298..617c7d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,19 +30,21 @@ jobs: with: path: deps key: ${{ runner.os }}-mix-deps-${{ hashFiles('mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix-deps- - name: Install dependencies - run: nix develop --command mix deps.get --check-locked + run: nix develop .#ci --command mix deps.get --check-locked - name: Verify tag, package version, and changelog run: | version="$(tr -d '[:space:]' < VERSION)" test "${GITHUB_REF_NAME}" = "v${version}" grep --fixed-strings --quiet "## [v${version}]" CHANGELOG.md - nix develop --command mix hex.build + nix develop .#ci --command mix hex.build - name: Publish to Hex - run: nix develop --command mix hex.publish --yes + run: nix develop .#ci --command mix hex.publish --yes env: HEX_API_KEY: ${{ secrets.HEX_API_KEY }} diff --git a/flake.nix b/flake.nix index ca1fa85..92c64b9 100644 --- a/flake.nix +++ b/flake.nix @@ -12,6 +12,8 @@ let pkgs = nixpkgs.legacyPackages.${system}; beamPackages = pkgs.beam.packages.erlang_29; + # CI/release tasks are headless; avoid the full wx and systemd closure. + ciBeamPackages = pkgs.beamMinimal29Packages; in { default = pkgs.mkShell { @@ -24,6 +26,15 @@ pkgs.uv ]; }; + + ci = pkgs.mkShell { + packages = [ + ciBeamPackages.erlang + ciBeamPackages.elixir_1_20 + ciBeamPackages.hex + ciBeamPackages.rebar3 + ]; + }; } ); };