From 38edf8a0b4d9076960baa71e3c6987a9229a5a32 Mon Sep 17 00:00:00 2001 From: regnat Date: Thu, 24 Feb 2022 15:59:59 +0100 Subject: [PATCH] Split the CI in several steps --- .github/workflows/ci.yml | 35 +++++++++++++++++++++--- scripts/list-tests-flake-outptus-for-gha | 11 ++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100755 scripts/list-tests-flake-outptus-for-gha diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09436b7e3..131eca535 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,13 +6,15 @@ on: jobs: - tests: + build: needs: [check_cachix] strategy: matrix: os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} timeout-minutes: 60 + outputs: + flake-outputs-json: ${{ steps.list-outputs.outputs.json }} steps: - uses: actions/checkout@v2.4.0 with: @@ -25,7 +27,32 @@ jobs: name: '${{ env.CACHIX_NAME }}' signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - run: nix --experimental-features 'nix-command flakes' flake check -L + - run: nix --experimental-features 'nix-command flakes' build -L + - name: List all the tests to run + id: list-outputs + run: scripts/list-tests-flake-outptus-for-gha + + test: + needs: [build, check_cachix] + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + outputName: ${{ fromJson(needs.build.outputs.flake-outputs-json) }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2.4.0 + with: + fetch-depth: 0 + - uses: cachix/install-nix-action@v16 + - run: echo CACHIX_NAME="$(echo $GITHUB_REPOSITORY-install-tests | tr "[A-Z]/" "[a-z]-")" >> $GITHUB_ENV + - uses: cachix/cachix-action@v10 + if: needs.check_cachix.outputs.secret == 'true' + with: + name: '${{ env.CACHIX_NAME }}' + signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - run: nix --experimental-features 'nix-command flakes' build .#checks.$(nix eval --raw --impure --expr builtins.currentSystem).${{ matrix.outputName }} -L + check_cachix: name: Cachix secret present for installer tests @@ -40,7 +67,7 @@ jobs: run: echo "::set-output name=secret::${{ env._CACHIX_SECRETS != '' }}" installer: - needs: [tests, check_cachix] + needs: [test, check_cachix] if: github.event_name == 'push' && needs.check_cachix.outputs.secret == 'true' runs-on: ubuntu-latest outputs: @@ -76,7 +103,7 @@ jobs: - run: nix-instantiate -E 'builtins.currentTime' --eval docker_push_image: - needs: [check_cachix, tests] + needs: [check_cachix, build] if: >- github.event_name == 'push' && github.ref_name == 'master' && diff --git a/scripts/list-tests-flake-outptus-for-gha b/scripts/list-tests-flake-outptus-for-gha new file mode 100755 index 000000000..b93cf559e --- /dev/null +++ b/scripts/list-tests-flake-outptus-for-gha @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail +set -x + +nix build --inputs-from . nixpkgs#jq -o jq + +TEST_NAMES=$(nix flake show . --json | ./jq-bin/bin/jq -c ".checks[\"$(nix eval --raw --impure --expr builtins.currentSystem)\"] | keys") + + +echo "::set-output name=json::$TEST_NAMES"