From aeb0dcbf6a3f239601aacd717cb080c45b739b7f Mon Sep 17 00:00:00 2001 From: seth Date: Thu, 11 Jan 2024 16:47:25 -0500 Subject: [PATCH] ci: cleanup all workflows (#71) * ci: merge test-vm and format workflows * ci: don't use matrix for doc gen * ci: use inputs from dev flake --- .github/workflows/ci.yml | 51 +++++++++++++++++++++++++++++++ .github/workflows/format.yml | 24 --------------- .github/workflows/release.yml | 3 +- .github/workflows/test-vm.yml | 35 --------------------- .github/workflows/update-docs.yml | 42 ++++++++++++++----------- .github/workflows/update-lock.yml | 6 ++-- 6 files changed, 81 insertions(+), 80 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/format.yml delete mode 100644 .github/workflows/test-vm.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..67bc1ae --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,51 @@ +name: CI + +on: + push: + branches: [main] + paths: + - '**.lock' + - '**.nix' + pull_request: + workflow_dispatch: + +jobs: + format: + name: Check formatting + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + + - name: Install Nix + uses: cachix/install-nix-action@v24 + + - name: Run formatter + run: | + nix run --inputs-from ./dev nixpkgs#nixpkgs-fmt -- . + + - name: Check for changes + run: git diff --color=always --exit-code + + vm: + name: Test Modules + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + + - name: Install Nix + uses: cachix/install-nix-action@v24 + + - name: Setup cache + uses: DeterminateSystems/magic-nix-cache-action@v2 + + - name: Run VM + run: | + nix build -L --show-trace ./dev#checks.x86_64-linux.module-vm-test diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml deleted file mode 100644 index 51d737f..0000000 --- a/.github/workflows/format.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Format - -on: - push: - branches: [main] - pull_request: - -jobs: - format-check: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: cachix/install-nix-action@v24 - - - name: Run formatter - run: | - pushd dev/ - nix fmt - popd - - - name: Check for changes - run: git diff --color=always --exit-code diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2b76e8d..a728d7d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: release +name: Release on: push: @@ -6,6 +6,7 @@ on: jobs: release-please: + name: Make release runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/test-vm.yml b/.github/workflows/test-vm.yml deleted file mode 100644 index f905692..0000000 --- a/.github/workflows/test-vm.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Test modules - -on: - push: - paths: - - '_sources/**' - - 'modules/**' - - 'test.nix' - - 'flake.*' - - 'dev/flake.*' - pull_request: - paths: - - '_sources/**' - - 'modules/**' - - 'test.nix' - - 'flake.*' - - 'dev/flake.*' - workflow_dispatch: - -jobs: - run-vm: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: cachix/install-nix-action@v24 - with: - extra_nix_config: "system-features = benchmark big-parallel kvm nixos-test uid-range" - - - uses: DeterminateSystems/magic-nix-cache-action@main - - - name: Run VM - run: | - nix build -Lv ./dev#checks.x86_64-linux.module-vm-test diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml index f26cb34..beaeb13 100644 --- a/.github/workflows/update-docs.yml +++ b/.github/workflows/update-docs.yml @@ -2,44 +2,50 @@ name: Update docs on: push: + branches: [main] paths: - "modules/home-manager/**" - "modules/nixos/**" workflow_dispatch: jobs: - update-docs: + update: + name: Run update runs-on: ubuntu-latest permissions: contents: write - strategy: - max-parallel: 1 - matrix: - package: ["nixos", "home-manager"] - - # we only want this running on our repo, on the `main` branch - if: github.repository == 'Stonks3141/ctp-nix' && github.ref_name == 'main' + # we only want this running on our repo + if: github.repository == 'Stonks3141/ctp-nix' steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v24 + + - name: Install Nix + uses: cachix/install-nix-action@v24 + + - name: Set Git user info + run: | + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' - name: Get short revision id: rev run: echo "rev=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" - - name: Build doc + - name: Build & update docs run: | - nix build ./dev#${{ matrix.package }}-doc - - - name: Update doc - run: cat result > docs/${{ matrix.package }}-options.md + for module in "nixos" "home-manager"; do + nix build -L --show-trace ./dev#"$module"-doc + cat result > docs/"$module"-options.md + rm result + done - name: Commit changes - uses: EndBug/add-and-commit@v9 - with: - default_author: github_actions - message: "docs: update docs for ${{ steps.rev.outputs.rev }}" + run: | + if ! git diff --color=always --exit-code; then + git commit -am "docs: update for ${{ steps.rev.outputs.rev }}" + git push + fi diff --git a/.github/workflows/update-lock.yml b/.github/workflows/update-lock.yml index fdf27fa..688db27 100644 --- a/.github/workflows/update-lock.yml +++ b/.github/workflows/update-lock.yml @@ -13,7 +13,9 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v24 + + - name: Install Nix + uses: cachix/install-nix-action@v24 - name: Set Git user info run: | @@ -41,7 +43,7 @@ jobs: - name: Update upstream sources run: | - nix run --inputs-from . nixpkgs#nvfetcher + nix run --inputs-from ./dev nixpkgs#nvfetcher if ! git diff --color=always --exit-code; then git commit -am "chore: update nvfetcher sources"