Skip to content

ci: add gh cache to nix action #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .github/actions/nix-devshell/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,28 @@ runs:
using: "composite"
steps:
- name: Setup Nix
uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d # v16
uses: nixbuild/nix-quick-install-action@5bb6a3b3abe66fd09bbf250dce8ada94f856a703 # v30

- uses: nix-community/cache-nix-action@92aaf15ec4f2857ffed00023aecb6504bb4a5d3d # v6
with:
# restore and save a cache using this key
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
# if there's no cache hit, restore a cache by this prefix
restore-prefixes-first-match: nix-${{ runner.os }}-
# collect garbage until Nix store size (in bytes) is at most this number
# before trying to save a new cache
# 1 GB = 1073741824 B
gc-max-store-size-linux: 1073741824
# do purge caches
purge: true
# purge all versions of the cache
purge-prefixes: nix-${{ runner.os }}-
# created more than this number of seconds ago relative to the start of the `Post Restore` phase
purge-created: 0
# except the version with the `primary-key`, if it exists
purge-primary-key: never

- name: Enter devshell
uses: nicknovitski/nix-develop@9be7cfb4b10451d3390a75dc18ad0465bed4932a # v1.2.1
with:
arguments: ".#ci"
1 change: 1 addition & 0 deletions .ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds .ignore file for search tool configuration

What's this do?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tools like ripgrep use it as an additional source of ignore patterns (think of it like gitignore, but not tied to git).

This config specifically allows me to include the files in the github folder by default instead of having to include them specifically.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh because it starts with . it gets ignored by those by default, I see! Good idea

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.github
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ XCPROJECT := Coder\ Desktop/Coder\ Desktop.xcodeproj
SCHEME := Coder\ Desktop
SWIFT_VERSION := 6.0

CURRENT_PROJECT_VERSION:=$(shell git describe --match 'v[0-9]*' --dirty='.devel' --always --tags)
ifndef CURRENT_PROJECT_VERSION
CURRENT_PROJECT_VERSION:=$(shell git describe --match 'v[0-9]*' --dirty='.devel' --always --tags)
endif
ifeq ($(strip $(CURRENT_PROJECT_VERSION)),)
$(error CURRENT_PROJECT_VERSION cannot be empty)
$(error CURRENT_PROJECT_VERSION cannot be empty)
endif

MARKETING_VERSION:=$(shell git describe --match 'v[0-9]*' --tags --abbrev=0 | sed 's/^v//' | sed 's/-.*$$//')
ifndef MARKETING_VERSION
MARKETING_VERSION:=$(shell git describe --match 'v[0-9]*' --tags --abbrev=0 | sed 's/^v//' | sed 's/-.*$$//')
endif
ifeq ($(strip $(MARKETING_VERSION)),)
$(error MARKETING_VERSION cannot be empty)
$(error MARKETING_VERSION cannot be empty)
endif

# Define the keychain file name first
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 32 additions & 20 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,38 @@
{
inherit formatter;

devShells.default = pkgs.mkShellNoCC {
buildInputs = with pkgs; [
actionlint
apple-sdk_15
clang
coreutils
create-dmg
formatter
gh
gnumake
protobuf_28
protoc-gen-swift
swiftformat
swiftlint
watchexec
xcbeautify
xcodegen
xcpretty
zizmor
];
devShells = rec {
# Need to use a devshell for CI, as we want to reuse the already existing Xcode on the runner
ci = pkgs.mkShellNoCC {
buildInputs = with pkgs; [
actionlint
clang
coreutils
create-dmg
gh
git
gnumake
protobuf_28
protoc-gen-swift
swiftformat
swiftlint
xcbeautify
xcodegen
xcpretty
zizmor
];
};

default = pkgs.mkShellNoCC {
buildInputs =
with pkgs;
[
apple-sdk_15
formatter
watchexec
]
++ ci.buildInputs;
};
};
}
);
Expand Down
Loading