From 2efe3e0b5786bcf8076c804fc2f432efde69fd12 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 5 Jun 2024 11:27:50 +0300 Subject: [PATCH] ci: fine-grain trigger conditions --- .../workflows/{audit.yml => cargo-audit.yml} | 2 +- .github/workflows/cargo-build.yml | 40 +++++++++++++ .../{update.yml => cargo-update.yml} | 9 +-- .github/workflows/nix-build.yml | 60 +++++++++++++++++++ .github/workflows/{nix.yml => nix-cache.yml} | 16 ++--- 5 files changed, 110 insertions(+), 17 deletions(-) rename .github/workflows/{audit.yml => cargo-audit.yml} (95%) create mode 100644 .github/workflows/cargo-build.yml rename .github/workflows/{update.yml => cargo-update.yml} (84%) create mode 100644 .github/workflows/nix-build.yml rename .github/workflows/{nix.yml => nix-cache.yml} (81%) diff --git a/.github/workflows/audit.yml b/.github/workflows/cargo-audit.yml similarity index 95% rename from .github/workflows/audit.yml rename to .github/workflows/cargo-audit.yml index 797e920..8c333ca 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/cargo-audit.yml @@ -1,4 +1,4 @@ -name: Security audit +name: "Security audit" on: workflow_call: workflow_dispatch: diff --git a/.github/workflows/cargo-build.yml b/.github/workflows/cargo-build.yml new file mode 100644 index 0000000..3314380 --- /dev/null +++ b/.github/workflows/cargo-build.yml @@ -0,0 +1,40 @@ +name: "Build with Cargo" +on: + workflow_call: + workflow_dispatch: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: cachix/install-nix-action@v26 + - uses: DeterminateSystems/magic-nix-cache-action@main + + - name: Install dependencies + run: nix profile install --inputs-from .# + + - uses: actions-rs/toolchain@v1 + name: Install rust toolchain + with: + toolchain: nightly + override: true + + - uses: Swatinem/rust-cache@v2 + name: Add caching + + - uses: actions-rs/cargo@v1 + name: Build crate + with: + command: build + args: --verbose diff --git a/.github/workflows/update.yml b/.github/workflows/cargo-update.yml similarity index 84% rename from .github/workflows/update.yml rename to .github/workflows/cargo-update.yml index ea4ee14..dc185fa 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/cargo-update.yml @@ -1,6 +1,7 @@ name: "Update repository dependencies" on: + workflow_call: workflow_dispatch: schedule: - cron: "0 4 1 * *" @@ -14,7 +15,7 @@ jobs: uses: DeterminateSystems/nix-installer-action@main - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Bump nix run: nix flake update @@ -31,12 +32,12 @@ jobs: uses: peter-evans/create-pull-request@v4 with: token: "${{ secrets.github_token }}" - title: "ci: update inputs" + title: "chore: update all inputs" author: GitHub - branch: update + branch: automated-dep-updates branch-suffix: timestamp delete-branch: true commit-message: | - Update all inputs + chore: update all inputs Co-authored-by: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> diff --git a/.github/workflows/nix-build.yml b/.github/workflows/nix-build.yml new file mode 100644 index 0000000..056c17f --- /dev/null +++ b/.github/workflows/nix-build.yml @@ -0,0 +1,60 @@ +name: "Check flake & Build packages" + +on: + workflow_call: + workflow_dispatch: + pull_request: + branches: ["master"] + +jobs: + check-flake: + name: "Check flake validity" + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@main + with: + logger: pretty + + - name: Check Flake + run: nix flake check --accept-flake-config + + build: + name: "Build Exposed Packages" + runs-on: ubuntu-latest + needs: check-flake + strategy: + matrix: + package: + - anyrun + - applications + - dictionary + - kidex + - randr + - rink + - shell + - stdin + - symbols + - websearch + steps: + - uses: easimon/maximize-build-space@v8 + with: + overprovision-lvm: true + remove-android: true + remove-dotnet: true + remove-haskell: true + remove-docker-images: true + remove-codeql: true + + - name: Checkout + uses: actions/checkout@v4 + + - uses: cachix/install-nix-action@v26 + - uses: DeterminateSystems/magic-nix-cache-action@main + + - name: Build anyrun from the defined matrix + run: nix build .#${{ matrix.package }} --print-build-logs --extra-substituters "https://anyrun.cachix.org" diff --git a/.github/workflows/nix.yml b/.github/workflows/nix-cache.yml similarity index 81% rename from .github/workflows/nix.yml rename to .github/workflows/nix-cache.yml index 9a29127..7ccb515 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix-cache.yml @@ -1,13 +1,8 @@ -name: "Set up binary cache & push binaries" +name: "Check flake & Push built packages to cache" on: + workflow_call: workflow_dispatch: - pull_request: - branches: - - master - paths-ignore: - - .gitignore - - README.md push: branches: - master @@ -33,7 +28,7 @@ jobs: run: nix flake check --accept-flake-config cachix: - name: "Build Exposed Packages" + name: "Build & Cache Exposed Packages" runs-on: ubuntu-latest needs: check-flake strategy: @@ -65,13 +60,10 @@ jobs: - uses: cachix/install-nix-action@v26 - uses: DeterminateSystems/magic-nix-cache-action@main - - uses: cachix/cachix-action@v12 + - uses: cachix/cachix-action@v14 with: authToken: ${{ secrets.CACHIX_TOKEN }} name: anyrun - - name: Set default git branch (to reduce log spam) - run: git config --global init.defaultBranch main - - name: Build anyrun from the defined matrix run: nix build .#${{ matrix.package }} --print-build-logs --extra-substituters "https://anyrun.cachix.org"