From ce6a9bccd30a563dccdf28e59f7b47de04b1b460 Mon Sep 17 00:00:00 2001 From: Robert James Hernandez Date: Tue, 24 Sep 2024 05:29:33 +0000 Subject: [PATCH] gha: limit nixos builds to master and manual Running these on every PR or every push to a PR quickly gets us rate limited by github. Its unclear if theres a way around this cache rate limit: https://github.com/DeterminateSystems/magic-nix-cache-action?tab=readme-ov-file#usage-notes Moving this to only running on `master` and manually should do the trick for now. If it persists we might have to move it to a scheduled job like openwrt builds. --- .github/workflows/ci-nixos.yml | 40 ++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 30 ------------------------- 2 files changed, 40 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/ci-nixos.yml diff --git a/.github/workflows/ci-nixos.yml b/.github/workflows/ci-nixos.yml new file mode 100644 index 00000000..5edec337 --- /dev/null +++ b/.github/workflows/ci-nixos.yml @@ -0,0 +1,40 @@ +name: ci-nixos +on: + push: # This is only run when PRs are merged into master + branches: + - master + workflow_dispatch: +# These jobs can take a long time and potentially cause us to bump up against CI +# rate limits. Instead we've opted to run these only on merges to master. We might +# have to limit these further if the rate limiting remains +jobs: + nixos_configs_get: + name: nixos configurations get name + runs-on: ubuntu-latest + outputs: + nixosconfignames: ${{ steps.nixosconfigsget.outputs.nixosconfignames }} + steps: + - uses: actions/checkout@v3 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - name: Get all NixOS configurations + id: nixosconfigsget + run: | + nixosconfignames=$(nix eval .\#nixosConfigurations --apply builtins.attrNames --json) + echo "$nixosconfignames" + echo "nixosconfignames=$nixosconfignames" >> $GITHUB_OUTPUT + nixos_configs_build: + name: build ${{ matrix.configName }} nixos configuration + needs: nixos_configs_get + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + configName: ${{ fromJSON(needs.nixos_configs_get.outputs.nixosconfignames) }} + steps: + - uses: actions/checkout@v3 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - name: Build ${{ matrix.configName }} nixos configuration + run: | + nix build -L .#nixosConfigurations.${{ matrix.configName }}.config.system.build.toplevel diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14c9130f..31a45288 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,33 +28,3 @@ jobs: - run: nix build -L .#massflash - run: nix build -L .#scaleInventory - run: nix build -L .#serverspec - nixos_configs_get: - name: nixos configurations get name - runs-on: ubuntu-latest - outputs: - nixosconfignames: ${{ steps.nixosconfigsget.outputs.nixosconfignames }} - steps: - - uses: actions/checkout@v3 - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - - name: Get all NixOS configurations - id: nixosconfigsget - run: | - nixosconfignames=$(nix eval .\#nixosConfigurations --apply builtins.attrNames --json) - echo "$nixosconfignames" - echo "nixosconfignames=$nixosconfignames" >> $GITHUB_OUTPUT - nixos_configs_build: - name: build ${{ matrix.configName }} nixos configuration - needs: nixos_configs_get - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - configName: ${{ fromJSON(needs.nixos_configs_get.outputs.nixosconfignames) }} - steps: - - uses: actions/checkout@v3 - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - - name: Build ${{ matrix.configName }} nixos configuration - run: | - nix build -L .#nixosConfigurations.${{ matrix.configName }}.config.system.build.toplevel